111
|
1 /* Test operation of -Wparentheses. Warnings for ambiguous else. */
|
|
2 /* Origin: Joseph Myers <jsm@polyomino.org.uk> */
|
|
3
|
|
4 /* { dg-do compile } */
|
|
5 /* { dg-options "-Wparentheses" } */
|
|
6
|
|
7 int foo (int);
|
|
8
|
|
9 int a, b, c;
|
|
10
|
|
11 int
|
|
12 bar (void)
|
|
13 {
|
|
14 if (a)
|
|
15 foo (0);
|
|
16 if (b)
|
|
17 foo (1);
|
|
18 else
|
|
19 foo (2);
|
|
20 if (c) /* { dg-warning "ambiguous" "correct warning" } */
|
|
21 if (a)
|
|
22 foo (3);
|
|
23 else
|
|
24 foo (4);
|
|
25 if (a)
|
|
26 if (c)
|
|
27 foo (5);
|
|
28 if (a)
|
|
29 if (b) /* { dg-warning "ambiguous" "correct warning" } */
|
|
30 if (c)
|
|
31 foo (6);
|
|
32 else
|
|
33 foo (7);
|
|
34 if (a) /* { dg-warning "ambiguous" "correct warning" } */
|
|
35 if (b)
|
|
36 if (c)
|
|
37 foo (8);
|
|
38 else
|
|
39 foo (9);
|
|
40 else
|
|
41 foo (10);
|
|
42 if (a)
|
|
43 if (b)
|
|
44 if (c)
|
|
45 foo (11);
|
|
46 else
|
|
47 foo (12);
|
|
48 else
|
|
49 foo (13);
|
|
50 else
|
|
51 foo (14);
|
|
52 if (a) {
|
|
53 if (b)
|
|
54 if (c)
|
|
55 foo (15);
|
|
56 else
|
|
57 foo (16);
|
|
58 else
|
|
59 foo (17);
|
|
60 }
|
|
61 }
|