[cfe-commits] r64499 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/Sema/attr-used.c
Daniel Dunbar
daniel at zuster.org
Fri Feb 13 14:48:56 PST 2009
Author: ddunbar
Date: Fri Feb 13 16:48:56 2009
New Revision: 64499
URL: http://llvm.org/viewvc/llvm-project?rev=64499&view=rev
Log:
Warn about attribute used ignored on "extern int a
__attribute__((used))".
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/attr-used.c
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=64499&r1=64498&r2=64499&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Feb 13 16:48:56 2009
@@ -439,7 +439,7 @@
}
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;
}
Modified: cfe/trunk/test/Sema/attr-used.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-used.c?rev=64499&r1=64498&r2=64499&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-used.c (original)
+++ cfe/trunk/test/Sema/attr-used.c Fri Feb 13 16:48:56 2009
@@ -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;
};
More information about the cfe-commits
mailing list