blob: b5df744f93067a77082d932c734fe63372a135a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// 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));
};
bool f5();
bool f6(int);
void bar() {
bool b;
b = f1; // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
expected-note {{prefix with the address-of operator to silence this warning}}
if (f1) {} // expected-warning {{address of function 'f1' will always evaluate to 'true'}} \
expected-note {{prefix with the address-of operator to silence this warning}}
b = S::f2; // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
expected-note {{prefix with the address-of operator to silence this warning}}
if (S::f2) {} // expected-warning {{address of function 'S::f2' will always evaluate to 'true'}} \
expected-note {{prefix with the address-of operator to silence this warning}}
b = f5; // expected-warning {{address of function 'f5' will always evaluate to 'true'}} \
expected-note {{prefix with the address-of operator to silence this warning}} \
expected-note {{suffix with parentheses to turn this into a function call}}
b = f6; // expected-warning {{address of function 'f6' will always evaluate to 'true'}} \
expected-note {{prefix with the address-of operator to silence this warning}}
// implicit casts of weakly imported symbols are ok:
b = f3;
if (f3) {}
b = S2::f4;
if (S2::f4) {}
}
|