summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-13 22:48:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-13 22:48:56 +0000
commit311bf2916be85a0eb5fe3e89ee074c20c98abab0 (patch)
treec3a1a033c12eae8c35369f6f8e8a87ec330297a3 /clang
parent0818b26362b56fe6a5ea03b751080d8dc4583a7b (diff)
downloadbcm5719-llvm-311bf2916be85a0eb5fe3e89ee074c20c98abab0.tar.gz
bcm5719-llvm-311bf2916be85a0eb5fe3e89ee074c20c98abab0.zip
Warn about attribute used ignored on "extern int a
__attribute__((used))". llvm-svn: 64499
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp2
-rw-r--r--clang/test/Sema/attr-used.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 29f6cb18a07..3ea2b5064c4 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/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/clang/test/Sema/attr-used.c b/clang/test/Sema/attr-used.c
index 7d0265ef323..10674814ce2 100644
--- a/clang/test/Sema/attr-used.c
+++ b/clang/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;
};
OpenPOWER on IntegriCloud