]> granicus.if.org Git - clang/commitdiff
Warn about attribute used ignored on "extern int a
authorDaniel Dunbar <daniel@zuster.org>
Fri, 13 Feb 2009 22:48:56 +0000 (22:48 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 13 Feb 2009 22:48:56 +0000 (22:48 +0000)
__attribute__((used))".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64499 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-used.c

index 29f6cb18a07474da79f37519f9f99cea402dd7c9..3ea2b5064c482154615de6e693953a3e97ba121e 100644 (file)
@@ -439,7 +439,7 @@ static void HandleUsedAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   }
   
   if (const VarDecl *VD = dyn_cast<VarDecl>(d)) {
-    if (VD->hasLocalStorage()) {
+    if (VD->hasLocalStorage() || VD->hasExternalStorage()) {
       S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "used";
       return;
     }
index 7d0265ef323787b1632f21f0e08fa3c3dbd6458b..10674814ce262151a3e82da189362e17f6f28ab2 100644 (file)
@@ -1,5 +1,8 @@
 // RUN: clang -verify -fsyntax-only %s
 
+extern int l0 __attribute__((used)); // expected-warning {{used attribute ignored}}
+__private_extern__ int l1 __attribute__((used)); // expected-warning {{used attribute ignored}}
+
 struct __attribute__((used)) s { // expected-warning {{'used' attribute only applies to variable and function types}}
   int x;
 };