111
|
1 /* PR c/80116 */
|
|
2 /* { dg-options "-Wmultistatement-macros" } */
|
|
3 /* { dg-do compile } */
|
|
4
|
|
5 #define SWAP(x, y) \
|
|
6 tmp = x; /* { dg-warning "macro expands to multiple statements" } */ \
|
|
7 x = y; \
|
|
8 y = tmp
|
|
9
|
|
10 #define M1 \
|
|
11 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */ \
|
|
12 case 1: \
|
|
13 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
|
|
14
|
|
15 #define M2 \
|
|
16 switch (x) \
|
|
17 case 1: \
|
|
18 x++
|
|
19
|
|
20 #define M3 \
|
|
21 switch (x) \
|
|
22 case 1: \
|
|
23 x++;;
|
|
24
|
|
25 #define M4 \
|
|
26 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */ \
|
|
27 L1: \
|
|
28 case 1: \
|
|
29 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
|
|
30
|
|
31 #define INC \
|
|
32 x++;;
|
|
33
|
|
34 int x, y, tmp;
|
|
35
|
|
36 void
|
|
37 fn0 (void)
|
|
38 {
|
|
39 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */
|
|
40 case 1:
|
|
41 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
|
|
42
|
|
43 switch (x) /* { dg-message "not guarded by this 'switch' clause" } */
|
|
44 case 1:
|
|
45 case 2:
|
|
46 case 3:
|
|
47 case 4:
|
|
48 case 5:
|
|
49 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
|
|
50 }
|
|
51
|
|
52 void
|
|
53 fn1 (void)
|
|
54 {
|
|
55 M1; /* { dg-message "in expansion of macro .M1." } */
|
|
56 M2;
|
|
57 M3;
|
|
58 M4; /* { dg-message "in expansion of macro .M4." } */
|
|
59 goto L1;
|
|
60 }
|
|
61
|
|
62 void
|
|
63 fn2 (void)
|
|
64 {
|
|
65 switch (x)
|
|
66 case 1:
|
|
67 INC
|
|
68
|
|
69 switch (x)
|
|
70 case 1:
|
|
71 ({ x = 10; x++; });
|
|
72 }
|
|
73
|
|
74 void
|
|
75 fn3 (void)
|
|
76 {
|
|
77 switch (x)
|
|
78 {
|
|
79 case 1:
|
|
80 SWAP (x, y);
|
|
81 }
|
|
82 }
|