Add a basic testcase for the "variable is not needed" warning and one that
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 25 Nov 2012 14:00:51 +0000 (14:00 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 25 Nov 2012 14:00:51 +0000 (14:00 +0000)
regressed in r168519.

llvm-svn: 168563

clang/test/SemaCXX/warn-variable-not-needed.cpp [new file with mode: 0644]

diff --git a/clang/test/SemaCXX/warn-variable-not-needed.cpp b/clang/test/SemaCXX/warn-variable-not-needed.cpp
new file mode 100644 (file)
index 0000000..0fb0f81
--- /dev/null
@@ -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();
+  }
+}