]> git.ipfire.org Git - thirdparty/gcc.git/blob - libcpp/location-example.txt
PR preprocessor/84517 allow double-underscore macros after string literals
[thirdparty/gcc.git] / libcpp / location-example.txt
1 Consider compiling test.c, with this content:
2 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
3 #include "test.h"
4
5 int
6 main (int argc, char **argv)
7 {
8 int a = PLUS (1,2);
9 int b = PLUS (3,4);
10 return 0;
11 }
12 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13
14 ...where test.h has this content:
15 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
16 extern int foo ();
17
18 #define PLUS(A, B) A + B
19 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20
21
22 The undocumented -fdump-internal-locations option outputs this information
23 to stderr, showing what each source_location value means. Source code
24 lines are quoted, showing both per-line source_location values and
25 per-line&column source_location values (written vertically under the
26 corresponding character of source code).
27
28 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
29 RESERVED LOCATIONS
30 source_location interval: 0 <= loc < 2
31
32 ORDINARY MAP: 0
33 source_location interval: 32 <= loc < 64
34 file: test.c
35 starting at line: 1
36 column bits: 12
37 range bits: 5
38 test.c: 1|loc: 32|#include "test.h"
39 |69269258258148147
40 |46802468024680246
41
42 ORDINARY MAP: 1
43 source_location interval: 64 <= loc < 96
44 file: <built-in>
45 starting at line: 0
46 column bits: 0
47 range bits: 0
48
49 ORDINARY MAP: 2
50 source_location interval: 96 <= loc < 128
51 file: <command-line>
52 starting at line: 0
53 column bits: 0
54 range bits: 0
55
56 ORDINARY MAP: 3
57 source_location interval: 128 <= loc < 160128
58 file: /usr/include/stdc-predef.h
59 starting at line: 1
60 column bits: 12
61 range bits: 5
62 (contents of /usr/include/stdc-predef.h snipped for brevity)
63
64 ORDINARY MAP: 4
65 source_location interval: 160128 <= loc < 160160
66 file: <command-line>
67 starting at line: 32
68 column bits: 12
69 range bits: 5
70
71 ORDINARY MAP: 5
72 source_location interval: 160160 <= loc < 164256
73 file: test.c
74 starting at line: 1
75 column bits: 12
76 range bits: 5
77 test.c: 1|loc:160160|#include "test.h"
78 |00000000000000000
79 |12223334445556667
80 |92582581481470470
81 |24680246802468024
82
83 ORDINARY MAP: 6
84 source_location interval: 164256 <= loc < 173280
85 file: test.h
86 starting at line: 1
87 column bits: 12
88 range bits: 5
89 test.h: 1|loc:164256|extern int foo ();
90 |444444444444444444
91 |233344455566677788
92 |825814814704703603
93 |802468024680246802
94 test.h: 2|loc:168352|
95 |
96 |
97 |
98 |
99 test.h: 3|loc:172448|#define PLUS(A, B) A + B
100 |222222222222222223333333
101 |455566677788889990001112
102 |814704703603692692582581
103 |024680246802468024680246
104
105 ORDINARY MAP: 7
106 source_location interval: 173280 <= loc < 202016
107 file: test.c
108 starting at line: 2
109 column bits: 12
110 range bits: 5
111 test.c: 2|loc:173280|
112 |
113 |
114 |
115 |
116 test.c: 3|loc:177376|int
117 |777
118 |444
119 |047
120 |802
121 test.c: 4|loc:181472|main (int argc, char **argv)
122 |1111111111111111222222222222
123 |5556666777888999000111222333
124 |0360369269258258148147047036
125 |4680246802468024680246802468
126 test.c: 5|loc:185568|{
127 |5
128 |6
129 |0
130 |0
131 test.c: 6|loc:189664| int a = PLUS (1,2);
132 |999999999900000000000
133 |677788899900011122233
134 |926925825814814704703
135 |680246802468024680246
136 test.c: 7|loc:193760| int b = PLUS (3,4);
137 |333333344444444444444
138 |788899900011122233344
139 |925825814814704703603
140 |246802468024680246802
141 test.c: 8|loc:197856| return 0;
142 |77778888888
143 |89990001112
144 |82581481470
145 |80246802468
146 test.c: 9|loc:201952|}
147 |1
148 |9
149 |8
150 |4
151
152 UNALLOCATED LOCATIONS
153 source_location interval: 202016 <= loc < 2147483633
154
155 MACRO 1: PLUS (7 tokens)
156 source_location interval: 2147483633 <= loc < 2147483640
157 test.c:7:11: note: expansion point is location 194115
158 int b = PLUS (3,4);
159 ^~~~
160
161 map->start_location: 2147483633
162 macro_locations:
163 0: 194304, 173088
164 test.c:7:17: note: token 0 has x-location == 194304
165 int b = PLUS (3,4);
166 ^
167
168 test.c:7:17: note: token 0 has y-location == 173088
169 1: 173152, 173152
170 In file included from test.c:1:0:
171 test.h:3:22: note: token 1 has x-location == y-location == 173152
172 #define PLUS(A, B) A + B
173 ^
174
175 2: 194368, 173216
176 test.c:7:19: note: token 2 has x-location == 194368
177 int b = PLUS (3,4);
178 ^
179
180 test.c:7:19: note: token 2 has y-location == 173216
181 3: 0, 2947526575
182 cc1: note: token 3 has x-location == 0
183 cc1: note: token 3 has y-location == 2947526575
184 4: 2947526575, 2947526575
185 x-location == y-location == 2947526575 encodes token # 800042942
186 5: 2947526575, 2947526575
187 x-location == y-location == 2947526575 encodes token # 800042942
188 6: 2947526575, 2947526575
189 x-location == y-location == 2947526575 encodes token # 800042942
190
191 MACRO 0: PLUS (7 tokens)
192 source_location interval: 2147483640 <= loc < 2147483647
193 test.c:6:11: note: expansion point is location 190019
194 int a = PLUS (1,2);
195 ^~~~
196
197 map->start_location: 2147483640
198 macro_locations:
199 0: 190208, 173088
200 test.c:6:17: note: token 0 has x-location == 190208
201 int a = PLUS (1,2);
202 ^
203
204 test.c:6:17: note: token 0 has y-location == 173088
205 1: 173152, 173152
206 In file included from test.c:1:0:
207 test.h:3:22: note: token 1 has x-location == y-location == 173152
208 #define PLUS(A, B) A + B
209 ^
210
211 2: 190272, 173216
212 test.c:6:19: note: token 2 has x-location == 190272
213 int a = PLUS (1,2);
214 ^
215
216 test.c:6:19: note: token 2 has y-location == 173216
217 3: 0, 2947526575
218 cc1: note: token 3 has x-location == 0
219 cc1: note: token 3 has y-location == 2947526575
220 4: 2947526575, 2947526575
221 x-location == y-location == 2947526575 encodes token # 800042935
222 5: 2947526575, 2947526575
223 x-location == y-location == 2947526575 encodes token # 800042935
224 6: 2947526575, 2947526575
225 x-location == y-location == 2947526575 encodes token # 800042935
226
227 MAX_SOURCE_LOCATION
228 source_location interval: 2147483647 <= loc < 2147483648
229
230 AD-HOC LOCATIONS
231 source_location interval: 2147483648 <= loc < 4294967295
232 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^