| 1 |
/* { dg-do preprocess } */ |
| 2 |
/* { dg-additional-options "-fdiagnostics-show-caret -Wunused-macros -Wbuiltin-macro-redefined" } */ |
| 3 |
|
| 4 |
/* Verify that we output range information for diagnostics involving |
| 5 |
macro definitions. */ |
| 6 |
|
| 7 |
#undef __TIME__ /* { dg-warning {undefining '__TIME__'} } */ |
| 8 |
/* { dg-begin-multiline-output "" } |
| 9 |
#undef __TIME__ |
| 10 |
^~~~~~~~ |
| 11 |
/* { dg-end-multiline-output "" } */ |
| 12 |
|
| 13 |
#define XYZ 123 /* { dg-warning {macro 'XYZ' is not used} } */ |
| 14 |
/* { dg-begin-multiline-output "" } |
| 15 |
#define XYZ 123 |
| 16 |
^~~ |
| 17 |
/* { dg-end-multiline-output "" } */ |
| 18 |
|
| 19 |
#define MACRO initial_definition /* { dg-line def_line } */ |
| 20 |
|
| 21 |
/* This locus is output first for the unused warning... */ |
| 22 |
/* { dg-warning {macro 'MACRO' is not used} "" { target *-*-* } def_line } */ |
| 23 |
/* { dg-begin-multiline-output "" } |
| 24 |
#define MACRO initial_definition |
| 25 |
^~~~~ |
| 26 |
/* { dg-end-multiline-output "" } */ |
| 27 |
|
| 28 |
/* ...then a second time for the redefinition warning. */ |
| 29 |
/* { dg-note {this is the location of the previous definition} "" { target *-*-* } def_line } */ |
| 30 |
/* { dg-begin-multiline-output "" } |
| 31 |
#define MACRO initial_definition |
| 32 |
^~~~~ |
| 33 |
/* { dg-end-multiline-output "" } */ |
| 34 |
|
| 35 |
#define MACRO /* { dg-warning {'MACRO' redefined} } */ |
| 36 |
/* { dg-begin-multiline-output "" } |
| 37 |
#define MACRO |
| 38 |
^~~~~ |
| 39 |
{ dg-end-multiline-output "" } */ |
| 40 |
|
| 41 |
#define MACRO2(x,y) x /* { dg-note {macro 'MACRO2' defined here} } */ |
| 42 |
/* { dg-begin-multiline-output "" } |
| 43 |
#define MACRO2(x,y) |
| 44 |
^~~~~~ |
| 45 |
{ dg-end-multiline-output "" } */ |
| 46 |
|
| 47 |
MACRO2(MACRO, MACRO) |
| 48 |
MACRO2(MACRO) /* { dg-error {macro 'MACRO2' requires 2 arguments, but only 1 given} } */ |
| 49 |
/* { dg-begin-multiline-output "" } |
| 50 |
MACRO2(MACRO) |
| 51 |
^ |
| 52 |
{ dg-end-multiline-output "" } */ |