[cfe-commits] r168563 - /cfe/trunk/test/SemaCXX/warn-variable-not-needed.cpp

Rafael Espindola rafael.espindola at gmail.com
Sun Nov 25 06:00:51 PST 2012


Author: rafael
Date: Sun Nov 25 08:00:51 2012
New Revision: 168563

URL: http://llvm.org/viewvc/llvm-project?rev=168563&view=rev
Log:
Add a basic testcase for the "variable is not needed" warning and one that
regressed in r168519.

Added:
    cfe/trunk/test/SemaCXX/warn-variable-not-needed.cpp

Added: cfe/trunk/test/SemaCXX/warn-variable-not-needed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-variable-not-needed.cpp?rev=168563&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-variable-not-needed.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-variable-not-needed.cpp Sun Nov 25 08:00:51 2012
@@ -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();
+  }
+}





More information about the cfe-commits mailing list