]> granicus.if.org Git - clang/commitdiff
Added missing testcase from r145849. Thanks to Dave Blaikie for catching this.
authorLang Hames <lhames@gmail.com>
Thu, 8 Dec 2011 19:26:24 +0000 (19:26 +0000)
committerLang Hames <lhames@gmail.com>
Thu, 8 Dec 2011 19:26:24 +0000 (19:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146169 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaCXX/warn-func-as-bool.cpp [new file with mode: 0644]

diff --git a/test/SemaCXX/warn-func-as-bool.cpp b/test/SemaCXX/warn-func-as-bool.cpp
new file mode 100644 (file)
index 0000000..2606b4d
--- /dev/null
@@ -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) {}
+}