diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-02 18:28:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-04-02 18:28:36 +0000 |
commit | c392617cff4f5293c6a1c62a1d2dd3aa048c68ac (patch) | |
tree | 1df5040a2cd08761ace27d34beeb918f3c82ee95 /clang/test | |
parent | 65813a3bce7cb1806a5c510ca0685f02c83720ad (diff) | |
download | bcm5719-llvm-c392617cff4f5293c6a1c62a1d2dd3aa048c68ac.tar.gz bcm5719-llvm-c392617cff4f5293c6a1c62a1d2dd3aa048c68ac.zip |
PR19305: Don't issue -Wunused-variable warnings on variable templates. It's not
meaningful to odr-use the VarDecl inside a variable template. (Separately, it'd
be nice to track referenced-ness for templates, and warn on unused ones, but
that's really a distinct issue...)
Move a test that generates and tests a warning-suppressing error out to its own
test file, so it doesn't have weird effects on the other tests in the same file.
llvm-svn: 205448
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaCXX/warn-unused-label-error.cpp | 26 | ||||
-rw-r--r-- | clang/test/SemaCXX/warn-unused-variables.cpp | 36 |
2 files changed, 38 insertions, 24 deletions
diff --git a/clang/test/SemaCXX/warn-unused-label-error.cpp b/clang/test/SemaCXX/warn-unused-label-error.cpp new file mode 100644 index 00000000000..66b616f3cf2 --- /dev/null +++ b/clang/test/SemaCXX/warn-unused-label-error.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -verify %s + +static int unused_local_static; + +namespace PR8455 { + void f() { + A: // expected-warning {{unused label 'A'}} + __attribute__((unused)) int i; // attribute applies to variable + B: // attribute applies to label + __attribute__((unused)); int j; // expected-warning {{unused variable 'j'}} + } + + void g() { + C: // unused label 'C' will not appear here because an error has occurred + __attribute__((unused)) + #pragma weak unused_local_static // expected-error {{expected ';' after __attribute__}} + ; + } + + void h() { + D: // expected-warning {{unused label 'D'}} + #pragma weak unused_local_static + __attribute__((unused)) // expected-warning {{declaration does not declare anything}} + ; + } +} diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp index 93d2f6f9563..ecb36ec2749 100644 --- a/clang/test/SemaCXX/warn-unused-variables.cpp +++ b/clang/test/SemaCXX/warn-unused-variables.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s template<typename T> void f() { T t; t = 17; @@ -115,6 +115,17 @@ namespace PR11550 { } } +namespace PR19305 { + template<typename T> int n = 0; // no warning + int a = n<int>; + + template<typename T> const int l = 0; // no warning + int b = l<int>; + + // FIXME: It'd be nice to warn here. + template<typename T> int m = 0; +} + namespace ctor_with_cleanups { struct S1 { ~S1(); @@ -128,26 +139,3 @@ namespace ctor_with_cleanups { } #include "Inputs/warn-unused-variables.h" - -namespace PR8455 { - void f() { - A: // expected-warning {{unused label 'A'}} - __attribute__((unused)) int i; // attribute applies to variable - B: // attribute applies to label - __attribute__((unused)); int j; // expected-warning {{unused variable 'j'}} - } - - void g() { - C: // unused label 'C' will not appear here because an error occurs - __attribute__((unused)) - #pragma weak unused_local_static // expected-error {{expected ';' after __attribute__}} - ; - } - - void h() { - D: // expected-warning {{unused label 'D'}} - #pragma weak unused_local_static - __attribute__((unused)) // expected-warning {{declaration does not declare anything}} - ; - } -} |