Debian Codegraph @

gcc/testsuite/c-c++-common/Wmultistatement-macros-9.c

raw
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 while (x) /* { dg-message "not guarded by this 'while' claus" } */ \
12 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
13
14 #define M2 \
15 while (x) \
16 x++
17
18 #define M3 \
19 while (x) \
20 x++;;
21
22 #define M4 \
23 while (x) /* { dg-message "not guarded by this 'while' claus" } */ \
24 L1: \
25 SWAP (x, y) /* { dg-message "in expansion of macro .SWAP." } */
26
27 #define INC \
28 x++;;
29
30 int x, y, tmp;
31
32 void
33 fn0 (void)
34 {
35 while (x) /* { dg-message "not guarded by this 'while' claus" } */
36 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
37
38 while (x) /* { dg-message "not guarded by this 'while' claus" } */
39 L:
40 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
41 goto L;
42 }
43
44 void
45 fn1 (void)
46 {
47 M1; /* { dg-message "in expansion of macro .M1." } */
48 M2;
49 M3;
50 M4; /* { dg-message "in expansion of macro .M4." } */
51 goto L1;
52 }
53
54 void
55 fn2 (void)
56 {
57 while (x)
58 INC
59
60 while (x)
61 ({ x = 10; x++; });
62 }