1 /* { dg-do compile } */
2 /* { dg-require-weak "" } */
3 /* { dg-options "-Waddress" } */
4 /* Warning when addr convert to bool always gives known result.
5 Ada/Pascal programmers sometimes write 0-param functions without
6 (), and might as well warn on variables, too. */
10 int weak_func (void) __attribute__ ((weak
));
11 extern int weak_var
__attribute__ ((weak
));
16 if (func
) /* { dg-warning "the address of 'func'" } */
18 if (!func
) /* { dg-warning "the address of 'func'" } */
20 if (&var
) /* { dg-warning "the address of 'var'" } */
22 if (!&var
) /* { dg-warning "the address of 'var'" } */
35 /* Test equality with 0 on the right hand side. */
37 test_func_cmp_rhs_zero (void)
39 if (func
== 0) /* { dg-warning "the comparison will always evaluate as 'false'" } */
41 if (func
!= 0) /* { dg-warning "the comparison will always evaluate as 'true'" } */
43 if (&var
== 0) /* { dg-warning "the comparison will always evaluate as 'false'" } */
45 if (&var
!= 0) /* { dg-warning "the comparison will always evaluate as 'true'" } */
58 /* Test equality with 0 on the left hand side. */
60 test_func_cmp_lhs_zero (void)
62 if (0 == func
) /* { dg-warning "the comparison will always evaluate as 'false'" } */
64 if (0 != func
) /* { dg-warning "the comparison will always evaluate as 'true'" } */
66 if (0 == &var
) /* { dg-warning "the comparison will always evaluate as 'false'" } */
68 if (0 != &var
) /* { dg-warning "the comparison will always evaluate as 'true'" } */