aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/cpp/macro-ranges.c
blob: 72a122ba4de13c688285e8feb7e8b7d2b33bc8d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* { dg-do preprocess } */
/* { dg-additional-options "-fdiagnostics-show-caret -Wunused-macros -Wbuiltin-macro-redefined" } */

/* Verify that we output range information for diagnostics involving
   macro definitions.  */

#undef __TIME__ /* { dg-warning {undefining '__TIME__'} } */
/* { dg-begin-multiline-output "" }
 #undef __TIME__
        ^~~~~~~~
/* { dg-end-multiline-output "" } */

#define XYZ 123 /* { dg-warning {macro 'XYZ' is not used} } */
/* { dg-begin-multiline-output "" }
 #define XYZ 123
         ^~~
/* { dg-end-multiline-output "" } */

#define MACRO initial_definition /* { dg-line def_line } */

/* This locus is output first for the unused warning... */
/* { dg-warning {macro 'MACRO' is not used} "" { target *-*-* } def_line } */
/* { dg-begin-multiline-output "" }
 #define MACRO initial_definition
         ^~~~~
/* { dg-end-multiline-output "" } */

/* ...then a second time for the redefinition warning.  */
/* { dg-note {this is the location of the previous definition} "" { target *-*-* } def_line } */
/* { dg-begin-multiline-output "" }
 #define MACRO initial_definition
         ^~~~~
/* { dg-end-multiline-output "" } */

#define MACRO /* { dg-warning {'MACRO' redefined} } */
/* { dg-begin-multiline-output "" }
 #define MACRO
         ^~~~~
{ dg-end-multiline-output "" } */

#define MACRO2(x,y) x /* { dg-note {macro 'MACRO2' defined here} } */
/* { dg-begin-multiline-output "" }
 #define MACRO2(x,y)
         ^~~~~~
{ dg-end-multiline-output "" } */

MACRO2(MACRO, MACRO)
MACRO2(MACRO) /* { dg-error {macro 'MACRO2' requires 2 arguments, but only 1 given} } */
/* { dg-begin-multiline-output "" }
 MACRO2(MACRO)
             ^
{ dg-end-multiline-output "" } */