aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr97932.c
blob: 4a0b3041375d7a7f816d46a006656cff25a0877b (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* Verify that we don't emit ranges that span both
   a macro definition location and a macro expansion location.  */

/* { dg-options "-fdiagnostics-show-caret" } */

/* Various cases involving the ranges of the LHS and RHS operands to "-".  */

/* Case 1
   start token is in macro definition ("&"),
   end token is in macro invocation ("a" and "b").  */   

#define M1(A, B) &A - &B /* { dg-error "invalid operands" } */

/* Intervening
   material
   that
   ought
   not
   to
   be
   printed.  */

int test_1 (float a, int b)
{
  return M1(a, b); /* { dg-message "in expansion of macro 'M1'" } */
}

/* { dg-begin-multiline-output "" }
 #define M1(A, B) &A - &B
                     ^
   { dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
   return M1(a, b);
          ^~
   { dg-end-multiline-output "" } */

/* Case 2:
   start and end tokens are both in macro invocation ("&", and "a"/"b").  */   

#define M2(A, B) A - B /* { dg-error "invalid operands" } */

/* Intervening
   material
   that
   ought
   not
   to
   be
   printed.  */

int test_2 (float a, int b)
{
  return M2(&a, &b); /* { dg-message "in expansion of macro 'M2'" } */
}

/* { dg-begin-multiline-output "" }
 #define M2(A, B) A - B
                    ^
   { dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
   return M2(&a, &b);
          ^~
   { dg-end-multiline-output "" } */

/* Case 3:
   start token is in macro invocation ("&"),
   end token is in macro definition ("a").  */   

#define M3(OP) OP a - OP b /* { dg-error "invalid operands" } */

/* Intervening
   material
   that
   ought
   not
   to
   be
   printed.  */

int test_3 (float a, int b)
{
  return M3(&); /* { dg-message "in expansion of macro 'M3'" } */
}

/* { dg-begin-multiline-output "" }
 #define M3(OP) OP a - OP b
                     ^
   { dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
   return M3(&);
          ^~
   { dg-end-multiline-output "" } */


/* Case 4:
   start and end tokens are both in macro definition ("&a").  */   

#define M4 &a - &b /* { dg-error "invalid operands" } */

/* Intervening
   material
   that
   ought
   not
   to
   be
   printed.  */

int test_4 (float a, int b)
{
  return M4; /* { dg-message "in expansion of macro 'M4'" } */
}

/* { dg-begin-multiline-output "" }
 #define M4 &a - &b
            ~~ ^ ~~
            |    |
            |    int *
            float *
   { dg-end-multiline-output "" } */
/* { dg-begin-multiline-output "" }
   return M4;
          ^~
   { dg-end-multiline-output "" } */