blob: b5df744f93067a77082d932c734fe63372a135a7 [file] [log] [blame]
Lang Hames2cad9e32011-12-08 19:26:24 +00001// RUN: %clang_cc1 -x c++ -verify -fsyntax-only %s
2
3void f1();
4
5struct S {
6 static void f2();
7};
8
9extern void f3() __attribute__((weak_import));
10
11struct S2 {
12 static void f4() __attribute__((weak_import));
13};
14
David Blaikie2def7732011-12-09 21:42:37 +000015bool f5();
16bool f6(int);
17
Lang Hames2cad9e32011-12-08 19:26:24 +000018void bar() {
19 bool b;
20
David Blaikie2def7732011-12-09 21:42:37 +000021 b = f1; // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
22 expected-note {{prefix with the address-of operator to silence this warning}}
23 if (f1) {} // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
24 expected-note {{prefix with the address-of operator to silence this warning}}
25 b = S::f2; // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
26 expected-note {{prefix with the address-of operator to silence this warning}}
27 if (S::f2) {} // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
28 expected-note {{prefix with the address-of operator to silence this warning}}
29 b = f5; // expected-warning {{address of function 'f5' will always evaluate to 'true'}} \
30 expected-note {{prefix with the address-of operator to silence this warning}} \
31 expected-note {{suffix with parentheses to turn this into a function call}}
32 b = f6; // expected-warning {{address of function 'f6' will always evaluate to 'true'}} \
33 expected-note {{prefix with the address-of operator to silence this warning}}
Lang Hames2cad9e32011-12-08 19:26:24 +000034
35 // implicit casts of weakly imported symbols are ok:
36 b = f3;
37 if (f3) {}
38 b = S2::f4;
39 if (S2::f4) {}
40}