PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / c-c++-common / Wmultistatement-macros-1.c
blobcdecbb4aca422f20849e9b4832645226e21d69f0
1 /* PR c/80116 */
2 /* { dg-options "-Wmultistatement-macros" } */
3 /* { dg-do compile } */
5 #define SWAP(X, Y) \
6 tmp = X; /* { dg-warning "macro expands to multiple statements" } */ \
7 X = Y; \
8 Y = tmp
10 #define STUFF \
11 if (0) x = y
13 #define STUFF2 \
14 if (0) x = y; x++
16 #define STUFF3 \
17 if (x) /* { dg-message "not guarded by this 'if' clause" } */ \
18 SWAP(x, y) /* { dg-message "in expansion of macro .SWAP." } */
20 #define SET(X, Y) \
21 (X) = (Y)
23 #define STUFF4 \
24 if (x) \
25 SET(x, y); \
26 SET(x, y)
28 #define STUFF5 \
29 { tmp = x; x = y; }
31 #define STUFF6 \
32 x++;;
34 int x, y, tmp;
36 void
37 fn1 (void)
39 if (x) /* { dg-message "not guarded by this 'if' clause" } */
40 SWAP(x, y); /* { dg-message "in expansion of macro .SWAP." } */
43 void
44 fn2 (void)
46 SWAP(x, y);
49 void
50 fn3 (void)
52 if (x)
54 SWAP(x, y);
58 void
59 fn4 (void)
61 if (x)
62 ({ x = 10; x++; });
65 void
66 fn5 (void)
68 if (x) /* { dg-message "not guarded by this 'if' clause" } */
69 L1:
70 SWAP (x, y); /* { dg-message "in expansion of macro .SWAP." } */
71 goto L1;
74 void
75 fn6 (void)
77 if (x)
78 SET (x, y);
79 SET (tmp, x);
82 void
83 fn7 (void)
85 STUFF;
88 void
89 fn8 (void)
91 STUFF2;
94 void
95 fn9 (void)
97 STUFF3; /* { dg-message "in expansion of macro .STUFF3." } */
100 void
101 fn10 (void)
103 STUFF4;
106 void
107 fn11 (void)
109 if (x)
110 STUFF5;
113 void
114 fn12 (void)
116 if (x)
117 STUFF6;