diff options
| author | Lang Hames <lhames@gmail.com> | 2011-12-08 19:26:24 +0000 |
|---|---|---|
| committer | Lang Hames <lhames@gmail.com> | 2011-12-08 19:26:24 +0000 |
| commit | 34792a8250c1087287c9fe08dec692acdbb1af72 (patch) | |
| tree | f6e6cb7a0013993d8a5771af63df639cef564899 | |
| parent | cdf89fdeafbe7daf31822c6eaa034915a259be31 (diff) | |
| download | bcm5719-llvm-34792a8250c1087287c9fe08dec692acdbb1af72.tar.gz bcm5719-llvm-34792a8250c1087287c9fe08dec692acdbb1af72.zip | |
Added missing testcase from r145849. Thanks to Dave Blaikie for catching this.
llvm-svn: 146169
| -rw-r--r-- | clang/test/SemaCXX/warn-func-as-bool.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-func-as-bool.cpp b/clang/test/SemaCXX/warn-func-as-bool.cpp new file mode 100644 index 00000000000..2606b4da953 --- /dev/null +++ b/clang/test/SemaCXX/warn-func-as-bool.cpp @@ -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) {} +} |

