Warn about attribute used ignored on "extern int a

__attribute__((used))".

llvm-svn: 64499
This commit is contained in:
Daniel Dunbar 2009-02-13 22:48:56 +00:00
parent 0818b26362
commit 311bf2916b
2 changed files with 4 additions and 1 deletions

View 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;
}

View 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;
};