Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -x c++ -verify -fsyntax-only %s
      2 
      3 void f1();
      4 
      5 struct S {
      6   static void f2();
      7 };
      8 
      9 extern void f3() __attribute__((weak_import));
     10 
     11 struct S2 {
     12   static void f4() __attribute__((weak_import));
     13 };
     14 
     15 bool f5();
     16 bool f6(int);
     17 
     18 void bar() {
     19   bool b;
     20 
     21   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}}
     34 
     35   // implicit casts of weakly imported symbols are ok:
     36   b = f3;
     37   if (f3) {}
     38   b = S2::f4;
     39   if (S2::f4) {}
     40 }
     41