[cfe-commits] r146169 - /cfe/trunk/test/SemaCXX/warn-func-as-bool.cpp
Lang Hames
lhames at gmail.com
Thu Dec 8 11:26:24 PST 2011
Author: lhames
Date: Thu Dec 8 13:26:24 2011
New Revision: 146169
URL: http://llvm.org/viewvc/llvm-project?rev=146169&view=rev
Log:
Added missing testcase from r145849. Thanks to Dave Blaikie for catching this.
Added:
cfe/trunk/test/SemaCXX/warn-func-as-bool.cpp
Added: cfe/trunk/test/SemaCXX/warn-func-as-bool.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-func-as-bool.cpp?rev=146169&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-func-as-bool.cpp (added)
+++ cfe/trunk/test/SemaCXX/warn-func-as-bool.cpp Thu Dec 8 13:26:24 2011
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -x c++ -verify -fsyntax-only %s
+
+void f1();
+
+struct S {
+ static void f2();
+};
+
+extern void f3() __attribute__((weak_import));
+
+struct S2 {
+ static void f4() __attribute__((weak_import));
+};
+
+void bar() {
+ bool b;
+
+ b = f1; // expected-warning {{address of function 'f1' will always evaluate to 'true'}}
+ if (f1) {} // expected-warning {{address of function 'f1' will always evaluate to 'true'}}
+ b = S::f2; // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}}
+ if (S::f2) {} // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}}
+
+ // implicit casts of weakly imported symbols are ok:
+ b = f3;
+ if (f3) {}
+ b = S2::f4;
+ if (S2::f4) {}
+}
More information about the cfe-commits
mailing list