| 1 |
/* This is like diagnostic-pragma-2.c, but handles the case where everything |
| 2 |
is wrapped inside a macro, which previously caused additional issues tracked |
| 3 |
in PR preprocessor/82335. */ |
| 4 |
|
| 5 |
/* { dg-do compile } */ |
| 6 |
/* { dg-additional-options "-save-temps -Wattributes -Wtype-limits" } */ |
| 7 |
|
| 8 |
#define B _Pragma("GCC diagnostic push") \ |
| 9 |
_Pragma("GCC diagnostic ignored \"-Wattributes\"") |
| 10 |
#define E _Pragma("GCC diagnostic pop") |
| 11 |
|
| 12 |
#define X() B int __attribute((unknown_attr)) x; E |
| 13 |
#define Y B int __attribute((unknown_attr)) y; E |
| 14 |
#define WRAP(x) x |
| 15 |
|
| 16 |
void test1(void) |
| 17 |
{ |
| 18 |
WRAP(X()) |
| 19 |
WRAP(Y) |
| 20 |
} |
| 21 |
|
| 22 |
/* Additional test provided on the PR. */ |
| 23 |
#define PRAGMA(...) _Pragma(#__VA_ARGS__) |
| 24 |
#define PUSH_IGN(X) PRAGMA(GCC diagnostic push) PRAGMA(GCC diagnostic ignored X) |
| 25 |
#define POP() PRAGMA(GCC diagnostic pop) |
| 26 |
#define TEST(X, Y) \ |
| 27 |
PUSH_IGN("-Wtype-limits") \ |
| 28 |
int Y = (__typeof(X))-1 < 0; \ |
| 29 |
POP() |
| 30 |
|
| 31 |
int test2() |
| 32 |
{ |
| 33 |
unsigned x; |
| 34 |
TEST(x, i1); |
| 35 |
WRAP(TEST(x, i2)) |
| 36 |
return i1 + i2; |
| 37 |
} |