summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-unused-variables.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-06-21 23:42:09 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-06-21 23:42:09 +0000
commit2602a683e09c84ec4e28314abb60c6e2a900ef0e (patch)
tree785be00529f1278236e6d3eb08d0d07201d4f9c0 /clang/test/SemaCXX/warn-unused-variables.cpp
parentcf5f43ce1fdd4bbade729dc478ea77efc6d807b5 (diff)
downloadbcm5719-llvm-2602a683e09c84ec4e28314abb60c6e2a900ef0e.tar.gz
bcm5719-llvm-2602a683e09c84ec4e28314abb60c6e2a900ef0e.zip
Fix PR10168: don't warn for unused non-dependent variables in both the template definition and each instantiation.
llvm-svn: 133580
Diffstat (limited to 'clang/test/SemaCXX/warn-unused-variables.cpp')
-rw-r--r--clang/test/SemaCXX/warn-unused-variables.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp
index 81f22a796a0..5ba1f2a5f34 100644
--- a/clang/test/SemaCXX/warn-unused-variables.cpp
+++ b/clang/test/SemaCXX/warn-unused-variables.cpp
@@ -54,3 +54,29 @@ void unused_local_static() {
static int y = 0; // expected-warning{{unused variable 'y'}}
#pragma unused(x)
}
+
+// PR10168
+namespace PR10168 {
+ // We expect a warning in the definition only for non-dependent variables, and
+ // a warning in the instantiation only for dependent variables.
+ template<typename T>
+ struct S {
+ void f() {
+ int a; // expected-warning {{unused variable 'a'}}
+ T b; // expected-warning 2{{unused variable 'b'}}
+ }
+ };
+
+ template<typename T>
+ void f() {
+ int a; // expected-warning {{unused variable 'a'}}
+ T b; // expected-warning 2{{unused variable 'b'}}
+ }
+
+ void g() {
+ S<int>().f(); // expected-note {{here}}
+ S<char>().f(); // expected-note {{here}}
+ f<int>(); // expected-note {{here}}
+ f<char>(); // expected-note {{here}}
+ }
+}
OpenPOWER on IntegriCloud