From: Rafael Espindola Date: Sun, 25 Nov 2012 14:00:51 +0000 (+0000) Subject: Add a basic testcase for the "variable is not needed" warning and one that X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c80b522e45243d91838bb9b549f844b762cd2bf;p=clang 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 --- 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 + 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(); + } +}