diff options
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 2 | ||||
-rw-r--r-- | test/Sema/attr-used.c | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 29f6cb18a0..3ea2b5064c 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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; } diff --git a/test/Sema/attr-used.c b/test/Sema/attr-used.c index 7d0265ef32..10674814ce 100644 --- a/test/Sema/attr-used.c +++ b/test/Sema/attr-used.c @@ -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; }; |