2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / Walways-true-2.c
blob7f0bb7b10b9bf3ec11893e6b044f0513c1c555b7
1 /* Make sure we don't assume that a weak symbol is always non-NULL.
2 This is just like Walways-true-1.C, except that it uses a weak
3 symbol.
4 Origin: Ian Lance Taylor <iant@google.com>. */
6 /* { dg-do compile } */
7 /* { dg-options "-Waddress" } */
8 /* { dg-require-weak "" } */
10 extern int foo (int) __attribute__ ((weak));
12 int i __attribute__ ((weak));
14 void
15 bar (int a)
17 lab:
18 if (foo)
19 foo (0);
20 if (foo (1))
22 if (&i)
23 foo (2);
24 if (i)
25 foo (3);
26 if (&a) /* { dg-warning "always evaluate as" "correct warning" } */
27 foo (4);
28 if (a)
29 foo (5);
30 if (&&lab) /* { dg-warning "always evaluate as" "correct warning" } */
31 foo (6);
32 if (foo == 0)
33 foo (7);
34 if (foo (1) == 0)
35 foo (8);
36 if (&i == 0)
37 foo (9);
38 if (i == 0)
39 foo (10);
40 if (&a == 0) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */
41 foo (11);
42 if (a == 0)
43 foo (12);
44 if (&&lab == 0) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */
45 foo (13);
46 if (0 == foo)
47 foo (14);
48 if (0 == foo (1))
49 foo (15);
50 if (0 == &i)
51 foo (16);
52 if (0 == i)
53 foo (17);
54 if (0 == &a) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */
55 foo (18);
56 if (0 == a)
57 foo (19);
58 if (0 == &&lab) /* { dg-warning "the comparison will always evaluate as 'false'" "correct warning" } */
59 foo (20);