aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--lib/Sema/SemaAttr.cpp4
-rw-r--r--test/Sema/pragma-unused.c17
3 files changed, 12 insertions, 13 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td
index 3d9d8d38be..bd9e441a84 100644
--- a/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/include/clang/Basic/DiagnosticSemaKinds.td
@@ -279,8 +279,8 @@ def warn_pragma_pack_pop_failed : Warning<"#pragma pack(pop, ...) failed: %0">;
def warn_pragma_unused_undeclared_var : Warning<
"undeclared variable %0 used as an argument for '#pragma unused'">;
-def warn_pragma_unused_expected_localvar : Warning<
- "only local variables can be arguments to '#pragma unused'">;
+def warn_pragma_unused_expected_var_arg : Warning<
+ "only variables can be arguments to '#pragma unused'">;
def err_unsupported_pragma_weak : Error<
"using '#pragma weak' to refer to an undeclared identifier is not yet supported">;
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp
index a67c4fbbb2..c983199cf9 100644
--- a/lib/Sema/SemaAttr.cpp
+++ b/lib/Sema/SemaAttr.cpp
@@ -277,8 +277,8 @@ void Sema::ActOnPragmaUnused(const Token &IdTok, Scope *curScope,
}
VarDecl *VD = Lookup.getAsSingle<VarDecl>();
- if (!VD || !(VD->hasLocalStorage() || VD->isStaticLocal())) {
- Diag(PragmaLoc, diag::warn_pragma_unused_expected_localvar)
+ if (!VD) {
+ Diag(PragmaLoc, diag::warn_pragma_unused_expected_var_arg)
<< Name << SourceRange(IdTok.getLocation());
return;
}
diff --git a/test/Sema/pragma-unused.c b/test/Sema/pragma-unused.c
index 5f379458a2..aafac0de20 100644
--- a/test/Sema/pragma-unused.c
+++ b/test/Sema/pragma-unused.c
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -Wused-but-marked-unused -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -Wused-but-marked-unused -Wunused -verify %s
void f1(void) {
int x, y, z;
#pragma unused(x)
#pragma unused(y, z)
- int w; // FIXME: We should emit a warning that 'w' is unused.
+ int w; // expected-warning {{unused}}
#pragma unused w // expected-warning{{missing '(' after '#pragma unused' - ignoring}}
}
void f2(void) {
- int x, y;
+ int x, y; // expected-warning {{unused}} expected-warning {{unused}}
#pragma unused(x,) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
#pragma unused() // expected-warning{{expected '#pragma unused' argument to be a variable name}}
}
@@ -20,15 +20,10 @@ void f3(void) {
}
void f4(void) {
- int w; // FIXME: We should emit a warning that 'w' is unused.
+ int w; // expected-warning {{unused}}
#pragma unused((w)) // expected-warning{{expected '#pragma unused' argument to be a variable name}}
}
-int k;
-void f5(void) {
- #pragma unused(k) // expected-warning{{only local variables can be arguments to '#pragma unused'}}
-}
-
void f6(void) {
int z; // no-warning
{
@@ -64,3 +59,7 @@ int f12(int x) {
#pragma unused(x) // expected-warning{{'x' was marked unused but was used}}
return y;
}
+
+// rdar://8793832
+static int glob_var = 0;
+#pragma unused(glob_var)