aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-11-25 14:00:51 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-11-25 14:00:51 +0000
commit1c80b522e45243d91838bb9b549f844b762cd2bf (patch)
treeabb276e6b45e5404fdd8344bb6998a67ad86b954
parent1059653db7ac43ff361663bea35352f82285cc22 (diff)
Add a basic testcase for the "variable is not needed" warning and one that
regressed in r168519. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168563 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/SemaCXX/warn-variable-not-needed.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-variable-not-needed.cpp b/test/SemaCXX/warn-variable-not-needed.cpp
new file mode 100644
index 0000000000..0fb0f8151b
--- /dev/null
+++ b/test/SemaCXX/warn-variable-not-needed.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s
+
+namespace test1 {
+ static int abc = 42; // expected-warning {{variable 'abc' is not needed and will not be emitted}}
+ template <typename T>
+ int foo(void) {
+ return abc;
+ }
+}
+
+namespace test2 {
+ struct bah {
+ };
+ namespace {
+ struct foo : bah {
+ static char bar;
+ virtual void zed();
+ };
+ void foo::zed() {
+ bar++;
+ }
+ char foo::bar=0;
+ }
+ bah *getfoo() {
+ return new foo();
+ }
+}