]>
Commit | Line | Data |
---|---|---|
8d08fdba MS |
1 | /* Call-backs for C++ error reporting. |
2 | This code is non-reentrant. | |
b34c06e3 | 3 | Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002 |
158991b7 | 4 | Free Software Foundation, Inc. |
f5adbb8d | 5 | This file is part of GCC. |
8d08fdba | 6 | |
f5adbb8d | 7 | GCC is free software; you can redistribute it and/or modify |
8d08fdba MS |
8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
f5adbb8d | 12 | GCC is distributed in the hope that it will be useful, |
8d08fdba MS |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
f5adbb8d | 18 | along with GCC; see the file COPYING. If not, write to |
e9fa0c7c RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
21 | |
22 | #include "config.h" | |
8d052bc7 | 23 | #include "system.h" |
4977bab6 ZW |
24 | #include "coretypes.h" |
25 | #include "tm.h" | |
8d08fdba MS |
26 | #include "tree.h" |
27 | #include "cp-tree.h" | |
a1bda5f1 | 28 | #include "real.h" |
54f92bfb | 29 | #include "toplev.h" |
749ced52 | 30 | #include "flags.h" |
cb753e49 | 31 | #include "diagnostic.h" |
7cb32822 | 32 | #include "langhooks-def.h" |
8d08fdba | 33 | |
a1066c99 GDR |
34 | enum pad { none, before, after }; |
35 | ||
c3e76028 GDR |
36 | #define sorry_for_unsupported_tree(T) \ |
37 | sorry ("`%s' not supported by %s", tree_code_name[(int) TREE_CODE (T)], \ | |
38 | __FUNCTION__) | |
39 | ||
b34c06e3 GS |
40 | #define print_scope_operator(BUFFER) output_add_string ((BUFFER), "::") |
41 | #define print_left_paren(BUFFER) output_add_character ((BUFFER), '(') | |
42 | #define print_right_paren(BUFFER) output_add_character ((BUFFER), ')') | |
43 | #define print_left_bracket(BUFFER) output_add_character ((BUFFER), '[') | |
44 | #define print_right_bracket(BUFFER) output_add_character ((BUFFER), ']') | |
99885b3f | 45 | #define print_template_argument_list_start(BUFFER) \ |
b34c06e3 | 46 | print_non_consecutive_character ((BUFFER), '<') |
99885b3f | 47 | #define print_template_argument_list_end(BUFFER) \ |
b34c06e3 | 48 | print_non_consecutive_character ((BUFFER), '>') |
a1066c99 | 49 | #define print_tree_identifier(BUFFER, TID) \ |
b34c06e3 GS |
50 | output_add_string ((BUFFER), IDENTIFIER_POINTER (TID)) |
51 | #define print_identifier(BUFFER, ID) output_add_string ((BUFFER), (ID)) | |
52 | #define separate_with_comma(BUFFER) output_add_string ((BUFFER), ", ") | |
a1066c99 | 53 | |
99885b3f GDR |
54 | /* The global buffer where we dump everything. It is there only for |
55 | transitional purpose. It is expected, in the near future, to be | |
56 | completely removed. */ | |
57 | static output_buffer scratch_buffer_rec; | |
58 | static output_buffer *scratch_buffer = &scratch_buffer_rec; | |
0aafb128 | 59 | |
b34c06e3 | 60 | # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T))) |
8d08fdba | 61 | |
99885b3f GDR |
62 | #define reinit_global_formatting_buffer() \ |
63 | output_clear_message_text (scratch_buffer) | |
64 | ||
158991b7 KG |
65 | static const char *args_to_string PARAMS ((tree, int)); |
66 | static const char *assop_to_string PARAMS ((enum tree_code, int)); | |
67 | static const char *code_to_string PARAMS ((enum tree_code, int)); | |
68 | static const char *cv_to_string PARAMS ((tree, int)); | |
69 | static const char *decl_to_string PARAMS ((tree, int)); | |
70 | static const char *expr_to_string PARAMS ((tree, int)); | |
71 | static const char *fndecl_to_string PARAMS ((tree, int)); | |
158991b7 KG |
72 | static const char *op_to_string PARAMS ((enum tree_code, int)); |
73 | static const char *parm_to_string PARAMS ((int, int)); | |
74 | static const char *type_to_string PARAMS ((tree, int)); | |
9e93bc9d | 75 | |
761f0855 GDR |
76 | static void dump_type PARAMS ((tree, int)); |
77 | static void dump_typename PARAMS ((tree, int)); | |
78 | static void dump_simple_decl PARAMS ((tree, tree, int)); | |
79 | static void dump_decl PARAMS ((tree, int)); | |
80 | static void dump_template_decl PARAMS ((tree, int)); | |
81 | static void dump_function_decl PARAMS ((tree, int)); | |
82 | static void dump_expr PARAMS ((tree, int)); | |
83 | static void dump_unary_op PARAMS ((const char *, tree, int)); | |
84 | static void dump_binary_op PARAMS ((const char *, tree, int)); | |
85 | static void dump_aggr_type PARAMS ((tree, int)); | |
86 | static enum pad dump_type_prefix PARAMS ((tree, int)); | |
87 | static void dump_type_suffix PARAMS ((tree, int)); | |
88 | static void dump_function_name PARAMS ((tree, int)); | |
89 | static void dump_expr_list PARAMS ((tree, int)); | |
158991b7 KG |
90 | static void dump_global_iord PARAMS ((tree)); |
91 | static enum pad dump_qualifiers PARAMS ((tree, enum pad)); | |
92 | static void dump_char PARAMS ((int)); | |
761f0855 GDR |
93 | static void dump_parameters PARAMS ((tree, int)); |
94 | static void dump_exception_spec PARAMS ((tree, int)); | |
c3e76028 | 95 | static const char *class_key_or_enum PARAMS ((tree)); |
761f0855 GDR |
96 | static void dump_template_argument PARAMS ((tree, int)); |
97 | static void dump_template_argument_list PARAMS ((tree, int)); | |
98 | static void dump_template_parameter PARAMS ((tree, int)); | |
158991b7 | 99 | static void dump_template_bindings PARAMS ((tree, tree)); |
761f0855 GDR |
100 | static void dump_scope PARAMS ((tree, int)); |
101 | static void dump_template_parms PARAMS ((tree, int, int)); | |
9e93bc9d | 102 | |
cb753e49 | 103 | static const char *function_category PARAMS ((tree)); |
47b69537 GDR |
104 | static void maybe_print_instantiation_context PARAMS ((diagnostic_context *)); |
105 | static void print_instantiation_full_context PARAMS ((diagnostic_context *)); | |
106 | static void print_instantiation_partial_context PARAMS ((diagnostic_context *, | |
107 | tree, | |
cb753e49 | 108 | const char *, int)); |
47b69537 GDR |
109 | static void cp_diagnostic_starter PARAMS ((diagnostic_context *, |
110 | diagnostic_info *)); | |
111 | static void cp_diagnostic_finalizer PARAMS ((diagnostic_context *, | |
112 | diagnostic_info *)); | |
113 | static void cp_print_error_function PARAMS ((diagnostic_context *, | |
114 | diagnostic_info *)); | |
115 | ||
116 | static bool cp_printer PARAMS ((output_buffer *, text_info *)); | |
99885b3f | 117 | static void print_non_consecutive_character PARAMS ((output_buffer *, int)); |
749ced52 ZW |
118 | static void print_integer PARAMS ((output_buffer *, HOST_WIDE_INT)); |
119 | static tree locate_error PARAMS ((const char *, va_list)); | |
8d08fdba MS |
120 | |
121 | void | |
122 | init_error () | |
123 | { | |
f68fc4db GDR |
124 | diagnostic_starter (global_dc) = cp_diagnostic_starter; |
125 | diagnostic_finalizer (global_dc) = cp_diagnostic_finalizer; | |
749ced52 ZW |
126 | diagnostic_format_decoder (global_dc) = cp_printer; |
127 | ||
f68fc4db | 128 | init_output_buffer (scratch_buffer, /* prefix */NULL, /* line-width */0); |
8d08fdba MS |
129 | } |
130 | ||
9e93bc9d | 131 | /* Dump a scope, if deemed necessary. */ |
bbcec105 | 132 | |
9e93bc9d NS |
133 | static void |
134 | dump_scope (scope, flags) | |
bbcec105 | 135 | tree scope; |
761f0855 | 136 | int flags; |
bbcec105 | 137 | { |
55ace93c | 138 | int f = ~TFF_RETURN_TYPE & (flags & (TFF_SCOPE | TFF_CHASE_TYPEDEF)); |
761f0855 | 139 | |
9e93bc9d NS |
140 | if (scope == NULL_TREE) |
141 | return; | |
bb20cc46 | 142 | |
9e93bc9d NS |
143 | if (TREE_CODE (scope) == NAMESPACE_DECL) |
144 | { | |
145 | if (scope != global_namespace) | |
146 | { | |
761f0855 | 147 | dump_decl (scope, f); |
99885b3f | 148 | print_scope_operator (scratch_buffer); |
9e93bc9d | 149 | } |
9e93bc9d NS |
150 | } |
151 | else if (AGGREGATE_TYPE_P (scope)) | |
152 | { | |
761f0855 | 153 | dump_type (scope, f); |
99885b3f | 154 | print_scope_operator (scratch_buffer); |
9e93bc9d | 155 | } |
761f0855 | 156 | else if ((flags & TFF_SCOPE) && TREE_CODE (scope) == FUNCTION_DECL) |
9e93bc9d | 157 | { |
761f0855 | 158 | dump_function_decl (scope, f); |
99885b3f | 159 | print_scope_operator (scratch_buffer); |
9e93bc9d | 160 | } |
bbcec105 JM |
161 | } |
162 | ||
9e93bc9d NS |
163 | /* Dump type qualifiers, providing padding as requested. Return an |
164 | indication of whether we dumped something. */ | |
165 | ||
166 | static enum pad | |
91063b51 | 167 | dump_qualifiers (t, p) |
8d08fdba MS |
168 | tree t; |
169 | enum pad p; | |
170 | { | |
9e93bc9d NS |
171 | static const int masks[] = |
172 | {TYPE_QUAL_CONST, TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT}; | |
173 | static const char *const names[] = | |
174 | {"const", "volatile", "__restrict"}; | |
175 | int ix; | |
176 | int quals = TYPE_QUALS (t); | |
177 | int do_after = p == after; | |
bb20cc46 | 178 | |
9e93bc9d | 179 | if (quals) |
8d08fdba | 180 | { |
9e93bc9d NS |
181 | for (ix = 0; ix != 3; ix++) |
182 | if (masks[ix] & quals) | |
183 | { | |
184 | if (p == before) | |
99885b3f | 185 | output_add_space (scratch_buffer); |
9e93bc9d | 186 | p = before; |
99885b3f | 187 | print_identifier (scratch_buffer, names[ix]); |
9e93bc9d NS |
188 | } |
189 | if (do_after) | |
99885b3f | 190 | output_add_space (scratch_buffer); |
8d08fdba | 191 | } |
9e93bc9d NS |
192 | else |
193 | p = none; | |
194 | return p; | |
8d08fdba MS |
195 | } |
196 | ||
197 | /* This must be large enough to hold any printed integer or floating-point | |
198 | value. */ | |
199 | static char digit_buffer[128]; | |
200 | ||
612c671a | 201 | /* Dump the template ARGument under control of FLAGS. */ |
5f77d6cc GDR |
202 | |
203 | static void | |
612c671a GDR |
204 | dump_template_argument (arg, flags) |
205 | tree arg; | |
761f0855 | 206 | int flags; |
5f77d6cc | 207 | { |
2f939d94 | 208 | if (TYPE_P (arg) || TREE_CODE (arg) == TEMPLATE_DECL) |
761f0855 | 209 | dump_type (arg, flags & ~TFF_CLASS_KEY_OR_ENUM); |
5f77d6cc | 210 | else |
761f0855 | 211 | dump_expr (arg, (flags | TFF_EXPR_IN_PARENS) & ~TFF_CLASS_KEY_OR_ENUM); |
5f77d6cc GDR |
212 | } |
213 | ||
612c671a GDR |
214 | /* Dump a template-argument-list ARGS (always a TREE_VEC) under control |
215 | of FLAGS. */ | |
216 | ||
217 | static void | |
218 | dump_template_argument_list (args, flags) | |
219 | tree args; | |
761f0855 | 220 | int flags; |
612c671a GDR |
221 | { |
222 | int n = TREE_VEC_LENGTH (args); | |
223 | int need_comma = 0; | |
224 | int i; | |
225 | ||
226 | for (i = 0; i< n; ++i) | |
227 | { | |
228 | if (need_comma) | |
99885b3f | 229 | separate_with_comma (scratch_buffer); |
612c671a GDR |
230 | dump_template_argument (TREE_VEC_ELT (args, i), flags); |
231 | need_comma = 1; | |
232 | } | |
233 | } | |
234 | ||
235 | /* Dump a template parameter PARM (a TREE_LIST) under control of FLAGS. */ | |
236 | ||
237 | static void | |
238 | dump_template_parameter (parm, flags) | |
239 | tree parm; | |
761f0855 | 240 | int flags; |
612c671a GDR |
241 | { |
242 | tree p = TREE_VALUE (parm); | |
243 | tree a = TREE_PURPOSE (parm); | |
244 | ||
245 | if (TREE_CODE (p) == TYPE_DECL) | |
246 | { | |
761f0855 | 247 | if (flags & TFF_DECL_SPECIFIERS) |
612c671a | 248 | { |
99885b3f | 249 | print_identifier (scratch_buffer, "class"); |
612c671a GDR |
250 | if (DECL_NAME (p)) |
251 | { | |
99885b3f GDR |
252 | output_add_space (scratch_buffer); |
253 | print_tree_identifier (scratch_buffer, DECL_NAME (p)); | |
612c671a GDR |
254 | } |
255 | } | |
256 | else if (DECL_NAME (p)) | |
99885b3f | 257 | print_tree_identifier (scratch_buffer, DECL_NAME (p)); |
612c671a | 258 | else |
99885b3f | 259 | print_identifier (scratch_buffer, "{template default argument error}"); |
612c671a GDR |
260 | } |
261 | else | |
761f0855 | 262 | dump_decl (p, flags | TFF_DECL_SPECIFIERS); |
612c671a | 263 | |
761f0855 | 264 | if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && a != NULL_TREE) |
612c671a | 265 | { |
99885b3f | 266 | output_add_string (scratch_buffer, " = "); |
31bb3027 | 267 | if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL) |
761f0855 | 268 | dump_type (a, flags & ~TFF_CHASE_TYPEDEF); |
612c671a | 269 | else |
761f0855 | 270 | dump_expr (a, flags | TFF_EXPR_IN_PARENS); |
612c671a GDR |
271 | } |
272 | } | |
273 | ||
274 | /* Dump, under control of FLAGS, a template-parameter-list binding. | |
275 | PARMS is a TREE_LIST of TREE_VEC of TREE_LIST and ARGS is a | |
276 | TREE_VEC. */ | |
277 | ||
278 | static void | |
b5ac18ea | 279 | dump_template_bindings (parms, args) |
612c671a | 280 | tree parms, args; |
612c671a | 281 | { |
612c671a GDR |
282 | int need_comma = 0; |
283 | ||
284 | while (parms) | |
285 | { | |
286 | tree p = TREE_VALUE (parms); | |
b5ac18ea MM |
287 | int lvl = TMPL_PARMS_DEPTH (parms); |
288 | int arg_idx = 0; | |
612c671a GDR |
289 | int i; |
290 | ||
291 | for (i = 0; i < TREE_VEC_LENGTH (p); ++i) | |
b5ac18ea | 292 | { |
2bb5d995 JM |
293 | tree arg = NULL_TREE; |
294 | ||
295 | /* Don't crash if we had an invalid argument list. */ | |
296 | if (TMPL_ARGS_DEPTH (args) >= lvl) | |
297 | { | |
298 | tree lvl_args = TMPL_ARGS_LEVEL (args, lvl); | |
299 | if (NUM_TMPL_ARGS (lvl_args) > arg_idx) | |
300 | arg = TREE_VEC_ELT (lvl_args, arg_idx); | |
301 | } | |
b5ac18ea MM |
302 | |
303 | if (need_comma) | |
99885b3f | 304 | separate_with_comma (scratch_buffer); |
761f0855 | 305 | dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER); |
99885b3f | 306 | output_add_string (scratch_buffer, " = "); |
b5ac18ea | 307 | if (arg) |
761f0855 | 308 | dump_template_argument (arg, TFF_PLAIN_IDENTIFIER); |
b5ac18ea | 309 | else |
99885b3f | 310 | print_identifier (scratch_buffer, "<missing>"); |
bb20cc46 | 311 | |
b5ac18ea MM |
312 | ++arg_idx; |
313 | need_comma = 1; | |
314 | } | |
612c671a GDR |
315 | |
316 | parms = TREE_CHAIN (parms); | |
317 | } | |
318 | } | |
319 | ||
b3426eb9 GK |
320 | /* Dump a human-readable equivalent of TYPE. FLAGS controls the |
321 | format. */ | |
e92cc029 | 322 | |
8d08fdba | 323 | static void |
9e93bc9d | 324 | dump_type (t, flags) |
8d08fdba | 325 | tree t; |
761f0855 | 326 | int flags; |
8d08fdba MS |
327 | { |
328 | if (t == NULL_TREE) | |
329 | return; | |
bb20cc46 | 330 | |
8d08fdba MS |
331 | if (TYPE_PTRMEMFUNC_P (t)) |
332 | goto offset_type; | |
333 | ||
334 | switch (TREE_CODE (t)) | |
335 | { | |
8d08fdba | 336 | case UNKNOWN_TYPE: |
99885b3f | 337 | print_identifier (scratch_buffer, "<unknown type>"); |
8d08fdba MS |
338 | break; |
339 | ||
dcd08efc JM |
340 | case TREE_LIST: |
341 | /* A list of function parms. */ | |
9e93bc9d | 342 | dump_parameters (t, flags); |
dcd08efc JM |
343 | break; |
344 | ||
8d08fdba | 345 | case IDENTIFIER_NODE: |
99885b3f | 346 | print_tree_identifier (scratch_buffer, t); |
8d08fdba MS |
347 | break; |
348 | ||
349 | case TREE_VEC: | |
9e93bc9d | 350 | dump_type (BINFO_TYPE (t), flags); |
8d08fdba MS |
351 | break; |
352 | ||
353 | case RECORD_TYPE: | |
354 | case UNION_TYPE: | |
355 | case ENUMERAL_TYPE: | |
9e93bc9d | 356 | dump_aggr_type (t, flags); |
8d08fdba MS |
357 | break; |
358 | ||
359 | case TYPE_DECL: | |
761f0855 | 360 | if (flags & TFF_CHASE_TYPEDEF) |
9e93bc9d NS |
361 | { |
362 | dump_type (DECL_ORIGINAL_TYPE (t) | |
363 | ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags); | |
364 | break; | |
365 | } | |
366 | /* else fallthrough */ | |
bb20cc46 | 367 | |
67c2a928 | 368 | case TEMPLATE_DECL: |
009425e1 | 369 | case NAMESPACE_DECL: |
761f0855 | 370 | dump_decl (t, flags & ~TFF_DECL_SPECIFIERS); |
8d08fdba | 371 | break; |
bb20cc46 | 372 | |
37c46b43 | 373 | case COMPLEX_TYPE: |
99885b3f | 374 | output_add_string (scratch_buffer, "__complex__ "); |
9e93bc9d | 375 | dump_type (TREE_TYPE (t), flags); |
37c46b43 MS |
376 | break; |
377 | ||
c00996a3 | 378 | case VECTOR_TYPE: |
39abc9a6 | 379 | output_add_string (scratch_buffer, "vector "); |
d8a6f584 JM |
380 | { |
381 | /* The subtype of a VECTOR_TYPE is something like intQI_type_node, | |
382 | which has no name and is not very useful for diagnostics. So | |
383 | look up the equivalent C type and print its name. */ | |
384 | tree elt = TREE_TYPE (t); | |
b0c48229 | 385 | elt = c_common_type_for_mode (TYPE_MODE (elt), TREE_UNSIGNED (elt)); |
d8a6f584 JM |
386 | dump_type (elt, flags); |
387 | } | |
c00996a3 JM |
388 | break; |
389 | ||
8d08fdba MS |
390 | case INTEGER_TYPE: |
391 | if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t)) | |
99885b3f | 392 | output_add_string (scratch_buffer, "unsigned "); |
8d08fdba | 393 | else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t)) |
99885b3f | 394 | output_add_string (scratch_buffer, "signed "); |
8d08fdba MS |
395 | |
396 | /* fall through. */ | |
397 | case REAL_TYPE: | |
398 | case VOID_TYPE: | |
2986ae00 | 399 | case BOOLEAN_TYPE: |
3df095e2 MM |
400 | { |
401 | tree type; | |
91063b51 | 402 | dump_qualifiers (t, after); |
761f0855 | 403 | type = flags & TFF_CHASE_TYPEDEF ? TYPE_MAIN_VARIANT (t) : t; |
3df095e2 | 404 | if (TYPE_NAME (type) && TYPE_IDENTIFIER (type)) |
99885b3f | 405 | print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (type)); |
3df095e2 MM |
406 | else |
407 | /* Types like intQI_type_node and friends have no names. | |
408 | These don't come up in user error messages, but it's nice | |
409 | to be able to print them from the debugger. */ | |
99885b3f | 410 | print_identifier (scratch_buffer, "<anonymous>"); |
3df095e2 | 411 | } |
8d08fdba MS |
412 | break; |
413 | ||
73b0fce8 | 414 | case TEMPLATE_TEMPLATE_PARM: |
c6002625 | 415 | /* For parameters inside template signature. */ |
a1281f45 | 416 | if (TYPE_IDENTIFIER (t)) |
99885b3f | 417 | print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t)); |
73b0fce8 | 418 | else |
99885b3f GDR |
419 | print_identifier |
420 | (scratch_buffer, "<anonymous template template parameter>"); | |
a1281f45 KL |
421 | break; |
422 | ||
423 | case BOUND_TEMPLATE_TEMPLATE_PARM: | |
424 | { | |
425 | tree args = TYPE_TI_ARGS (t); | |
99885b3f GDR |
426 | print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t)); |
427 | print_template_argument_list_start (scratch_buffer); | |
a1281f45 | 428 | dump_template_argument_list (args, flags); |
99885b3f | 429 | print_template_argument_list_end (scratch_buffer); |
a1281f45 | 430 | } |
73b0fce8 KL |
431 | break; |
432 | ||
8d08fdba | 433 | case TEMPLATE_TYPE_PARM: |
91063b51 | 434 | dump_qualifiers (t, after); |
ec255269 | 435 | if (TYPE_IDENTIFIER (t)) |
99885b3f | 436 | print_tree_identifier (scratch_buffer, TYPE_IDENTIFIER (t)); |
ec255269 | 437 | else |
99885b3f GDR |
438 | print_identifier |
439 | (scratch_buffer, "<anonymous template type parameter>"); | |
8d08fdba MS |
440 | break; |
441 | ||
8d08fdba MS |
442 | /* This is not always necessary for pointers and such, but doing this |
443 | reduces code size. */ | |
444 | case ARRAY_TYPE: | |
445 | case POINTER_TYPE: | |
446 | case REFERENCE_TYPE: | |
447 | case OFFSET_TYPE: | |
448 | offset_type: | |
449 | case FUNCTION_TYPE: | |
450 | case METHOD_TYPE: | |
9e93bc9d NS |
451 | { |
452 | dump_type_prefix (t, flags); | |
453 | dump_type_suffix (t, flags); | |
8d08fdba | 454 | break; |
9e93bc9d | 455 | } |
5566b478 | 456 | case TYPENAME_TYPE: |
ea9264e9 GDR |
457 | if (!IMPLICIT_TYPENAME_P (t)) |
458 | output_add_string (scratch_buffer, "typename "); | |
46e2747c | 459 | dump_typename (t, flags); |
5566b478 MS |
460 | break; |
461 | ||
b8c6534b KL |
462 | case UNBOUND_CLASS_TEMPLATE: |
463 | dump_type (TYPE_CONTEXT (t), flags); | |
464 | print_scope_operator (scratch_buffer); | |
465 | print_identifier (scratch_buffer, "template "); | |
466 | dump_type (DECL_NAME (TYPE_NAME (t)), flags); | |
467 | break; | |
468 | ||
b894fc05 | 469 | case TYPEOF_TYPE: |
99885b3f | 470 | output_add_string (scratch_buffer, "__typeof ("); |
761f0855 | 471 | dump_expr (TYPE_FIELDS (t), flags & ~TFF_EXPR_IN_PARENS); |
4e664ef1 | 472 | print_right_paren (scratch_buffer); |
b894fc05 JM |
473 | break; |
474 | ||
8d08fdba | 475 | default: |
99885b3f | 476 | sorry_for_unsupported_tree (t); |
c6002625 | 477 | /* Fall through to error. */ |
9e93bc9d NS |
478 | |
479 | case ERROR_MARK: | |
99885b3f | 480 | print_identifier (scratch_buffer, "<type error>"); |
9e93bc9d | 481 | break; |
8d08fdba MS |
482 | } |
483 | } | |
484 | ||
46e2747c NS |
485 | /* Dump a TYPENAME_TYPE. We need to notice when the context is itself |
486 | a TYPENAME_TYPE. */ | |
487 | ||
488 | static void | |
489 | dump_typename (t, flags) | |
490 | tree t; | |
761f0855 | 491 | int flags; |
46e2747c NS |
492 | { |
493 | tree ctx = TYPE_CONTEXT (t); | |
bb20cc46 | 494 | |
46e2747c NS |
495 | if (TREE_CODE (ctx) == TYPENAME_TYPE) |
496 | dump_typename (ctx, flags); | |
497 | else | |
761f0855 | 498 | dump_type (ctx, flags & ~TFF_CLASS_KEY_OR_ENUM); |
99885b3f | 499 | print_scope_operator (scratch_buffer); |
46e2747c NS |
500 | dump_decl (TYPENAME_TYPE_FULLNAME (t), flags); |
501 | } | |
502 | ||
9e93bc9d NS |
503 | /* Return the name of the supplied aggregate, or enumeral type. */ |
504 | ||
9c0758dd | 505 | static const char * |
c3e76028 | 506 | class_key_or_enum (t) |
8d08fdba | 507 | tree t; |
8d08fdba | 508 | { |
8d08fdba | 509 | if (TREE_CODE (t) == ENUMERAL_TYPE) |
51c184be | 510 | return "enum"; |
8d08fdba | 511 | else if (TREE_CODE (t) == UNION_TYPE) |
51c184be | 512 | return "union"; |
8d08fdba | 513 | else if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t)) |
51c184be | 514 | return "class"; |
8d08fdba | 515 | else |
51c184be MS |
516 | return "struct"; |
517 | } | |
518 | ||
9e93bc9d NS |
519 | /* Print out a class declaration T under the control of FLAGS, |
520 | in the form `class foo'. */ | |
e92cc029 | 521 | |
51c184be | 522 | static void |
9e93bc9d | 523 | dump_aggr_type (t, flags) |
51c184be | 524 | tree t; |
761f0855 | 525 | int flags; |
51c184be MS |
526 | { |
527 | tree name; | |
c3e76028 | 528 | const char *variety = class_key_or_enum (t); |
9e93bc9d NS |
529 | int typdef = 0; |
530 | int tmplate = 0; | |
8d08fdba | 531 | |
91063b51 | 532 | dump_qualifiers (t, after); |
8d08fdba | 533 | |
761f0855 | 534 | if (flags & TFF_CLASS_KEY_OR_ENUM) |
8d08fdba | 535 | { |
99885b3f GDR |
536 | print_identifier (scratch_buffer, variety); |
537 | output_add_space (scratch_buffer); | |
8d08fdba | 538 | } |
bb20cc46 | 539 | |
761f0855 | 540 | if (flags & TFF_CHASE_TYPEDEF) |
9e93bc9d | 541 | t = TYPE_MAIN_VARIANT (t); |
8d08fdba | 542 | |
9e93bc9d NS |
543 | name = TYPE_NAME (t); |
544 | ||
545 | if (name) | |
8d08fdba | 546 | { |
9e93bc9d NS |
547 | typdef = !DECL_ARTIFICIAL (name); |
548 | tmplate = !typdef && TREE_CODE (t) != ENUMERAL_TYPE | |
549 | && TYPE_LANG_SPECIFIC (t) && CLASSTYPE_TEMPLATE_INFO (t) | |
370af2d5 | 550 | && (CLASSTYPE_TEMPLATE_SPECIALIZATION (t) |
9e93bc9d NS |
551 | || TREE_CODE (CLASSTYPE_TI_TEMPLATE (t)) != TEMPLATE_DECL |
552 | || DECL_TEMPLATE_SPECIALIZATION (CLASSTYPE_TI_TEMPLATE (t)) | |
553 | || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t))); | |
761f0855 | 554 | dump_scope (CP_DECL_CONTEXT (name), flags | TFF_SCOPE); |
9e93bc9d NS |
555 | if (tmplate) |
556 | { | |
557 | /* Because the template names are mangled, we have to locate | |
558 | the most general template, and use that name. */ | |
559 | tree tpl = CLASSTYPE_TI_TEMPLATE (t); | |
bb20cc46 | 560 | |
9e93bc9d NS |
561 | while (DECL_TEMPLATE_INFO (tpl)) |
562 | tpl = DECL_TI_TEMPLATE (tpl); | |
563 | name = tpl; | |
564 | } | |
565 | name = DECL_NAME (name); | |
8d08fdba MS |
566 | } |
567 | ||
f30432d7 | 568 | if (name == 0 || ANON_AGGRNAME_P (name)) |
8d08fdba | 569 | { |
761f0855 | 570 | if (flags & TFF_CLASS_KEY_OR_ENUM) |
99885b3f GDR |
571 | print_identifier (scratch_buffer, "<anonymous>"); |
572 | else | |
573 | output_printf (scratch_buffer, "<anonymous %s>", variety); | |
8d08fdba MS |
574 | } |
575 | else | |
99885b3f | 576 | print_tree_identifier (scratch_buffer, name); |
9e93bc9d NS |
577 | if (tmplate) |
578 | dump_template_parms (TYPE_TEMPLATE_INFO (t), | |
579 | !CLASSTYPE_USE_TEMPLATE (t), | |
761f0855 | 580 | flags & ~TFF_TEMPLATE_HEADER); |
8d08fdba MS |
581 | } |
582 | ||
583 | /* Dump into the obstack the initial part of the output for a given type. | |
584 | This is necessary when dealing with things like functions returning | |
585 | functions. Examples: | |
586 | ||
587 | return type of `int (* fee ())()': pointer -> function -> int. Both | |
588 | pointer (and reference and offset) and function (and member) types must | |
589 | deal with prefix and suffix. | |
590 | ||
591 | Arrays must also do this for DECL nodes, like int a[], and for things like | |
bb20cc46 AJ |
592 | int *[]&. |
593 | ||
9e93bc9d NS |
594 | Return indicates how you should pad an object name after this. I.e. you |
595 | want to pad non-*, non-& cores, but not pad * or & types. */ | |
8d08fdba | 596 | |
9e93bc9d NS |
597 | static enum pad |
598 | dump_type_prefix (t, flags) | |
8d08fdba | 599 | tree t; |
761f0855 | 600 | int flags; |
8d08fdba | 601 | { |
9e93bc9d | 602 | enum pad padding = before; |
bb20cc46 | 603 | |
8d08fdba MS |
604 | if (TYPE_PTRMEMFUNC_P (t)) |
605 | { | |
606 | t = TYPE_PTRMEMFUNC_FN_TYPE (t); | |
607 | goto offset_type; | |
608 | } | |
bb20cc46 | 609 | |
8d08fdba MS |
610 | switch (TREE_CODE (t)) |
611 | { | |
612 | case POINTER_TYPE: | |
91063b51 | 613 | case REFERENCE_TYPE: |
8d08fdba MS |
614 | { |
615 | tree sub = TREE_TYPE (t); | |
bb20cc46 | 616 | |
9e93bc9d | 617 | padding = dump_type_prefix (sub, flags); |
8d08fdba MS |
618 | /* A tree for a member pointer looks like pointer to offset, |
619 | so let the OFFSET_TYPE case handle it. */ | |
91063b51 | 620 | if (!TYPE_PTRMEM_P (t)) |
8d08fdba | 621 | { |
9e93bc9d | 622 | if (TREE_CODE (sub) == ARRAY_TYPE) |
5f9cd837 GDR |
623 | { |
624 | output_add_space (scratch_buffer); | |
625 | print_left_paren (scratch_buffer); | |
626 | } | |
99885b3f GDR |
627 | output_add_character |
628 | (scratch_buffer, "&*"[TREE_CODE (t) == POINTER_TYPE]); | |
5f9cd837 | 629 | padding = dump_qualifiers (t, before); |
8d08fdba MS |
630 | } |
631 | } | |
8d08fdba MS |
632 | break; |
633 | ||
634 | case OFFSET_TYPE: | |
635 | offset_type: | |
9e93bc9d | 636 | padding = dump_type_prefix (TREE_TYPE (t), flags); |
51c184be MS |
637 | if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */ |
638 | { | |
9e93bc9d | 639 | if (padding != none) |
99885b3f | 640 | output_add_space (scratch_buffer); |
9e93bc9d | 641 | dump_type (TYPE_OFFSET_BASETYPE (t), flags); |
99885b3f | 642 | print_scope_operator (scratch_buffer); |
51c184be | 643 | } |
99885b3f | 644 | output_add_character (scratch_buffer, '*'); |
9e93bc9d | 645 | padding = dump_qualifiers (t, none); |
8d08fdba MS |
646 | break; |
647 | ||
648 | /* Can only be reached through function pointer -- this would not be | |
649 | correct if FUNCTION_DECLs used it. */ | |
650 | case FUNCTION_TYPE: | |
9e93bc9d NS |
651 | padding = dump_type_prefix (TREE_TYPE (t), flags); |
652 | if (padding != none) | |
99885b3f GDR |
653 | output_add_space (scratch_buffer); |
654 | print_left_paren (scratch_buffer); | |
9e93bc9d | 655 | padding = none; |
8d08fdba MS |
656 | break; |
657 | ||
658 | case METHOD_TYPE: | |
9e93bc9d NS |
659 | padding = dump_type_prefix (TREE_TYPE (t), flags); |
660 | if (padding != none) | |
99885b3f GDR |
661 | output_add_space (scratch_buffer); |
662 | print_left_paren (scratch_buffer); | |
9e93bc9d NS |
663 | padding = none; |
664 | dump_aggr_type (TYPE_METHOD_BASETYPE (t), flags); | |
99885b3f | 665 | print_scope_operator (scratch_buffer); |
8d08fdba MS |
666 | break; |
667 | ||
668 | case ARRAY_TYPE: | |
9e93bc9d | 669 | padding = dump_type_prefix (TREE_TYPE (t), flags); |
8d08fdba MS |
670 | break; |
671 | ||
672 | case ENUMERAL_TYPE: | |
8d08fdba MS |
673 | case IDENTIFIER_NODE: |
674 | case INTEGER_TYPE: | |
2986ae00 | 675 | case BOOLEAN_TYPE: |
8d08fdba MS |
676 | case REAL_TYPE: |
677 | case RECORD_TYPE: | |
678 | case TEMPLATE_TYPE_PARM: | |
73b0fce8 | 679 | case TEMPLATE_TEMPLATE_PARM: |
a1281f45 | 680 | case BOUND_TEMPLATE_TEMPLATE_PARM: |
8d08fdba MS |
681 | case TREE_LIST: |
682 | case TYPE_DECL: | |
683 | case TREE_VEC: | |
8d08fdba MS |
684 | case UNION_TYPE: |
685 | case UNKNOWN_TYPE: | |
686 | case VOID_TYPE: | |
5566b478 | 687 | case TYPENAME_TYPE: |
37c46b43 | 688 | case COMPLEX_TYPE: |
c00996a3 | 689 | case VECTOR_TYPE: |
9e93bc9d NS |
690 | dump_type (t, flags); |
691 | padding = before; | |
8d08fdba | 692 | break; |
bb20cc46 | 693 | |
8d08fdba | 694 | default: |
99885b3f GDR |
695 | sorry_for_unsupported_tree (t); |
696 | /* fall through. */ | |
9e93bc9d | 697 | case ERROR_MARK: |
99885b3f | 698 | print_identifier (scratch_buffer, "<typeprefixerror>"); |
9e93bc9d | 699 | break; |
8d08fdba | 700 | } |
9e93bc9d | 701 | return padding; |
8d08fdba MS |
702 | } |
703 | ||
9e93bc9d NS |
704 | /* Dump the suffix of type T, under control of FLAGS. This is the part |
705 | which appears after the identifier (or function parms). */ | |
706 | ||
8d08fdba | 707 | static void |
9e93bc9d | 708 | dump_type_suffix (t, flags) |
8d08fdba | 709 | tree t; |
761f0855 | 710 | int flags; |
8d08fdba MS |
711 | { |
712 | if (TYPE_PTRMEMFUNC_P (t)) | |
713 | t = TYPE_PTRMEMFUNC_FN_TYPE (t); | |
714 | ||
715 | switch (TREE_CODE (t)) | |
716 | { | |
717 | case POINTER_TYPE: | |
718 | case REFERENCE_TYPE: | |
719 | case OFFSET_TYPE: | |
39211cd5 | 720 | if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) |
99885b3f | 721 | print_right_paren (scratch_buffer); |
9e93bc9d | 722 | dump_type_suffix (TREE_TYPE (t), flags); |
8d08fdba MS |
723 | break; |
724 | ||
725 | /* Can only be reached through function pointer */ | |
726 | case FUNCTION_TYPE: | |
727 | case METHOD_TYPE: | |
728 | { | |
729 | tree arg; | |
99885b3f | 730 | print_right_paren (scratch_buffer); |
8d08fdba MS |
731 | arg = TYPE_ARG_TYPES (t); |
732 | if (TREE_CODE (t) == METHOD_TYPE) | |
733 | arg = TREE_CHAIN (arg); | |
734 | ||
4995028c NS |
735 | /* Function pointers don't have default args. Not in standard C++, |
736 | anyway; they may in g++, but we'll just pretend otherwise. */ | |
761f0855 | 737 | dump_parameters (arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS); |
4995028c | 738 | |
8d08fdba | 739 | if (TREE_CODE (t) == METHOD_TYPE) |
91063b51 | 740 | dump_qualifiers |
8d08fdba | 741 | (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), before); |
9e93bc9d | 742 | dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags); |
ad6b1795 | 743 | dump_type_suffix (TREE_TYPE (t), flags); |
8d08fdba MS |
744 | break; |
745 | } | |
746 | ||
747 | case ARRAY_TYPE: | |
99885b3f | 748 | print_left_bracket (scratch_buffer); |
8d08fdba | 749 | if (TYPE_DOMAIN (t)) |
5156628f | 750 | { |
665f2503 | 751 | if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0)) |
99885b3f GDR |
752 | print_integer |
753 | (scratch_buffer, | |
754 | tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1); | |
5156628f | 755 | else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR) |
9e93bc9d | 756 | dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0), |
761f0855 | 757 | flags & ~TFF_EXPR_IN_PARENS); |
5156628f | 758 | else |
ab76ca54 | 759 | dump_expr (fold (cp_build_binary_op |
5156628f | 760 | (PLUS_EXPR, TYPE_MAX_VALUE (TYPE_DOMAIN (t)), |
9e93bc9d | 761 | integer_one_node)), |
761f0855 | 762 | flags & ~TFF_EXPR_IN_PARENS); |
5156628f | 763 | } |
99885b3f | 764 | print_right_bracket (scratch_buffer); |
9e93bc9d | 765 | dump_type_suffix (TREE_TYPE (t), flags); |
8d08fdba | 766 | break; |
bb20cc46 | 767 | |
8d08fdba | 768 | case ENUMERAL_TYPE: |
8d08fdba MS |
769 | case IDENTIFIER_NODE: |
770 | case INTEGER_TYPE: | |
2986ae00 | 771 | case BOOLEAN_TYPE: |
8d08fdba MS |
772 | case REAL_TYPE: |
773 | case RECORD_TYPE: | |
774 | case TEMPLATE_TYPE_PARM: | |
73b0fce8 | 775 | case TEMPLATE_TEMPLATE_PARM: |
a97d0689 | 776 | case BOUND_TEMPLATE_TEMPLATE_PARM: |
8d08fdba MS |
777 | case TREE_LIST: |
778 | case TYPE_DECL: | |
779 | case TREE_VEC: | |
8d08fdba MS |
780 | case UNION_TYPE: |
781 | case UNKNOWN_TYPE: | |
782 | case VOID_TYPE: | |
5566b478 | 783 | case TYPENAME_TYPE: |
37c46b43 | 784 | case COMPLEX_TYPE: |
c00996a3 | 785 | case VECTOR_TYPE: |
8d08fdba MS |
786 | break; |
787 | ||
788 | default: | |
99885b3f | 789 | sorry_for_unsupported_tree (t); |
9e93bc9d NS |
790 | case ERROR_MARK: |
791 | /* Don't mark it here, we should have already done in | |
792 | dump_type_prefix. */ | |
793 | break; | |
8d08fdba MS |
794 | } |
795 | } | |
796 | ||
49c249e1 | 797 | static void |
8d08fdba MS |
798 | dump_global_iord (t) |
799 | tree t; | |
800 | { | |
99885b3f | 801 | const char *p = NULL; |
8d08fdba | 802 | |
92643fea | 803 | if (DECL_GLOBAL_CTOR_P (t)) |
99885b3f | 804 | p = "initializers"; |
92643fea | 805 | else if (DECL_GLOBAL_DTOR_P (t)) |
99885b3f | 806 | p = "destructors"; |
8d08fdba | 807 | else |
a98facb0 | 808 | abort (); |
bb20cc46 | 809 | |
99885b3f | 810 | output_printf (scratch_buffer, "(static %s for %s)", p, input_filename); |
8d08fdba MS |
811 | } |
812 | ||
07389efe | 813 | static void |
9e93bc9d | 814 | dump_simple_decl (t, type, flags) |
07389efe MM |
815 | tree t; |
816 | tree type; | |
761f0855 | 817 | int flags; |
07389efe | 818 | { |
761f0855 | 819 | if (flags & TFF_DECL_SPECIFIERS) |
07389efe | 820 | { |
9e93bc9d | 821 | if (dump_type_prefix (type, flags) != none) |
99885b3f | 822 | output_add_space (scratch_buffer); |
07389efe | 823 | } |
9e93bc9d NS |
824 | if (!DECL_INITIAL (t) || TREE_CODE (DECL_INITIAL (t)) != TEMPLATE_PARM_INDEX) |
825 | dump_scope (CP_DECL_CONTEXT (t), flags); | |
07389efe | 826 | if (DECL_NAME (t)) |
9e93bc9d | 827 | dump_decl (DECL_NAME (t), flags); |
07389efe | 828 | else |
99885b3f | 829 | print_identifier (scratch_buffer, "<anonymous>"); |
761f0855 | 830 | if (flags & TFF_DECL_SPECIFIERS) |
9e93bc9d | 831 | dump_type_suffix (type, flags); |
07389efe MM |
832 | } |
833 | ||
9e93bc9d NS |
834 | /* Dump a human readable string for the decl T under control of FLAGS. */ |
835 | ||
8d08fdba | 836 | static void |
9e93bc9d | 837 | dump_decl (t, flags) |
8d08fdba | 838 | tree t; |
761f0855 | 839 | int flags; |
8d08fdba MS |
840 | { |
841 | if (t == NULL_TREE) | |
842 | return; | |
843 | ||
844 | switch (TREE_CODE (t)) | |
845 | { | |
7177d104 | 846 | case TYPE_DECL: |
8d2733ca MS |
847 | { |
848 | /* Don't say 'typedef class A' */ | |
fc378698 | 849 | if (DECL_ARTIFICIAL (t)) |
8d2733ca | 850 | { |
761f0855 | 851 | if ((flags & TFF_DECL_SPECIFIERS) |
9e93bc9d | 852 | && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM) |
c6002625 | 853 | /* Say `class T' not just `T'. */ |
99885b3f | 854 | output_add_string (scratch_buffer, "class "); |
a9936d39 | 855 | |
9e93bc9d | 856 | dump_type (TREE_TYPE (t), flags); |
8d2733ca MS |
857 | break; |
858 | } | |
859 | } | |
761f0855 | 860 | if (flags & TFF_DECL_SPECIFIERS) |
99885b3f | 861 | output_add_string (scratch_buffer, "typedef "); |
bb20cc46 | 862 | dump_simple_decl (t, DECL_ORIGINAL_TYPE (t) |
9e93bc9d NS |
863 | ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), |
864 | flags); | |
7177d104 | 865 | break; |
bb20cc46 | 866 | |
8d08fdba | 867 | case VAR_DECL: |
b7484fbe | 868 | if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t))) |
8d08fdba | 869 | { |
99885b3f | 870 | output_add_string (scratch_buffer, "vtable for "); |
c4372ef4 NS |
871 | my_friendly_assert (TYPE_P (DECL_CONTEXT (t)), 20010720); |
872 | dump_type (DECL_CONTEXT (t), flags); | |
8d08fdba MS |
873 | break; |
874 | } | |
875 | /* else fall through */ | |
876 | case FIELD_DECL: | |
877 | case PARM_DECL: | |
9e93bc9d | 878 | dump_simple_decl (t, TREE_TYPE (t), flags); |
8d08fdba MS |
879 | break; |
880 | ||
f6a898ba | 881 | case RESULT_DECL: |
99885b3f | 882 | output_add_string (scratch_buffer, "<return value> "); |
f6a898ba AO |
883 | dump_simple_decl (t, TREE_TYPE (t), flags); |
884 | break; | |
885 | ||
a9aedbc2 | 886 | case NAMESPACE_DECL: |
9e93bc9d | 887 | dump_scope (CP_DECL_CONTEXT (t), flags); |
0c8feefe | 888 | if (DECL_NAME (t) == anonymous_namespace_name) |
99885b3f | 889 | print_identifier (scratch_buffer, "<unnamed>"); |
0c8feefe | 890 | else |
99885b3f | 891 | print_tree_identifier (scratch_buffer, DECL_NAME (t)); |
a9aedbc2 MS |
892 | break; |
893 | ||
3e3f722c | 894 | case SCOPE_REF: |
761f0855 | 895 | dump_decl (TREE_OPERAND (t, 0), flags & ~TFF_DECL_SPECIFIERS); |
99885b3f | 896 | print_scope_operator (scratch_buffer); |
9e93bc9d | 897 | dump_decl (TREE_OPERAND (t, 1), flags); |
bb20cc46 | 898 | break; |
3e3f722c | 899 | |
8d08fdba | 900 | case ARRAY_REF: |
9e93bc9d | 901 | dump_decl (TREE_OPERAND (t, 0), flags); |
99885b3f | 902 | print_left_bracket (scratch_buffer); |
9e93bc9d | 903 | dump_decl (TREE_OPERAND (t, 1), flags); |
99885b3f | 904 | print_right_bracket (scratch_buffer); |
8d08fdba MS |
905 | break; |
906 | ||
9e93bc9d | 907 | /* So that we can do dump_decl on an aggr type. */ |
8d08fdba MS |
908 | case RECORD_TYPE: |
909 | case UNION_TYPE: | |
910 | case ENUMERAL_TYPE: | |
9e93bc9d | 911 | dump_type (t, flags); |
8d08fdba MS |
912 | break; |
913 | ||
8d08fdba | 914 | case TYPE_EXPR: |
a98facb0 | 915 | abort (); |
8d08fdba MS |
916 | break; |
917 | ||
918 | /* These special cases are duplicated here so that other functions | |
33bd39a2 | 919 | can feed identifiers to error and get them demangled properly. */ |
8d08fdba | 920 | case IDENTIFIER_NODE: |
dc5c569a JJ |
921 | if (IDENTIFIER_TYPENAME_P (t)) |
922 | { | |
923 | output_add_string (scratch_buffer, "operator "); | |
924 | /* Not exactly IDENTIFIER_TYPE_VALUE. */ | |
925 | dump_type (TREE_TYPE (t), flags); | |
926 | break; | |
927 | } | |
928 | else | |
929 | print_tree_identifier (scratch_buffer, t); | |
8d08fdba MS |
930 | break; |
931 | ||
8f032717 MM |
932 | case OVERLOAD: |
933 | t = OVL_CURRENT (t); | |
934 | /* Fall through. */ | |
935 | ||
8d08fdba | 936 | case FUNCTION_DECL: |
92643fea MM |
937 | if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t)) |
938 | dump_global_iord (t); | |
da20811c | 939 | else if (! DECL_LANG_SPECIFIC (t)) |
99885b3f | 940 | print_identifier (scratch_buffer, "<internal>"); |
8d08fdba | 941 | else |
9e93bc9d | 942 | dump_function_decl (t, flags); |
8d08fdba MS |
943 | break; |
944 | ||
945 | case TEMPLATE_DECL: | |
38066e83 | 946 | dump_template_decl (t, flags); |
8d08fdba MS |
947 | break; |
948 | ||
74cd8397 JM |
949 | case TEMPLATE_ID_EXPR: |
950 | { | |
951 | tree args; | |
aa36c081 JM |
952 | tree name = TREE_OPERAND (t, 0); |
953 | if (is_overloaded_fn (name)) | |
954 | name = DECL_NAME (get_first_fn (name)); | |
9e93bc9d | 955 | dump_decl (name, flags); |
99885b3f | 956 | print_template_argument_list_start (scratch_buffer); |
74cd8397 JM |
957 | for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args)) |
958 | { | |
612c671a | 959 | dump_template_argument (TREE_VALUE (args), flags); |
74cd8397 | 960 | if (TREE_CHAIN (args)) |
99885b3f | 961 | separate_with_comma (scratch_buffer); |
74cd8397 | 962 | } |
99885b3f | 963 | print_template_argument_list_end (scratch_buffer); |
74cd8397 JM |
964 | } |
965 | break; | |
966 | ||
0fb9f1c3 | 967 | case LOOKUP_EXPR: |
9e93bc9d | 968 | dump_decl (TREE_OPERAND (t, 0), flags); |
0fb9f1c3 JM |
969 | break; |
970 | ||
8d08fdba | 971 | case LABEL_DECL: |
99885b3f | 972 | print_tree_identifier (scratch_buffer, DECL_NAME (t)); |
8d08fdba MS |
973 | break; |
974 | ||
975 | case CONST_DECL: | |
6467930b | 976 | if ((TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == ENUMERAL_TYPE) |
03555413 | 977 | || (DECL_INITIAL (t) && |
f84b4be9 | 978 | TREE_CODE (DECL_INITIAL (t)) == TEMPLATE_PARM_INDEX)) |
9e93bc9d | 979 | dump_simple_decl (t, TREE_TYPE (t), flags); |
224c649b | 980 | else if (DECL_NAME (t)) |
9e93bc9d | 981 | dump_decl (DECL_NAME (t), flags); |
03555413 | 982 | else if (DECL_INITIAL (t)) |
761f0855 | 983 | dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS); |
03555413 | 984 | else |
99885b3f | 985 | print_identifier (scratch_buffer, "enumerator"); |
8d08fdba MS |
986 | break; |
987 | ||
cffa8729 | 988 | case USING_DECL: |
99885b3f | 989 | output_add_string (scratch_buffer, "using "); |
9e93bc9d | 990 | dump_type (DECL_INITIAL (t), flags); |
99885b3f GDR |
991 | print_scope_operator (scratch_buffer); |
992 | print_tree_identifier (scratch_buffer, DECL_NAME (t)); | |
cffa8729 MS |
993 | break; |
994 | ||
50ad9642 MM |
995 | case BASELINK: |
996 | dump_decl (BASELINK_FUNCTIONS (t), flags); | |
997 | break; | |
998 | ||
8d08fdba | 999 | default: |
99885b3f | 1000 | sorry_for_unsupported_tree (t); |
9e93bc9d NS |
1001 | /* Fallthrough to error. */ |
1002 | ||
1003 | case ERROR_MARK: | |
99885b3f | 1004 | print_identifier (scratch_buffer, "<declaration error>"); |
9e93bc9d NS |
1005 | break; |
1006 | } | |
1007 | } | |
1008 | ||
1009 | /* Dump a template declaration T under control of FLAGS. This means the | |
1010 | 'template <...> leaders plus the 'class X' or 'void fn(...)' part. */ | |
1011 | ||
1012 | static void | |
1013 | dump_template_decl (t, flags) | |
1014 | tree t; | |
761f0855 | 1015 | int flags; |
9e93bc9d | 1016 | { |
b5ac18ea MM |
1017 | tree orig_parms = DECL_TEMPLATE_PARMS (t); |
1018 | tree parms; | |
bb20cc46 AJ |
1019 | int i; |
1020 | ||
761f0855 | 1021 | if (flags & TFF_TEMPLATE_HEADER) |
9e93bc9d | 1022 | { |
bb20cc46 | 1023 | for (parms = orig_parms = nreverse (orig_parms); |
b5ac18ea MM |
1024 | parms; |
1025 | parms = TREE_CHAIN (parms)) | |
9e93bc9d | 1026 | { |
b5ac18ea MM |
1027 | tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms); |
1028 | int len = TREE_VEC_LENGTH (inner_parms); | |
bb20cc46 | 1029 | |
99885b3f | 1030 | output_add_string (scratch_buffer, "template<"); |
38066e83 KL |
1031 | |
1032 | /* If we've shown the template prefix, we'd better show the | |
1033 | parameters' and decl's type too. */ | |
1034 | flags |= TFF_DECL_SPECIFIERS; | |
1035 | ||
9e93bc9d NS |
1036 | for (i = 0; i < len; i++) |
1037 | { | |
9e93bc9d | 1038 | if (i) |
99885b3f | 1039 | separate_with_comma (scratch_buffer); |
b5ac18ea | 1040 | dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags); |
9e93bc9d | 1041 | } |
99885b3f | 1042 | print_template_argument_list_end (scratch_buffer); |
faafaee6 | 1043 | output_add_space (scratch_buffer); |
9e93bc9d | 1044 | } |
b5ac18ea | 1045 | nreverse(orig_parms); |
38066e83 KL |
1046 | |
1047 | if (DECL_TEMPLATE_TEMPLATE_PARM_P (t)) | |
c6002625 | 1048 | /* Say `template<arg> class TT' not just `template<arg> TT'. */ |
38066e83 | 1049 | output_add_string (scratch_buffer, "class "); |
9e93bc9d | 1050 | } |
38066e83 | 1051 | |
9e93bc9d NS |
1052 | if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL) |
1053 | dump_type (TREE_TYPE (t), | |
761f0855 GDR |
1054 | ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME |
1055 | | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0))); | |
9e93bc9d | 1056 | else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL) |
761f0855 | 1057 | dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME); |
9e93bc9d | 1058 | else if (TREE_TYPE (t) == NULL_TREE) |
a98facb0 | 1059 | abort (); |
9e93bc9d NS |
1060 | else |
1061 | switch (NEXT_CODE (t)) | |
1062 | { | |
1063 | case METHOD_TYPE: | |
1064 | case FUNCTION_TYPE: | |
761f0855 | 1065 | dump_function_decl (t, flags | TFF_TEMPLATE_NAME); |
9e93bc9d NS |
1066 | break; |
1067 | default: | |
0e339752 | 1068 | /* This case can occur with some invalid code. */ |
9e93bc9d | 1069 | dump_type (TREE_TYPE (t), |
761f0855 GDR |
1070 | (flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME |
1071 | | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)); | |
8d08fdba MS |
1072 | } |
1073 | } | |
1074 | ||
4995028c | 1075 | /* Pretty print a function decl. There are several ways we want to print a |
761f0855 | 1076 | function declaration. The TFF_ bits in FLAGS tells us how to behave. |
33bd39a2 | 1077 | As error can only apply the '#' flag once to give 0 and 1 for V, there |
c6002625 | 1078 | is %D which doesn't print the throw specs, and %F which does. */ |
8d08fdba MS |
1079 | |
1080 | static void | |
9e93bc9d | 1081 | dump_function_decl (t, flags) |
8d08fdba | 1082 | tree t; |
761f0855 | 1083 | int flags; |
8d08fdba | 1084 | { |
98c1c668 JM |
1085 | tree fntype; |
1086 | tree parmtypes; | |
8d08fdba | 1087 | tree cname = NULL_TREE; |
612c671a GDR |
1088 | tree template_args = NULL_TREE; |
1089 | tree template_parms = NULL_TREE; | |
761f0855 | 1090 | int show_return = flags & TFF_RETURN_TYPE || flags & TFF_DECL_SPECIFIERS; |
8d08fdba | 1091 | |
98c1c668 JM |
1092 | if (TREE_CODE (t) == TEMPLATE_DECL) |
1093 | t = DECL_TEMPLATE_RESULT (t); | |
1094 | ||
612c671a | 1095 | /* Pretty print template instantiations only. */ |
f9817201 | 1096 | if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t)) |
612c671a | 1097 | { |
f9a7ae04 MM |
1098 | tree tmpl; |
1099 | ||
612c671a | 1100 | template_args = DECL_TI_ARGS (t); |
f9a7ae04 MM |
1101 | tmpl = most_general_template (t); |
1102 | if (tmpl && TREE_CODE (tmpl) == TEMPLATE_DECL) | |
1103 | { | |
1104 | template_parms = DECL_TEMPLATE_PARMS (tmpl); | |
1105 | t = tmpl; | |
1106 | } | |
612c671a GDR |
1107 | } |
1108 | ||
98c1c668 | 1109 | fntype = TREE_TYPE (t); |
e0fff4b3 | 1110 | parmtypes = FUNCTION_FIRST_USER_PARMTYPE (t); |
98c1c668 | 1111 | |
2642b9bf | 1112 | if (DECL_CLASS_SCOPE_P (t)) |
4f1c5b7d | 1113 | cname = DECL_CONTEXT (t); |
8d08fdba MS |
1114 | /* this is for partially instantiated template methods */ |
1115 | else if (TREE_CODE (fntype) == METHOD_TYPE) | |
1116 | cname = TREE_TYPE (TREE_VALUE (parmtypes)); | |
1117 | ||
761f0855 | 1118 | if (!(flags & TFF_DECL_SPECIFIERS)) |
9e93bc9d NS |
1119 | /* OK */; |
1120 | else if (DECL_STATIC_FUNCTION_P (t)) | |
99885b3f | 1121 | print_identifier (scratch_buffer, "static "); |
00bb3dad | 1122 | else if (DECL_VIRTUAL_P (t)) |
99885b3f | 1123 | print_identifier (scratch_buffer, "virtual "); |
bb20cc46 | 1124 | |
9e93bc9d NS |
1125 | /* Print the return type? */ |
1126 | if (show_return) | |
1127 | show_return = !DECL_CONV_FN_P (t) && !DECL_CONSTRUCTOR_P (t) | |
1128 | && !DECL_DESTRUCTOR_P (t); | |
1129 | if (show_return) | |
8d08fdba | 1130 | { |
5f9cd837 GDR |
1131 | dump_type_prefix (TREE_TYPE (fntype), flags); |
1132 | output_add_space (scratch_buffer); | |
8d08fdba MS |
1133 | } |
1134 | ||
61cd552e | 1135 | /* Print the function name. */ |
8d08fdba MS |
1136 | if (cname) |
1137 | { | |
9e93bc9d | 1138 | dump_type (cname, flags); |
99885b3f | 1139 | print_scope_operator (scratch_buffer); |
2642b9bf | 1140 | } |
9e93bc9d NS |
1141 | else |
1142 | dump_scope (CP_DECL_CONTEXT (t), flags); | |
8d08fdba | 1143 | |
9e93bc9d | 1144 | dump_function_name (t, flags); |
bb20cc46 | 1145 | |
55ace93c | 1146 | if (1) |
ad50e811 | 1147 | { |
ad50e811 | 1148 | dump_parameters (parmtypes, flags); |
bb20cc46 | 1149 | |
ad50e811 MM |
1150 | if (TREE_CODE (fntype) == METHOD_TYPE) |
1151 | dump_qualifiers (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))), | |
1152 | before); | |
bb20cc46 | 1153 | |
761f0855 | 1154 | if (flags & TFF_EXCEPTION_SPECIFICATION) |
ad50e811 | 1155 | dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), flags); |
ad6b1795 JM |
1156 | |
1157 | if (show_return) | |
1158 | dump_type_suffix (TREE_TYPE (fntype), flags); | |
ad50e811 | 1159 | } |
612c671a GDR |
1160 | |
1161 | /* If T is a template instantiation, dump the parameter binding. */ | |
1162 | if (template_parms != NULL_TREE && template_args != NULL_TREE) | |
1163 | { | |
99885b3f | 1164 | output_add_string (scratch_buffer, " [with "); |
b5ac18ea | 1165 | dump_template_bindings (template_parms, template_args); |
99885b3f | 1166 | print_right_bracket (scratch_buffer); |
612c671a | 1167 | } |
4995028c NS |
1168 | } |
1169 | ||
9e93bc9d NS |
1170 | /* Print a parameter list. If this is for a member function, the |
1171 | member object ptr (and any other hidden args) should have | |
c6002625 | 1172 | already been removed. */ |
4995028c NS |
1173 | |
1174 | static void | |
9e93bc9d | 1175 | dump_parameters (parmtypes, flags) |
4995028c | 1176 | tree parmtypes; |
761f0855 | 1177 | int flags; |
4995028c NS |
1178 | { |
1179 | int first; | |
99885b3f GDR |
1180 | |
1181 | print_left_paren (scratch_buffer); | |
4995028c NS |
1182 | |
1183 | for (first = 1; parmtypes != void_list_node; | |
1184 | parmtypes = TREE_CHAIN (parmtypes)) | |
1185 | { | |
1186 | if (!first) | |
99885b3f | 1187 | separate_with_comma (scratch_buffer); |
4995028c NS |
1188 | first = 0; |
1189 | if (!parmtypes) | |
1190 | { | |
99885b3f | 1191 | print_identifier (scratch_buffer, "..."); |
4995028c NS |
1192 | break; |
1193 | } | |
9e93bc9d | 1194 | dump_type (TREE_VALUE (parmtypes), flags); |
bb20cc46 | 1195 | |
761f0855 | 1196 | if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes)) |
4995028c | 1197 | { |
99885b3f | 1198 | output_add_string (scratch_buffer, " = "); |
761f0855 | 1199 | dump_expr (TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS); |
4995028c NS |
1200 | } |
1201 | } | |
1202 | ||
99885b3f | 1203 | print_right_paren (scratch_buffer); |
4995028c NS |
1204 | } |
1205 | ||
c6002625 | 1206 | /* Print an exception specification. T is the exception specification. */ |
4995028c NS |
1207 | |
1208 | static void | |
9e93bc9d | 1209 | dump_exception_spec (t, flags) |
4995028c | 1210 | tree t; |
761f0855 | 1211 | int flags; |
4995028c NS |
1212 | { |
1213 | if (t) | |
1214 | { | |
99885b3f | 1215 | output_add_string (scratch_buffer, " throw ("); |
4995028c NS |
1216 | if (TREE_VALUE (t) != NULL_TREE) |
1217 | while (1) | |
1218 | { | |
9e93bc9d | 1219 | dump_type (TREE_VALUE (t), flags); |
4995028c NS |
1220 | t = TREE_CHAIN (t); |
1221 | if (!t) | |
1222 | break; | |
99885b3f | 1223 | separate_with_comma (scratch_buffer); |
4995028c | 1224 | } |
99885b3f | 1225 | print_right_paren (scratch_buffer); |
4995028c | 1226 | } |
8d08fdba MS |
1227 | } |
1228 | ||
1229 | /* Handle the function name for a FUNCTION_DECL node, grokking operators | |
1230 | and destructors properly. */ | |
e92cc029 | 1231 | |
8d08fdba | 1232 | static void |
9e93bc9d | 1233 | dump_function_name (t, flags) |
8d08fdba | 1234 | tree t; |
761f0855 | 1235 | int flags; |
8d08fdba MS |
1236 | { |
1237 | tree name = DECL_NAME (t); | |
1238 | ||
78abea27 RS |
1239 | if (TREE_CODE (t) == TEMPLATE_DECL) |
1240 | t = DECL_TEMPLATE_RESULT (t); | |
1241 | ||
5e818b93 JM |
1242 | /* Don't let the user see __comp_ctor et al. */ |
1243 | if (DECL_CONSTRUCTOR_P (t) | |
1244 | || DECL_DESTRUCTOR_P (t)) | |
1245 | name = constructor_name (DECL_CONTEXT (t)); | |
1246 | ||
aa45967f | 1247 | if (DECL_DESTRUCTOR_P (t)) |
8d08fdba | 1248 | { |
99885b3f | 1249 | output_add_character (scratch_buffer, '~'); |
761f0855 | 1250 | dump_decl (name, TFF_PLAIN_IDENTIFIER); |
8d08fdba | 1251 | } |
aa45967f | 1252 | else if (DECL_CONV_FN_P (t)) |
8d08fdba MS |
1253 | { |
1254 | /* This cannot use the hack that the operator's return | |
1255 | type is stashed off of its name because it may be | |
1256 | used for error reporting. In the case of conflicting | |
1257 | declarations, both will have the same name, yet | |
1258 | the types will be different, hence the TREE_TYPE field | |
1259 | of the first name will be clobbered by the second. */ | |
99885b3f | 1260 | output_add_string (scratch_buffer, "operator "); |
9e93bc9d | 1261 | dump_type (TREE_TYPE (TREE_TYPE (t)), flags); |
8d08fdba MS |
1262 | } |
1263 | else if (IDENTIFIER_OPNAME_P (name)) | |
99885b3f | 1264 | print_tree_identifier (scratch_buffer, name); |
8d08fdba | 1265 | else |
9e93bc9d | 1266 | dump_decl (name, flags); |
386b8a85 | 1267 | |
9e93bc9d | 1268 | if (DECL_LANG_SPECIFIC (t) && DECL_TEMPLATE_INFO (t) |
05fd666b | 1269 | && !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (t) |
bb20cc46 | 1270 | && (DECL_TEMPLATE_SPECIALIZATION (t) |
36a117a5 MM |
1271 | || TREE_CODE (DECL_TI_TEMPLATE (t)) != TEMPLATE_DECL |
1272 | || DECL_TEMPLATE_SPECIALIZATION (DECL_TI_TEMPLATE (t)) | |
1273 | || PRIMARY_TEMPLATE_P (DECL_TI_TEMPLATE (t)))) | |
9e93bc9d NS |
1274 | dump_template_parms (DECL_TEMPLATE_INFO (t), !DECL_USE_TEMPLATE (t), flags); |
1275 | } | |
75650646 | 1276 | |
9e93bc9d NS |
1277 | /* Dump the template parameters from the template info INFO under control of |
1278 | FLAGS. PRIMARY indicates whether this is a primary template decl, or | |
1279 | specialization (partial or complete). For partial specializations we show | |
1280 | the specialized parameter values. For a primary template we show no | |
1281 | decoration. */ | |
1282 | ||
1283 | static void | |
1284 | dump_template_parms (info, primary, flags) | |
1285 | tree info; | |
1286 | int primary; | |
761f0855 | 1287 | int flags; |
9e93bc9d NS |
1288 | { |
1289 | tree args = info ? TI_ARGS (info) : NULL_TREE; | |
bb20cc46 | 1290 | |
761f0855 | 1291 | if (primary && flags & TFF_TEMPLATE_NAME) |
9e93bc9d | 1292 | return; |
761f0855 | 1293 | flags &= ~(TFF_CLASS_KEY_OR_ENUM | TFF_TEMPLATE_NAME); |
99885b3f | 1294 | print_template_argument_list_start (scratch_buffer); |
9e93bc9d NS |
1295 | |
1296 | /* Be careful only to print things when we have them, so as not | |
36a117a5 | 1297 | to crash producing error messages. */ |
9e93bc9d NS |
1298 | if (args && !primary) |
1299 | { | |
1300 | int len = 0; | |
1301 | int ix = 0; | |
1302 | int need_comma = 0; | |
bb20cc46 | 1303 | |
9e93bc9d NS |
1304 | if (TREE_CODE (args) == TREE_VEC) |
1305 | { | |
1306 | if (TREE_VEC_LENGTH (args) > 0 | |
bb20cc46 AJ |
1307 | && TREE_CODE (TREE_VEC_ELT (args, 0)) == TREE_VEC) |
1308 | args = TREE_VEC_ELT (args, TREE_VEC_LENGTH (args) - 1); | |
1309 | ||
9e93bc9d NS |
1310 | len = TREE_VEC_LENGTH (args); |
1311 | } | |
1312 | else if (TREE_CODE (args) == TREE_LIST) | |
1313 | len = -1; | |
1314 | while (ix != len && args) | |
1315 | { | |
1316 | tree arg; | |
1317 | if (len >= 0) | |
1318 | { | |
1319 | arg = TREE_VEC_ELT (args, ix); | |
1320 | ix++; | |
1321 | } | |
1322 | else | |
1323 | { | |
1324 | arg = TREE_VALUE (args); | |
1325 | args = TREE_CHAIN (args); | |
1326 | } | |
1327 | if (need_comma) | |
99885b3f GDR |
1328 | separate_with_comma (scratch_buffer); |
1329 | ||
9e93bc9d | 1330 | if (!arg) |
99885b3f | 1331 | print_identifier (scratch_buffer, "<template parameter error>"); |
9e93bc9d | 1332 | else |
612c671a | 1333 | dump_template_argument (arg, flags); |
9e93bc9d NS |
1334 | need_comma = 1; |
1335 | } | |
1336 | } | |
9e93bc9d NS |
1337 | else if (primary) |
1338 | { | |
1339 | tree tpl = TI_TEMPLATE (info); | |
1340 | tree parms = DECL_TEMPLATE_PARMS (tpl); | |
1341 | int len, ix; | |
bb20cc46 | 1342 | |
9e93bc9d NS |
1343 | parms = TREE_CODE (parms) == TREE_LIST ? TREE_VALUE (parms) : NULL_TREE; |
1344 | len = parms ? TREE_VEC_LENGTH (parms) : 0; | |
bb20cc46 | 1345 | |
9e93bc9d NS |
1346 | for (ix = 0; ix != len; ix++) |
1347 | { | |
1348 | tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix)); | |
1349 | ||
1350 | if (ix) | |
99885b3f | 1351 | separate_with_comma (scratch_buffer); |
bb20cc46 | 1352 | |
761f0855 | 1353 | dump_decl (parm, flags & ~TFF_DECL_SPECIFIERS); |
9e93bc9d | 1354 | } |
386b8a85 | 1355 | } |
99885b3f | 1356 | print_template_argument_list_end (scratch_buffer); |
8d08fdba MS |
1357 | } |
1358 | ||
1359 | static void | |
1360 | dump_char (c) | |
b2bb2710 | 1361 | int c; |
8d08fdba MS |
1362 | { |
1363 | switch (c) | |
1364 | { | |
a0a33927 | 1365 | case TARGET_NEWLINE: |
99885b3f | 1366 | output_add_string (scratch_buffer, "\\n"); |
8d08fdba | 1367 | break; |
a0a33927 | 1368 | case TARGET_TAB: |
99885b3f | 1369 | output_add_string (scratch_buffer, "\\t"); |
8d08fdba | 1370 | break; |
a0a33927 | 1371 | case TARGET_VT: |
99885b3f | 1372 | output_add_string (scratch_buffer, "\\v"); |
8d08fdba | 1373 | break; |
a0a33927 | 1374 | case TARGET_BS: |
99885b3f | 1375 | output_add_string (scratch_buffer, "\\b"); |
8d08fdba | 1376 | break; |
a0a33927 | 1377 | case TARGET_CR: |
99885b3f | 1378 | output_add_string (scratch_buffer, "\\r"); |
8d08fdba | 1379 | break; |
a0a33927 | 1380 | case TARGET_FF: |
99885b3f | 1381 | output_add_string (scratch_buffer, "\\f"); |
8d08fdba | 1382 | break; |
a0a33927 | 1383 | case TARGET_BELL: |
99885b3f | 1384 | output_add_string (scratch_buffer, "\\a"); |
8d08fdba MS |
1385 | break; |
1386 | case '\\': | |
99885b3f | 1387 | output_add_string (scratch_buffer, "\\\\"); |
8d08fdba MS |
1388 | break; |
1389 | case '\'': | |
99885b3f | 1390 | output_add_string (scratch_buffer, "\\'"); |
8d08fdba MS |
1391 | break; |
1392 | case '\"': | |
99885b3f | 1393 | output_add_string (scratch_buffer, "\\\""); |
8d08fdba MS |
1394 | break; |
1395 | default: | |
faa25e97 | 1396 | if (ISPRINT (c)) |
99885b3f | 1397 | output_add_character (scratch_buffer, c); |
8d08fdba MS |
1398 | else |
1399 | { | |
1400 | sprintf (digit_buffer, "\\%03o", (int) c); | |
99885b3f | 1401 | output_add_string (scratch_buffer, digit_buffer); |
8d08fdba MS |
1402 | } |
1403 | } | |
1404 | } | |
1405 | ||
1406 | /* Print out a list of initializers (subr of dump_expr) */ | |
e92cc029 | 1407 | |
8d08fdba | 1408 | static void |
9e93bc9d | 1409 | dump_expr_list (l, flags) |
8d08fdba | 1410 | tree l; |
761f0855 | 1411 | int flags; |
8d08fdba MS |
1412 | { |
1413 | while (l) | |
1414 | { | |
761f0855 | 1415 | dump_expr (TREE_VALUE (l), flags | TFF_EXPR_IN_PARENS); |
8d08fdba | 1416 | l = TREE_CHAIN (l); |
9e93bc9d | 1417 | if (l) |
99885b3f | 1418 | separate_with_comma (scratch_buffer); |
8d08fdba MS |
1419 | } |
1420 | } | |
1421 | ||
c6002625 | 1422 | /* Print out an expression E under control of FLAGS. */ |
e92cc029 | 1423 | |
8d08fdba | 1424 | static void |
9e93bc9d | 1425 | dump_expr (t, flags) |
8d08fdba | 1426 | tree t; |
761f0855 | 1427 | int flags; |
8d08fdba | 1428 | { |
8c048a52 GDR |
1429 | if (t == 0) |
1430 | return; | |
1431 | ||
8d08fdba MS |
1432 | switch (TREE_CODE (t)) |
1433 | { | |
1434 | case VAR_DECL: | |
1435 | case PARM_DECL: | |
1436 | case FIELD_DECL: | |
1437 | case CONST_DECL: | |
1438 | case FUNCTION_DECL: | |
ec255269 | 1439 | case TEMPLATE_DECL: |
6b57ac29 | 1440 | case NAMESPACE_DECL: |
5d73aa63 | 1441 | case OVERLOAD: |
a723baf1 | 1442 | case IDENTIFIER_NODE: |
761f0855 | 1443 | dump_decl (t, flags & ~TFF_DECL_SPECIFIERS); |
8d08fdba MS |
1444 | break; |
1445 | ||
1446 | case INTEGER_CST: | |
1447 | { | |
1448 | tree type = TREE_TYPE (t); | |
1449 | my_friendly_assert (type != 0, 81); | |
1450 | ||
1451 | /* If it's an enum, output its tag, rather than its value. */ | |
1452 | if (TREE_CODE (type) == ENUMERAL_TYPE) | |
1453 | { | |
fa40aa12 | 1454 | tree values = TYPE_VALUES (type); |
bb20cc46 | 1455 | |
fa40aa12 NS |
1456 | for (; values; |
1457 | values = TREE_CHAIN (values)) | |
1458 | if (tree_int_cst_equal (TREE_VALUE (values), t)) | |
1459 | break; | |
bb20cc46 | 1460 | |
fa40aa12 | 1461 | if (values) |
99885b3f | 1462 | print_tree_identifier (scratch_buffer, TREE_PURPOSE (values)); |
fa40aa12 NS |
1463 | else |
1464 | { | |
1465 | /* Value must have been cast. */ | |
99885b3f | 1466 | print_left_paren (scratch_buffer); |
fa40aa12 | 1467 | dump_type (type, flags); |
99885b3f | 1468 | print_right_paren (scratch_buffer); |
fa40aa12 NS |
1469 | goto do_int; |
1470 | } | |
8d08fdba | 1471 | } |
b7484fbe MS |
1472 | else if (type == boolean_type_node) |
1473 | { | |
665f2503 | 1474 | if (t == boolean_false_node || integer_zerop (t)) |
99885b3f | 1475 | print_identifier (scratch_buffer, "false"); |
b7484fbe | 1476 | else if (t == boolean_true_node) |
99885b3f | 1477 | print_identifier (scratch_buffer, "true"); |
b7484fbe MS |
1478 | } |
1479 | else if (type == char_type_node) | |
8d08fdba | 1480 | { |
99885b3f | 1481 | output_add_character (scratch_buffer, '\''); |
5089de93 MM |
1482 | if (host_integerp (t, TREE_UNSIGNED (type))) |
1483 | dump_char (tree_low_cst (t, TREE_UNSIGNED (type))); | |
1484 | else | |
42b99e03 KG |
1485 | output_printf (scratch_buffer, "\\x%x", |
1486 | (unsigned int) TREE_INT_CST_LOW (t)); | |
99885b3f | 1487 | output_add_character (scratch_buffer, '\''); |
8d08fdba | 1488 | } |
fa40aa12 | 1489 | else |
8d08fdba | 1490 | { |
fa40aa12 | 1491 | do_int: |
ba523395 | 1492 | if (! host_integerp (t, 0)) |
8d08fdba | 1493 | { |
fa40aa12 NS |
1494 | tree val = t; |
1495 | ||
1496 | if (tree_int_cst_sgn (val) < 0) | |
1497 | { | |
99885b3f | 1498 | output_add_character (scratch_buffer, '-'); |
fa40aa12 NS |
1499 | val = build_int_2 (-TREE_INT_CST_LOW (val), |
1500 | ~TREE_INT_CST_HIGH (val) | |
1501 | + !TREE_INT_CST_LOW (val)); | |
1502 | } | |
1503 | /* Would "%x%0*x" or "%x%*0x" get zero-padding on all | |
1504 | systems? */ | |
1505 | { | |
1506 | static char format[10]; /* "%x%09999x\0" */ | |
1507 | if (!format[0]) | |
1508 | sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4); | |
1509 | sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val), | |
1510 | TREE_INT_CST_LOW (val)); | |
99885b3f | 1511 | output_add_string (scratch_buffer, digit_buffer); |
fa40aa12 | 1512 | } |
8d08fdba | 1513 | } |
fa40aa12 | 1514 | else |
99885b3f | 1515 | print_integer (scratch_buffer, TREE_INT_CST_LOW (t)); |
8d08fdba | 1516 | } |
8d08fdba MS |
1517 | } |
1518 | break; | |
1519 | ||
1520 | case REAL_CST: | |
da6eec72 RH |
1521 | real_to_decimal (digit_buffer, &TREE_REAL_CST (t), |
1522 | sizeof (digit_buffer), 0, 1); | |
99885b3f | 1523 | output_add_string (scratch_buffer, digit_buffer); |
8d08fdba MS |
1524 | break; |
1525 | ||
61a127b3 | 1526 | case PTRMEM_CST: |
99885b3f | 1527 | output_add_character (scratch_buffer, '&'); |
9e93bc9d | 1528 | dump_type (PTRMEM_CST_CLASS (t), flags); |
99885b3f GDR |
1529 | print_scope_operator (scratch_buffer); |
1530 | print_tree_identifier | |
1531 | (scratch_buffer, DECL_NAME (PTRMEM_CST_MEMBER (t))); | |
61a127b3 MM |
1532 | break; |
1533 | ||
8d08fdba MS |
1534 | case STRING_CST: |
1535 | { | |
9c0758dd | 1536 | const char *p = TREE_STRING_POINTER (t); |
8d08fdba MS |
1537 | int len = TREE_STRING_LENGTH (t) - 1; |
1538 | int i; | |
1539 | ||
99885b3f | 1540 | output_add_character (scratch_buffer, '\"'); |
8d08fdba MS |
1541 | for (i = 0; i < len; i++) |
1542 | dump_char (p[i]); | |
99885b3f | 1543 | output_add_character (scratch_buffer, '\"'); |
8d08fdba MS |
1544 | } |
1545 | break; | |
1546 | ||
1547 | case COMPOUND_EXPR: | |
99885b3f | 1548 | print_left_paren (scratch_buffer); |
761f0855 | 1549 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1550 | separate_with_comma (scratch_buffer); |
761f0855 | 1551 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1552 | print_right_paren (scratch_buffer); |
8d08fdba MS |
1553 | break; |
1554 | ||
1555 | case COND_EXPR: | |
99885b3f | 1556 | print_left_paren (scratch_buffer); |
761f0855 | 1557 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1558 | output_add_string (scratch_buffer, " ? "); |
761f0855 | 1559 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1560 | output_add_string (scratch_buffer, " : "); |
761f0855 | 1561 | dump_expr (TREE_OPERAND (t, 2), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1562 | print_right_paren (scratch_buffer); |
8d08fdba MS |
1563 | break; |
1564 | ||
1565 | case SAVE_EXPR: | |
1566 | if (TREE_HAS_CONSTRUCTOR (t)) | |
1567 | { | |
99885b3f | 1568 | output_add_string (scratch_buffer, "new "); |
9e93bc9d | 1569 | dump_type (TREE_TYPE (TREE_TYPE (t)), flags); |
8d08fdba MS |
1570 | } |
1571 | else | |
1572 | { | |
761f0855 | 1573 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
8d08fdba MS |
1574 | } |
1575 | break; | |
1576 | ||
02531345 | 1577 | case AGGR_INIT_EXPR: |
27b8d0cd MM |
1578 | { |
1579 | tree fn = NULL_TREE; | |
bb20cc46 | 1580 | |
27b8d0cd MM |
1581 | if (TREE_CODE (TREE_OPERAND (t, 0)) == ADDR_EXPR) |
1582 | fn = TREE_OPERAND (TREE_OPERAND (t, 0), 0); | |
1583 | ||
1584 | if (fn && TREE_CODE (fn) == FUNCTION_DECL) | |
1585 | { | |
1586 | if (DECL_CONSTRUCTOR_P (fn)) | |
99885b3f GDR |
1587 | print_tree_identifier |
1588 | (scratch_buffer, TYPE_IDENTIFIER (TREE_TYPE (t))); | |
27b8d0cd MM |
1589 | else |
1590 | dump_decl (fn, 0); | |
1591 | } | |
1592 | else | |
1593 | dump_expr (TREE_OPERAND (t, 0), 0); | |
1594 | } | |
99885b3f | 1595 | print_left_paren (scratch_buffer); |
42976354 | 1596 | if (TREE_OPERAND (t, 1)) |
9e93bc9d | 1597 | dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags); |
99885b3f | 1598 | print_right_paren (scratch_buffer); |
8d08fdba MS |
1599 | break; |
1600 | ||
1601 | case CALL_EXPR: | |
1602 | { | |
1603 | tree fn = TREE_OPERAND (t, 0); | |
1604 | tree args = TREE_OPERAND (t, 1); | |
bb20cc46 | 1605 | |
8d08fdba MS |
1606 | if (TREE_CODE (fn) == ADDR_EXPR) |
1607 | fn = TREE_OPERAND (fn, 0); | |
1608 | ||
6467930b | 1609 | if (TREE_TYPE (fn) != NULL_TREE && NEXT_CODE (fn) == METHOD_TYPE) |
8d08fdba MS |
1610 | { |
1611 | tree ob = TREE_VALUE (args); | |
1612 | if (TREE_CODE (ob) == ADDR_EXPR) | |
1613 | { | |
761f0855 | 1614 | dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1615 | output_add_character (scratch_buffer, '.'); |
8d08fdba MS |
1616 | } |
1617 | else if (TREE_CODE (ob) != PARM_DECL | |
1618 | || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) | |
1619 | { | |
761f0855 | 1620 | dump_expr (ob, flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1621 | output_add_string (scratch_buffer, "->"); |
8d08fdba MS |
1622 | } |
1623 | args = TREE_CHAIN (args); | |
1624 | } | |
761f0855 | 1625 | dump_expr (fn, flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1626 | print_left_paren (scratch_buffer); |
9e93bc9d | 1627 | dump_expr_list (args, flags); |
99885b3f | 1628 | print_right_paren (scratch_buffer); |
8d08fdba MS |
1629 | } |
1630 | break; | |
1631 | ||
285baa06 JM |
1632 | case NEW_EXPR: |
1633 | { | |
1634 | tree type = TREE_OPERAND (t, 1); | |
1635 | if (NEW_EXPR_USE_GLOBAL (t)) | |
99885b3f GDR |
1636 | print_scope_operator (scratch_buffer); |
1637 | output_add_string (scratch_buffer, "new "); | |
285baa06 JM |
1638 | if (TREE_OPERAND (t, 0)) |
1639 | { | |
99885b3f | 1640 | print_left_paren (scratch_buffer); |
9e93bc9d | 1641 | dump_expr_list (TREE_OPERAND (t, 0), flags); |
99885b3f | 1642 | output_add_string (scratch_buffer, ") "); |
285baa06 JM |
1643 | } |
1644 | if (TREE_CODE (type) == ARRAY_REF) | |
1645 | type = build_cplus_array_type | |
1646 | (TREE_OPERAND (type, 0), | |
fed3cef0 RK |
1647 | build_index_type (fold (build (MINUS_EXPR, integer_type_node, |
1648 | TREE_OPERAND (type, 1), | |
1649 | integer_one_node)))); | |
9e93bc9d | 1650 | dump_type (type, flags); |
285baa06 JM |
1651 | if (TREE_OPERAND (t, 2)) |
1652 | { | |
99885b3f | 1653 | print_left_paren (scratch_buffer); |
9e93bc9d | 1654 | dump_expr_list (TREE_OPERAND (t, 2), flags); |
99885b3f | 1655 | print_right_paren (scratch_buffer); |
285baa06 JM |
1656 | } |
1657 | } | |
1658 | break; | |
1659 | ||
8d08fdba MS |
1660 | case TARGET_EXPR: |
1661 | /* Note that this only works for G++ target exprs. If somebody | |
1662 | builds a general TARGET_EXPR, there's no way to represent that | |
1663 | it initializes anything other that the parameter slot for the | |
1664 | default argument. Note we may have cleared out the first | |
1665 | operand in expand_expr, so don't go killing ourselves. */ | |
1666 | if (TREE_OPERAND (t, 1)) | |
761f0855 | 1667 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
8d08fdba MS |
1668 | break; |
1669 | ||
b3ab27f3 | 1670 | case INIT_EXPR: |
8d08fdba MS |
1671 | case MODIFY_EXPR: |
1672 | case PLUS_EXPR: | |
1673 | case MINUS_EXPR: | |
1674 | case MULT_EXPR: | |
1675 | case TRUNC_DIV_EXPR: | |
1676 | case TRUNC_MOD_EXPR: | |
1677 | case MIN_EXPR: | |
1678 | case MAX_EXPR: | |
1679 | case LSHIFT_EXPR: | |
1680 | case RSHIFT_EXPR: | |
1681 | case BIT_IOR_EXPR: | |
1682 | case BIT_XOR_EXPR: | |
1683 | case BIT_AND_EXPR: | |
1684 | case BIT_ANDTC_EXPR: | |
1685 | case TRUTH_ANDIF_EXPR: | |
1686 | case TRUTH_ORIF_EXPR: | |
1687 | case LT_EXPR: | |
1688 | case LE_EXPR: | |
1689 | case GT_EXPR: | |
1690 | case GE_EXPR: | |
1691 | case EQ_EXPR: | |
1692 | case NE_EXPR: | |
2adeacc9 | 1693 | case EXACT_DIV_EXPR: |
596ea4e5 | 1694 | dump_binary_op (operator_name_info[(int) TREE_CODE (t)].name, t, flags); |
8d08fdba MS |
1695 | break; |
1696 | ||
1697 | case CEIL_DIV_EXPR: | |
1698 | case FLOOR_DIV_EXPR: | |
1699 | case ROUND_DIV_EXPR: | |
9e93bc9d | 1700 | dump_binary_op ("/", t, flags); |
8d08fdba MS |
1701 | break; |
1702 | ||
1703 | case CEIL_MOD_EXPR: | |
1704 | case FLOOR_MOD_EXPR: | |
1705 | case ROUND_MOD_EXPR: | |
9e93bc9d | 1706 | dump_binary_op ("%", t, flags); |
8d08fdba MS |
1707 | break; |
1708 | ||
1709 | case COMPONENT_REF: | |
1710 | { | |
1711 | tree ob = TREE_OPERAND (t, 0); | |
1712 | if (TREE_CODE (ob) == INDIRECT_REF) | |
1713 | { | |
1714 | ob = TREE_OPERAND (ob, 0); | |
1715 | if (TREE_CODE (ob) != PARM_DECL | |
1716 | || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")) | |
1717 | { | |
761f0855 | 1718 | dump_expr (ob, flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1719 | output_add_string (scratch_buffer, "->"); |
8d08fdba MS |
1720 | } |
1721 | } | |
1722 | else | |
1723 | { | |
761f0855 | 1724 | dump_expr (ob, flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1725 | output_add_character (scratch_buffer, '.'); |
8d08fdba | 1726 | } |
761f0855 | 1727 | dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS); |
8d08fdba MS |
1728 | } |
1729 | break; | |
1730 | ||
28cbf42c | 1731 | case ARRAY_REF: |
761f0855 | 1732 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1733 | print_left_bracket (scratch_buffer); |
761f0855 | 1734 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1735 | print_right_bracket (scratch_buffer); |
28cbf42c MS |
1736 | break; |
1737 | ||
8d08fdba | 1738 | case CONVERT_EXPR: |
03da5286 | 1739 | if (TREE_TYPE (t) && VOID_TYPE_P (TREE_TYPE (t))) |
df39af7d | 1740 | { |
99885b3f | 1741 | print_left_paren (scratch_buffer); |
b72801e2 | 1742 | dump_type (TREE_TYPE (t), flags); |
99885b3f | 1743 | print_right_paren (scratch_buffer); |
9e93bc9d | 1744 | dump_expr (TREE_OPERAND (t, 0), flags); |
df39af7d JM |
1745 | } |
1746 | else | |
9e93bc9d | 1747 | dump_unary_op ("+", t, flags); |
8d08fdba MS |
1748 | break; |
1749 | ||
1750 | case ADDR_EXPR: | |
1751 | if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL | |
fd74ca0b MM |
1752 | || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST |
1753 | /* An ADDR_EXPR can have reference type. In that case, we | |
1754 | shouldn't print the `&' doing so indicates to the user | |
1755 | that the expression has pointer type. */ | |
bb20cc46 | 1756 | || (TREE_TYPE (t) |
fd74ca0b | 1757 | && TREE_CODE (TREE_TYPE (t)) == REFERENCE_TYPE)) |
761f0855 | 1758 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
8d08fdba | 1759 | else |
9e93bc9d | 1760 | dump_unary_op ("&", t, flags); |
8d08fdba MS |
1761 | break; |
1762 | ||
1763 | case INDIRECT_REF: | |
1764 | if (TREE_HAS_CONSTRUCTOR (t)) | |
1765 | { | |
1766 | t = TREE_OPERAND (t, 0); | |
1767 | my_friendly_assert (TREE_CODE (t) == CALL_EXPR, 237); | |
761f0855 | 1768 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1769 | print_left_paren (scratch_buffer); |
9e93bc9d | 1770 | dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)), flags); |
99885b3f | 1771 | print_right_paren (scratch_buffer); |
8d08fdba MS |
1772 | } |
1773 | else | |
1774 | { | |
6467930b | 1775 | if (TREE_OPERAND (t,0) != NULL_TREE |
5082a355 | 1776 | && TREE_TYPE (TREE_OPERAND (t, 0)) |
6467930b | 1777 | && NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE) |
9e93bc9d | 1778 | dump_expr (TREE_OPERAND (t, 0), flags); |
8d08fdba | 1779 | else |
9e93bc9d | 1780 | dump_unary_op ("*", t, flags); |
8d08fdba MS |
1781 | } |
1782 | break; | |
1783 | ||
1784 | case NEGATE_EXPR: | |
1785 | case BIT_NOT_EXPR: | |
1786 | case TRUTH_NOT_EXPR: | |
1787 | case PREDECREMENT_EXPR: | |
1788 | case PREINCREMENT_EXPR: | |
596ea4e5 | 1789 | dump_unary_op (operator_name_info [(int)TREE_CODE (t)].name, t, flags); |
8d08fdba MS |
1790 | break; |
1791 | ||
1792 | case POSTDECREMENT_EXPR: | |
1793 | case POSTINCREMENT_EXPR: | |
99885b3f | 1794 | print_left_paren (scratch_buffer); |
761f0855 | 1795 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f GDR |
1796 | print_identifier |
1797 | (scratch_buffer, operator_name_info[(int)TREE_CODE (t)].name); | |
1798 | print_right_paren (scratch_buffer); | |
8d08fdba MS |
1799 | break; |
1800 | ||
1801 | case NON_LVALUE_EXPR: | |
1802 | /* FIXME: This is a KLUDGE workaround for a parsing problem. There | |
1803 | should be another level of INDIRECT_REF so that I don't have to do | |
1804 | this. */ | |
6467930b | 1805 | if (TREE_TYPE (t) != NULL_TREE && NEXT_CODE (t) == POINTER_TYPE) |
8d08fdba MS |
1806 | { |
1807 | tree next = TREE_TYPE (TREE_TYPE (t)); | |
1808 | ||
1809 | while (TREE_CODE (next) == POINTER_TYPE) | |
1810 | next = TREE_TYPE (next); | |
bb20cc46 | 1811 | |
8d08fdba MS |
1812 | if (TREE_CODE (next) == FUNCTION_TYPE) |
1813 | { | |
761f0855 | 1814 | if (flags & TFF_EXPR_IN_PARENS) |
99885b3f GDR |
1815 | print_left_paren (scratch_buffer); |
1816 | output_add_character (scratch_buffer, '*'); | |
761f0855 GDR |
1817 | dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); |
1818 | if (flags & TFF_EXPR_IN_PARENS) | |
99885b3f | 1819 | print_right_paren (scratch_buffer); |
8d08fdba MS |
1820 | break; |
1821 | } | |
1822 | /* else FALLTHRU */ | |
1823 | } | |
761f0855 | 1824 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
8d08fdba MS |
1825 | break; |
1826 | ||
1827 | case NOP_EXPR: | |
9e93bc9d | 1828 | dump_expr (TREE_OPERAND (t, 0), flags); |
8d08fdba MS |
1829 | break; |
1830 | ||
89c6e7ac MM |
1831 | case EXPR_WITH_FILE_LOCATION: |
1832 | dump_expr (EXPR_WFL_NODE (t), flags); | |
1833 | break; | |
1834 | ||
8d08fdba | 1835 | case CONSTRUCTOR: |
9a3b49ac MS |
1836 | if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t))) |
1837 | { | |
50ad9642 | 1838 | tree idx = build_ptrmemfunc_access_expr (t, pfn_identifier); |
9a3b49ac | 1839 | |
c4372ef4 | 1840 | if (integer_zerop (idx)) |
e08a8f45 MM |
1841 | { |
1842 | /* A NULL pointer-to-member constant. */ | |
99885b3f | 1843 | output_add_string (scratch_buffer, "(("); |
9e93bc9d | 1844 | dump_type (TREE_TYPE (t), flags); |
99885b3f | 1845 | output_add_string (scratch_buffer, ") 0)"); |
e08a8f45 MM |
1846 | break; |
1847 | } | |
665f2503 | 1848 | else if (host_integerp (idx, 0)) |
9a3b49ac MS |
1849 | { |
1850 | tree virtuals; | |
1851 | unsigned HOST_WIDE_INT n; | |
1852 | ||
1853 | t = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t))); | |
1854 | t = TYPE_METHOD_BASETYPE (t); | |
83f2ccf4 | 1855 | virtuals = TYPE_BINFO_VIRTUALS (TYPE_MAIN_VARIANT (t)); |
bb20cc46 | 1856 | |
1f84ec23 | 1857 | n = tree_low_cst (idx, 0); |
9a3b49ac MS |
1858 | |
1859 | /* Map vtable index back one, to allow for the null pointer to | |
1860 | member. */ | |
1861 | --n; | |
1862 | ||
1863 | while (n > 0 && virtuals) | |
1864 | { | |
1865 | --n; | |
1866 | virtuals = TREE_CHAIN (virtuals); | |
1867 | } | |
1868 | if (virtuals) | |
1869 | { | |
31f8e4f3 | 1870 | dump_expr (BV_FN (virtuals), |
761f0855 | 1871 | flags | TFF_EXPR_IN_PARENS); |
9a3b49ac MS |
1872 | break; |
1873 | } | |
1874 | } | |
1875 | } | |
99885b3f | 1876 | output_add_character (scratch_buffer, '{'); |
9e93bc9d | 1877 | dump_expr_list (CONSTRUCTOR_ELTS (t), flags); |
99885b3f | 1878 | output_add_character (scratch_buffer, '}'); |
8d08fdba MS |
1879 | break; |
1880 | ||
51c184be MS |
1881 | case OFFSET_REF: |
1882 | { | |
1883 | tree ob = TREE_OPERAND (t, 0); | |
51924768 | 1884 | if (is_dummy_object (ob)) |
61a127b3 | 1885 | { |
05e0b2f4 JM |
1886 | t = TREE_OPERAND (t, 1); |
1887 | if (TREE_CODE (t) == FUNCTION_DECL) | |
61a127b3 | 1888 | /* A::f */ |
761f0855 | 1889 | dump_expr (t, flags | TFF_EXPR_IN_PARENS); |
05e0b2f4 | 1890 | else if (BASELINK_P (t)) |
da15dae6 MM |
1891 | dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t)), |
1892 | flags | TFF_EXPR_IN_PARENS); | |
61a127b3 | 1893 | else |
9e93bc9d | 1894 | dump_decl (t, flags); |
61a127b3 | 1895 | } |
51c184be MS |
1896 | else |
1897 | { | |
bbcec105 JM |
1898 | if (TREE_CODE (ob) == INDIRECT_REF) |
1899 | { | |
761f0855 | 1900 | dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1901 | output_add_string (scratch_buffer, "->*"); |
bbcec105 JM |
1902 | } |
1903 | else | |
1904 | { | |
761f0855 | 1905 | dump_expr (ob, flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1906 | output_add_string (scratch_buffer, ".*"); |
bbcec105 | 1907 | } |
761f0855 | 1908 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
51c184be MS |
1909 | } |
1910 | break; | |
1911 | } | |
1912 | ||
f84b4be9 | 1913 | case TEMPLATE_PARM_INDEX: |
761f0855 | 1914 | dump_decl (TEMPLATE_PARM_DECL (t), flags & ~TFF_DECL_SPECIFIERS); |
de22184b | 1915 | break; |
5566b478 | 1916 | |
5566b478 | 1917 | case SCOPE_REF: |
9e93bc9d | 1918 | dump_type (TREE_OPERAND (t, 0), flags); |
99885b3f | 1919 | print_scope_operator (scratch_buffer); |
761f0855 | 1920 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
5566b478 MS |
1921 | break; |
1922 | ||
1923 | case CAST_EXPR: | |
e349ee73 MS |
1924 | if (TREE_OPERAND (t, 0) == NULL_TREE |
1925 | || TREE_CHAIN (TREE_OPERAND (t, 0))) | |
e76a2646 | 1926 | { |
9e93bc9d | 1927 | dump_type (TREE_TYPE (t), flags); |
99885b3f | 1928 | print_left_paren (scratch_buffer); |
9e93bc9d | 1929 | dump_expr_list (TREE_OPERAND (t, 0), flags); |
99885b3f | 1930 | print_right_paren (scratch_buffer); |
e76a2646 MS |
1931 | } |
1932 | else | |
1933 | { | |
99885b3f | 1934 | print_left_paren (scratch_buffer); |
9e93bc9d | 1935 | dump_type (TREE_TYPE (t), flags); |
99885b3f | 1936 | output_add_string (scratch_buffer, ")("); |
9e93bc9d | 1937 | dump_expr_list (TREE_OPERAND (t, 0), flags); |
99885b3f | 1938 | print_right_paren (scratch_buffer); |
e76a2646 MS |
1939 | } |
1940 | break; | |
1941 | ||
477f6664 JM |
1942 | case STATIC_CAST_EXPR: |
1943 | output_add_string (scratch_buffer, "static_cast<"); | |
1944 | goto cast; | |
1945 | case REINTERPRET_CAST_EXPR: | |
1946 | output_add_string (scratch_buffer, "reinterpret_cast<"); | |
1947 | goto cast; | |
1948 | case CONST_CAST_EXPR: | |
1949 | output_add_string (scratch_buffer, "const_cast<"); | |
1950 | goto cast; | |
1951 | case DYNAMIC_CAST_EXPR: | |
1952 | output_add_string (scratch_buffer, "dynamic_cast<"); | |
1953 | cast: | |
1954 | dump_type (TREE_TYPE (t), flags); | |
1955 | output_add_string (scratch_buffer, ">("); | |
1956 | dump_expr (TREE_OPERAND (t, 0), flags); | |
1957 | print_right_paren (scratch_buffer); | |
1958 | break; | |
1959 | ||
e76a2646 | 1960 | case LOOKUP_EXPR: |
99885b3f | 1961 | print_tree_identifier (scratch_buffer, TREE_OPERAND (t, 0)); |
e76a2646 MS |
1962 | break; |
1963 | ||
5a11e05b | 1964 | case ARROW_EXPR: |
9e93bc9d | 1965 | dump_expr (TREE_OPERAND (t, 0), flags); |
99885b3f | 1966 | output_add_string (scratch_buffer, "->"); |
5a11e05b BK |
1967 | break; |
1968 | ||
e76a2646 | 1969 | case SIZEOF_EXPR: |
abff8e06 JM |
1970 | case ALIGNOF_EXPR: |
1971 | if (TREE_CODE (t) == SIZEOF_EXPR) | |
99885b3f | 1972 | output_add_string (scratch_buffer, "sizeof ("); |
bb20cc46 | 1973 | else |
abff8e06 JM |
1974 | { |
1975 | my_friendly_assert (TREE_CODE (t) == ALIGNOF_EXPR, 0); | |
99885b3f | 1976 | output_add_string (scratch_buffer, "__alignof__ ("); |
abff8e06 | 1977 | } |
2f939d94 | 1978 | if (TYPE_P (TREE_OPERAND (t, 0))) |
9e93bc9d | 1979 | dump_type (TREE_OPERAND (t, 0), flags); |
e76a2646 | 1980 | else |
761f0855 | 1981 | dump_unary_op ("*", t, flags | TFF_EXPR_IN_PARENS); |
99885b3f | 1982 | print_right_paren (scratch_buffer); |
e76a2646 | 1983 | break; |
5566b478 | 1984 | |
da20811c | 1985 | case DEFAULT_ARG: |
99885b3f | 1986 | print_identifier (scratch_buffer, "<unparsed>"); |
da20811c JM |
1987 | break; |
1988 | ||
6748b643 JM |
1989 | case TRY_CATCH_EXPR: |
1990 | case WITH_CLEANUP_EXPR: | |
1991 | case CLEANUP_POINT_EXPR: | |
9e93bc9d | 1992 | dump_expr (TREE_OPERAND (t, 0), flags); |
6748b643 JM |
1993 | break; |
1994 | ||
40242ccf | 1995 | case PSEUDO_DTOR_EXPR: |
9e93bc9d | 1996 | dump_expr (TREE_OPERAND (t, 2), flags); |
99885b3f | 1997 | output_add_character (scratch_buffer, '.'); |
9e93bc9d | 1998 | dump_type (TREE_OPERAND (t, 0), flags); |
99885b3f | 1999 | output_add_string (scratch_buffer, "::~"); |
9e93bc9d | 2000 | dump_type (TREE_OPERAND (t, 1), flags); |
40242ccf MM |
2001 | break; |
2002 | ||
7ac7b28f | 2003 | case TEMPLATE_ID_EXPR: |
9e93bc9d | 2004 | dump_decl (t, flags); |
7ac7b28f MM |
2005 | break; |
2006 | ||
558475f0 MM |
2007 | case STMT_EXPR: |
2008 | /* We don't yet have a way of dumping statements in a | |
2009 | human-readable format. */ | |
99885b3f | 2010 | output_add_string (scratch_buffer, "({...})"); |
558475f0 MM |
2011 | break; |
2012 | ||
0045e0bc | 2013 | case BIND_EXPR: |
52a11cbf | 2014 | output_add_character (scratch_buffer, '{'); |
761f0855 | 2015 | dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS); |
99885b3f | 2016 | output_add_character (scratch_buffer, '}'); |
0045e0bc | 2017 | break; |
bb20cc46 | 2018 | |
0045e0bc | 2019 | case LOOP_EXPR: |
99885b3f | 2020 | output_add_string (scratch_buffer, "while (1) { "); |
761f0855 | 2021 | dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); |
99885b3f | 2022 | output_add_character (scratch_buffer, '}'); |
0045e0bc MM |
2023 | break; |
2024 | ||
2025 | case EXIT_EXPR: | |
99885b3f | 2026 | output_add_string (scratch_buffer, "if ("); |
761f0855 | 2027 | dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); |
99885b3f | 2028 | output_add_string (scratch_buffer, ") break; "); |
0045e0bc MM |
2029 | break; |
2030 | ||
a723baf1 MM |
2031 | case BASELINK: |
2032 | print_tree_identifier (scratch_buffer, DECL_NAME (get_first_fn (t))); | |
2033 | break; | |
2034 | ||
bb20cc46 | 2035 | /* else fall through */ |
00595019 | 2036 | |
8d08fdba MS |
2037 | /* This list is incomplete, but should suffice for now. |
2038 | It is very important that `sorry' does not call | |
2039 | `report_error_function'. That could cause an infinite loop. */ | |
2040 | default: | |
99885b3f | 2041 | sorry_for_unsupported_tree (t); |
8d08fdba MS |
2042 | /* fall through to ERROR_MARK... */ |
2043 | case ERROR_MARK: | |
99885b3f | 2044 | print_identifier (scratch_buffer, "<expression error>"); |
8d08fdba MS |
2045 | break; |
2046 | } | |
2047 | } | |
2048 | ||
2049 | static void | |
9e93bc9d | 2050 | dump_binary_op (opstring, t, flags) |
9c0758dd | 2051 | const char *opstring; |
8d08fdba | 2052 | tree t; |
761f0855 | 2053 | int flags; |
8d08fdba | 2054 | { |
99885b3f | 2055 | print_left_paren (scratch_buffer); |
761f0855 | 2056 | dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 2057 | output_add_space (scratch_buffer); |
2adeacc9 | 2058 | if (opstring) |
99885b3f | 2059 | print_identifier (scratch_buffer, opstring); |
2adeacc9 | 2060 | else |
99885b3f GDR |
2061 | print_identifier (scratch_buffer, "<unknown operator>"); |
2062 | output_add_space (scratch_buffer); | |
761f0855 | 2063 | dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); |
99885b3f | 2064 | print_right_paren (scratch_buffer); |
8d08fdba MS |
2065 | } |
2066 | ||
2067 | static void | |
9e93bc9d | 2068 | dump_unary_op (opstring, t, flags) |
9c0758dd | 2069 | const char *opstring; |
8d08fdba | 2070 | tree t; |
761f0855 | 2071 | int flags; |
8d08fdba | 2072 | { |
761f0855 | 2073 | if (flags & TFF_EXPR_IN_PARENS) |
99885b3f GDR |
2074 | print_left_paren (scratch_buffer); |
2075 | print_identifier (scratch_buffer, opstring); | |
761f0855 GDR |
2076 | dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS); |
2077 | if (flags & TFF_EXPR_IN_PARENS) | |
99885b3f | 2078 | print_right_paren (scratch_buffer); |
8d08fdba MS |
2079 | } |
2080 | ||
761f0855 | 2081 | /* Exported interface to stringifying types, exprs and decls under TFF_* |
9e93bc9d | 2082 | control. */ |
4995028c | 2083 | |
e1def31b | 2084 | const char * |
9e93bc9d NS |
2085 | type_as_string (typ, flags) |
2086 | tree typ; | |
761f0855 | 2087 | int flags; |
8d08fdba | 2088 | { |
99885b3f | 2089 | reinit_global_formatting_buffer (); |
4995028c | 2090 | |
9e93bc9d NS |
2091 | dump_type (typ, flags); |
2092 | ||
99885b3f | 2093 | return output_finalize_message (scratch_buffer); |
8d08fdba MS |
2094 | } |
2095 | ||
e1def31b | 2096 | const char * |
9e93bc9d NS |
2097 | expr_as_string (decl, flags) |
2098 | tree decl; | |
761f0855 | 2099 | int flags; |
8d08fdba | 2100 | { |
99885b3f | 2101 | reinit_global_formatting_buffer (); |
8d08fdba | 2102 | |
9e93bc9d | 2103 | dump_expr (decl, flags); |
8d08fdba | 2104 | |
99885b3f | 2105 | return output_finalize_message (scratch_buffer); |
8d08fdba MS |
2106 | } |
2107 | ||
e1def31b | 2108 | const char * |
9e93bc9d | 2109 | decl_as_string (decl, flags) |
8d08fdba | 2110 | tree decl; |
761f0855 | 2111 | int flags; |
8d08fdba | 2112 | { |
99885b3f | 2113 | reinit_global_formatting_buffer (); |
8d08fdba | 2114 | |
9e93bc9d | 2115 | dump_decl (decl, flags); |
8d08fdba | 2116 | |
99885b3f | 2117 | return output_finalize_message (scratch_buffer); |
8d08fdba MS |
2118 | } |
2119 | ||
e1def31b | 2120 | const char * |
9e93bc9d NS |
2121 | context_as_string (context, flags) |
2122 | tree context; | |
761f0855 | 2123 | int flags; |
8d08fdba | 2124 | { |
99885b3f | 2125 | reinit_global_formatting_buffer (); |
bb20cc46 | 2126 | |
9e93bc9d | 2127 | dump_scope (context, flags); |
bb20cc46 | 2128 | |
99885b3f | 2129 | return output_finalize_message (scratch_buffer); |
8d08fdba MS |
2130 | } |
2131 | ||
7afff7cf | 2132 | /* Generate the three forms of printable names for cxx_printable_name. */ |
2ba25f50 | 2133 | |
e1def31b | 2134 | const char * |
2ba25f50 MS |
2135 | lang_decl_name (decl, v) |
2136 | tree decl; | |
2137 | int v; | |
2138 | { | |
2139 | if (v >= 2) | |
761f0855 | 2140 | return decl_as_string (decl, TFF_DECL_SPECIFIERS); |
2ba25f50 | 2141 | |
99885b3f | 2142 | reinit_global_formatting_buffer (); |
2ba25f50 | 2143 | |
6eb3bb27 | 2144 | if (v == 1 && DECL_CLASS_SCOPE_P (decl)) |
2ba25f50 | 2145 | { |
761f0855 | 2146 | dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER); |
99885b3f | 2147 | print_scope_operator (scratch_buffer); |
2ba25f50 MS |
2148 | } |
2149 | ||
2150 | if (TREE_CODE (decl) == FUNCTION_DECL) | |
761f0855 | 2151 | dump_function_name (decl, TFF_PLAIN_IDENTIFIER); |
2ba25f50 | 2152 | else |
761f0855 | 2153 | dump_decl (DECL_NAME (decl), TFF_PLAIN_IDENTIFIER); |
2ba25f50 | 2154 | |
99885b3f | 2155 | return output_finalize_message (scratch_buffer); |
2ba25f50 | 2156 | } |
2ba25f50 | 2157 | |
e1def31b | 2158 | const char * |
8d08fdba MS |
2159 | cp_file_of (t) |
2160 | tree t; | |
2161 | { | |
741f2839 | 2162 | if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) |
8d08fdba | 2163 | return DECL_SOURCE_FILE (DECL_CONTEXT (t)); |
2f939d94 | 2164 | else if (TYPE_P (t)) |
d2e5ee5c | 2165 | return DECL_SOURCE_FILE (TYPE_MAIN_DECL (t)); |
8f032717 MM |
2166 | else if (TREE_CODE (t) == OVERLOAD) |
2167 | return DECL_SOURCE_FILE (OVL_FUNCTION (t)); | |
8d08fdba MS |
2168 | else |
2169 | return DECL_SOURCE_FILE (t); | |
2170 | } | |
2171 | ||
2172 | int | |
2173 | cp_line_of (t) | |
2174 | tree t; | |
2175 | { | |
f376e137 | 2176 | int line = 0; |
741f2839 | 2177 | if (TREE_CODE (t) == PARM_DECL && DECL_CONTEXT (t)) |
f376e137 | 2178 | line = DECL_SOURCE_LINE (DECL_CONTEXT (t)); |
f3400fe2 JM |
2179 | if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t) |
2180 | && TYPE_MAIN_DECL (TREE_TYPE (t))) | |
f376e137 MS |
2181 | t = TREE_TYPE (t); |
2182 | ||
2f939d94 | 2183 | if (TYPE_P (t)) |
d2e5ee5c | 2184 | line = DECL_SOURCE_LINE (TYPE_MAIN_DECL (t)); |
8f032717 MM |
2185 | else if (TREE_CODE (t) == OVERLOAD) |
2186 | line = DECL_SOURCE_LINE (OVL_FUNCTION (t)); | |
8d08fdba | 2187 | else |
f376e137 MS |
2188 | line = DECL_SOURCE_LINE (t); |
2189 | ||
2190 | if (line == 0) | |
2191 | return lineno; | |
2192 | ||
2193 | return line; | |
8d08fdba MS |
2194 | } |
2195 | ||
33bd39a2 | 2196 | /* Now the interfaces from error et al to dump_type et al. Each takes an |
761f0855 | 2197 | on/off VERBOSE flag and supply the appropriate TFF_ flags to a dump_ |
9e93bc9d NS |
2198 | function. */ |
2199 | ||
2200 | static const char * | |
2201 | decl_to_string (decl, verbose) | |
2202 | tree decl; | |
2203 | int verbose; | |
2204 | { | |
761f0855 | 2205 | int flags = 0; |
d67cdbc3 | 2206 | |
9e93bc9d NS |
2207 | if (TREE_CODE (decl) == TYPE_DECL || TREE_CODE (decl) == RECORD_TYPE |
2208 | || TREE_CODE (decl) == UNION_TYPE || TREE_CODE (decl) == ENUMERAL_TYPE) | |
761f0855 | 2209 | flags = TFF_CLASS_KEY_OR_ENUM; |
9e93bc9d | 2210 | if (verbose) |
761f0855 | 2211 | flags |= TFF_DECL_SPECIFIERS | TFF_FUNCTION_DEFAULT_ARGUMENTS; |
9e93bc9d | 2212 | else if (TREE_CODE (decl) == FUNCTION_DECL) |
761f0855 GDR |
2213 | flags |= TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE; |
2214 | flags |= TFF_TEMPLATE_HEADER; | |
bb20cc46 | 2215 | |
99885b3f | 2216 | reinit_global_formatting_buffer (); |
9e93bc9d NS |
2217 | |
2218 | dump_decl (decl, flags); | |
2219 | ||
99885b3f | 2220 | return output_finalize_message (scratch_buffer); |
9e93bc9d NS |
2221 | } |
2222 | ||
2223 | static const char * | |
2224 | expr_to_string (decl, verbose) | |
2225 | tree decl; | |
2226 | int verbose ATTRIBUTE_UNUSED; | |
2227 | { | |
99885b3f | 2228 | reinit_global_formatting_buffer (); |
9e93bc9d NS |
2229 | |
2230 | dump_expr (decl, 0); | |
2231 | ||
99885b3f | 2232 | return output_finalize_message (scratch_buffer); |
9e93bc9d NS |
2233 | } |
2234 | ||
2235 | static const char * | |
2236 | fndecl_to_string (fndecl, verbose) | |
2237 | tree fndecl; | |
2238 | int verbose; | |
2239 | { | |
761f0855 | 2240 | int flags; |
bb20cc46 | 2241 | |
761f0855 | 2242 | flags = TFF_EXCEPTION_SPECIFICATION | TFF_DECL_SPECIFIERS; |
9e93bc9d | 2243 | if (verbose) |
761f0855 | 2244 | flags |= TFF_FUNCTION_DEFAULT_ARGUMENTS; |
99885b3f | 2245 | reinit_global_formatting_buffer (); |
9e93bc9d NS |
2246 | |
2247 | dump_decl (fndecl, flags); | |
bb20cc46 | 2248 | |
99885b3f | 2249 | return output_finalize_message (scratch_buffer); |
9e93bc9d NS |
2250 | } |
2251 | ||
2252 | ||
2253 | static const char * | |
2254 | code_to_string (c, v) | |
8d08fdba | 2255 | enum tree_code c; |
7dee3f36 | 2256 | int v ATTRIBUTE_UNUSED; |
8d08fdba MS |
2257 | { |
2258 | return tree_code_name [c]; | |
2259 | } | |
2260 | ||
421844e7 | 2261 | const char * |
9e93bc9d | 2262 | language_to_string (c, v) |
8d08fdba | 2263 | enum languages c; |
7dee3f36 | 2264 | int v ATTRIBUTE_UNUSED; |
8d08fdba MS |
2265 | { |
2266 | switch (c) | |
2267 | { | |
2268 | case lang_c: | |
2269 | return "C"; | |
2270 | ||
2271 | case lang_cplusplus: | |
2272 | return "C++"; | |
2273 | ||
31b72b87 PB |
2274 | case lang_java: |
2275 | return "Java"; | |
2276 | ||
8d08fdba | 2277 | default: |
a98facb0 | 2278 | abort (); |
8926095f | 2279 | return 0; |
8d08fdba MS |
2280 | } |
2281 | } | |
2282 | ||
2283 | /* Return the proper printed version of a parameter to a C++ function. */ | |
e92cc029 | 2284 | |
9e93bc9d NS |
2285 | static const char * |
2286 | parm_to_string (p, v) | |
7dee3f36 KG |
2287 | int p; |
2288 | int v ATTRIBUTE_UNUSED; | |
8d08fdba MS |
2289 | { |
2290 | if (p < 0) | |
2291 | return "`this'"; | |
2292 | ||
2293 | sprintf (digit_buffer, "%d", p+1); | |
2294 | return digit_buffer; | |
2295 | } | |
2296 | ||
9e93bc9d NS |
2297 | static const char * |
2298 | op_to_string (p, v) | |
8d08fdba | 2299 | enum tree_code p; |
7dee3f36 | 2300 | int v ATTRIBUTE_UNUSED; |
8d08fdba | 2301 | { |
596ea4e5 | 2302 | tree id; |
8d08fdba | 2303 | |
596ea4e5 AS |
2304 | id = operator_name_info[(int) p].identifier; |
2305 | return id ? IDENTIFIER_POINTER (id) : "{unknown}"; | |
8d08fdba MS |
2306 | } |
2307 | ||
9e93bc9d NS |
2308 | static const char * |
2309 | type_to_string (typ, verbose) | |
2310 | tree typ; | |
2311 | int verbose; | |
2312 | { | |
761f0855 | 2313 | int flags; |
bb20cc46 | 2314 | |
9e93bc9d NS |
2315 | flags = 0; |
2316 | if (verbose) | |
761f0855 GDR |
2317 | flags |= TFF_CLASS_KEY_OR_ENUM; |
2318 | flags |= TFF_TEMPLATE_HEADER; | |
bb20cc46 | 2319 | |
99885b3f | 2320 | reinit_global_formatting_buffer (); |
9e93bc9d NS |
2321 | |
2322 | dump_type (typ, flags); | |
2323 | ||
99885b3f | 2324 | return output_finalize_message (scratch_buffer); |
9e93bc9d NS |
2325 | } |
2326 | ||
2327 | static const char * | |
2328 | assop_to_string (p, v) | |
c91a56d2 | 2329 | enum tree_code p; |
7dee3f36 | 2330 | int v ATTRIBUTE_UNUSED; |
c91a56d2 | 2331 | { |
596ea4e5 | 2332 | tree id; |
c91a56d2 | 2333 | |
596ea4e5 AS |
2334 | id = assignment_operator_name_info[(int) p].identifier; |
2335 | return id ? IDENTIFIER_POINTER (id) : "{unknown}"; | |
c91a56d2 MS |
2336 | } |
2337 | ||
9e93bc9d NS |
2338 | static const char * |
2339 | args_to_string (p, verbose) | |
8d08fdba | 2340 | tree p; |
9e93bc9d | 2341 | int verbose; |
8d08fdba | 2342 | { |
761f0855 | 2343 | int flags = 0; |
9e93bc9d | 2344 | if (verbose) |
761f0855 | 2345 | flags |= TFF_CLASS_KEY_OR_ENUM; |
bb20cc46 | 2346 | |
8d08fdba | 2347 | if (p == NULL_TREE) |
c73964b2 | 2348 | return ""; |
8d08fdba | 2349 | |
2f939d94 | 2350 | if (TYPE_P (TREE_VALUE (p))) |
9e93bc9d | 2351 | return type_as_string (p, flags); |
c73964b2 | 2352 | |
99885b3f | 2353 | reinit_global_formatting_buffer (); |
c73964b2 MS |
2354 | for (; p; p = TREE_CHAIN (p)) |
2355 | { | |
a6967cc0 | 2356 | if (TREE_VALUE (p) == null_node) |
99885b3f | 2357 | print_identifier (scratch_buffer, "NULL"); |
a6967cc0 | 2358 | else |
9e93bc9d | 2359 | dump_type (error_type (TREE_VALUE (p)), flags); |
c73964b2 | 2360 | if (TREE_CHAIN (p)) |
99885b3f | 2361 | separate_with_comma (scratch_buffer); |
c73964b2 | 2362 | } |
99885b3f | 2363 | return output_finalize_message (scratch_buffer); |
8d08fdba | 2364 | } |
f30432d7 | 2365 | |
9e93bc9d NS |
2366 | static const char * |
2367 | cv_to_string (p, v) | |
f30432d7 | 2368 | tree p; |
ea50ad82 | 2369 | int v; |
f30432d7 | 2370 | { |
99885b3f | 2371 | reinit_global_formatting_buffer (); |
f30432d7 | 2372 | |
ea50ad82 | 2373 | dump_qualifiers (p, v ? before : none); |
f30432d7 | 2374 | |
99885b3f | 2375 | return output_finalize_message (scratch_buffer); |
f30432d7 | 2376 | } |
cb753e49 | 2377 | |
7cb32822 NB |
2378 | /* Langhook for print_error_function. */ |
2379 | void | |
2380 | cxx_print_error_function (context, file) | |
46f018e1 | 2381 | diagnostic_context *context; |
a72462a4 GDR |
2382 | const char *file; |
2383 | { | |
7cb32822 | 2384 | lhd_print_error_function (context, file); |
47b69537 GDR |
2385 | output_set_prefix (&context->buffer, file); |
2386 | maybe_print_instantiation_context (context); | |
a72462a4 GDR |
2387 | } |
2388 | ||
cb753e49 | 2389 | static void |
47b69537 GDR |
2390 | cp_diagnostic_starter (context, diagnostic) |
2391 | diagnostic_context *context; | |
2392 | diagnostic_info *diagnostic; | |
cb753e49 | 2393 | { |
47b69537 GDR |
2394 | diagnostic_report_current_module (context); |
2395 | cp_print_error_function (context, diagnostic); | |
2396 | maybe_print_instantiation_context (context); | |
2397 | output_set_prefix (&context->buffer, diagnostic_build_prefix (diagnostic)); | |
cb753e49 GDR |
2398 | } |
2399 | ||
2400 | static void | |
47b69537 GDR |
2401 | cp_diagnostic_finalizer (context, diagnostic) |
2402 | diagnostic_context *context; | |
2403 | diagnostic_info *diagnostic __attribute__((unused)); | |
cb753e49 | 2404 | { |
47b69537 | 2405 | output_destroy_prefix (&context->buffer); |
cb753e49 GDR |
2406 | } |
2407 | ||
2408 | /* Print current function onto BUFFER, in the process of reporting | |
2409 | a diagnostic message. Called from cp_diagnostic_starter. */ | |
2410 | static void | |
47b69537 GDR |
2411 | cp_print_error_function (context, diagnostic) |
2412 | diagnostic_context *context; | |
2413 | diagnostic_info *diagnostic; | |
cb753e49 | 2414 | { |
47b69537 | 2415 | if (diagnostic_last_function_changed (context)) |
cb753e49 | 2416 | { |
47b69537 GDR |
2417 | const char *old_prefix = output_prefix (&context->buffer); |
2418 | char *new_prefix = diagnostic->location.file | |
2419 | ? file_name_as_prefix (diagnostic->location.file) | |
cb753e49 | 2420 | : NULL; |
cb753e49 | 2421 | |
47b69537 | 2422 | output_set_prefix (&context->buffer, new_prefix); |
bb20cc46 | 2423 | |
cb753e49 | 2424 | if (current_function_decl == NULL) |
47b69537 | 2425 | output_add_string (&context->buffer, "At global scope:"); |
cb753e49 | 2426 | else |
47b69537 GDR |
2427 | output_printf (&context->buffer, "In %s `%s':", |
2428 | function_category (current_function_decl), | |
2429 | cxx_printable_name (current_function_decl, 2)); | |
2430 | output_add_newline (&context->buffer); | |
2431 | ||
2432 | diagnostic_set_last_function (context); | |
2433 | output_destroy_prefix (&context->buffer); | |
2434 | context->buffer.state.prefix = old_prefix; | |
cb753e49 GDR |
2435 | } |
2436 | } | |
2437 | ||
2438 | /* Returns a description of FUNCTION using standard terminology. */ | |
2439 | static const char * | |
2440 | function_category (fn) | |
2441 | tree fn; | |
2442 | { | |
2443 | if (DECL_FUNCTION_MEMBER_P (fn)) | |
2444 | { | |
2445 | if (DECL_STATIC_FUNCTION_P (fn)) | |
2446 | return "static member function"; | |
2447 | else if (DECL_COPY_CONSTRUCTOR_P (fn)) | |
2448 | return "copy constructor"; | |
2449 | else if (DECL_CONSTRUCTOR_P (fn)) | |
2450 | return "constructor"; | |
2451 | else if (DECL_DESTRUCTOR_P (fn)) | |
2452 | return "destructor"; | |
2453 | else | |
2454 | return "member function"; | |
2455 | } | |
2456 | else | |
2457 | return "function"; | |
2458 | } | |
2459 | ||
2460 | /* Report the full context of a current template instantiation, | |
2461 | onto BUFFER. */ | |
2462 | static void | |
47b69537 GDR |
2463 | print_instantiation_full_context (context) |
2464 | diagnostic_context *context; | |
cb753e49 GDR |
2465 | { |
2466 | tree p = current_instantiation (); | |
2467 | int line = lineno; | |
2468 | const char *file = input_filename; | |
2469 | ||
2470 | if (p) | |
2471 | { | |
2472 | if (current_function_decl != TINST_DECL (p) | |
2473 | && current_function_decl != NULL_TREE) | |
2474 | /* We can get here during the processing of some synthesized | |
2475 | method. Then, TINST_DECL (p) will be the function that's causing | |
2476 | the synthesis. */ | |
2477 | ; | |
2478 | else | |
2479 | { | |
2480 | if (current_function_decl == TINST_DECL (p)) | |
2481 | /* Avoid redundancy with the the "In function" line. */; | |
bb20cc46 | 2482 | else |
47b69537 GDR |
2483 | output_verbatim (&context->buffer, |
2484 | "%s: In instantiation of `%s':\n", file, | |
cb753e49 | 2485 | decl_as_string (TINST_DECL (p), |
761f0855 | 2486 | TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); |
bb20cc46 | 2487 | |
cb753e49 GDR |
2488 | line = TINST_LINE (p); |
2489 | file = TINST_FILE (p); | |
2490 | p = TREE_CHAIN (p); | |
2491 | } | |
2492 | } | |
bb20cc46 | 2493 | |
47b69537 | 2494 | print_instantiation_partial_context (context, p, file, line); |
cb753e49 GDR |
2495 | } |
2496 | ||
2497 | /* Same as above but less verbose. */ | |
2498 | static void | |
47b69537 GDR |
2499 | print_instantiation_partial_context (context, t, file, line) |
2500 | diagnostic_context *context; | |
cb753e49 GDR |
2501 | tree t; |
2502 | const char *file; | |
2503 | int line; | |
2504 | { | |
2505 | for (; t; t = TREE_CHAIN (t)) | |
2506 | { | |
2507 | output_verbatim | |
47b69537 | 2508 | (&context->buffer, "%s:%d: instantiated from `%s'\n", file, line, |
761f0855 | 2509 | decl_as_string (TINST_DECL (t), TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); |
cb753e49 GDR |
2510 | line = TINST_LINE (t); |
2511 | file = TINST_FILE (t); | |
2512 | } | |
47b69537 | 2513 | output_verbatim (&context->buffer, "%s:%d: instantiated from here\n", file, line); |
cb753e49 GDR |
2514 | } |
2515 | ||
2516 | /* Called from cp_thing to print the template context for an error. */ | |
2517 | static void | |
47b69537 GDR |
2518 | maybe_print_instantiation_context (context) |
2519 | diagnostic_context *context; | |
cb753e49 GDR |
2520 | { |
2521 | if (!problematic_instantiation_changed () || current_instantiation () == 0) | |
2522 | return; | |
2523 | ||
2524 | record_last_problematic_instantiation (); | |
47b69537 | 2525 | print_instantiation_full_context (context); |
cb753e49 GDR |
2526 | } |
2527 | ||
2528 | /* Report the bare minimum context of a template instantiation. */ | |
2529 | void | |
2530 | print_instantiation_context () | |
2531 | { | |
2532 | print_instantiation_partial_context | |
47b69537 GDR |
2533 | (global_dc, current_instantiation (), input_filename, lineno); |
2534 | diagnostic_flush_buffer (global_dc); | |
cb753e49 | 2535 | } |
a1066c99 GDR |
2536 | \f |
2537 | /* Called from output_format -- during diagnostic message processing -- | |
2538 | to handle C++ specific format specifier with the following meanings: | |
2539 | %A function argument-list. | |
749ced52 | 2540 | %C tree code. |
a1066c99 GDR |
2541 | %D declaration. |
2542 | %E expression. | |
2543 | %F function declaration. | |
749ced52 ZW |
2544 | %L language as used in extern "lang". |
2545 | %O binary operator. | |
a1066c99 | 2546 | %P function parameter whose position is indicated by an integer. |
749ced52 | 2547 | %Q assignment operator. |
a1066c99 GDR |
2548 | %T type. |
2549 | %V cv-qualifier. */ | |
47b69537 GDR |
2550 | static bool |
2551 | cp_printer (buffer, text) | |
a1066c99 | 2552 | output_buffer *buffer; |
47b69537 | 2553 | text_info *text; |
a1066c99 | 2554 | { |
749ced52 ZW |
2555 | int verbose = 0; |
2556 | const char *result; | |
47b69537 GDR |
2557 | #define next_tree va_arg (*text->args_ptr, tree) |
2558 | #define next_tcode va_arg (*text->args_ptr, enum tree_code) | |
2559 | #define next_lang va_arg (*text->args_ptr, enum languages) | |
2560 | #define next_int va_arg (*text->args_ptr, int) | |
2561 | ||
2562 | if (*text->format_spec == '+') | |
2563 | ++text->format_spec; | |
2564 | if (*text->format_spec == '#') | |
a1066c99 | 2565 | { |
749ced52 | 2566 | verbose = 1; |
47b69537 | 2567 | ++text->format_spec; |
a1066c99 GDR |
2568 | } |
2569 | ||
47b69537 | 2570 | switch (*text->format_spec) |
22a4158c | 2571 | { |
749ced52 ZW |
2572 | case 'A': result = args_to_string (next_tree, verbose); break; |
2573 | case 'C': result = code_to_string (next_tcode, verbose); break; | |
2574 | case 'D': result = decl_to_string (next_tree, verbose); break; | |
2575 | case 'E': result = expr_to_string (next_tree, verbose); break; | |
2576 | case 'F': result = fndecl_to_string (next_tree, verbose); break; | |
2577 | case 'L': result = language_to_string (next_lang, verbose); break; | |
2578 | case 'O': result = op_to_string (next_tcode, verbose); break; | |
2579 | case 'P': result = parm_to_string (next_int, verbose); break; | |
2580 | case 'Q': result = assop_to_string (next_tcode, verbose); break; | |
2581 | case 'T': result = type_to_string (next_tree, verbose); break; | |
2582 | case 'V': result = cv_to_string (next_tree, verbose); break; | |
2583 | ||
22a4158c | 2584 | default: |
47b69537 | 2585 | return false; |
a1066c99 | 2586 | } |
bb20cc46 | 2587 | |
749ced52 | 2588 | output_add_string (buffer, result); |
47b69537 | 2589 | return true; |
749ced52 ZW |
2590 | #undef next_tree |
2591 | #undef next_tcode | |
2592 | #undef next_lang | |
2593 | #undef next_int | |
a1066c99 GDR |
2594 | } |
2595 | ||
99885b3f GDR |
2596 | static void |
2597 | print_integer (buffer, i) | |
2598 | output_buffer *buffer; | |
2599 | HOST_WIDE_INT i; | |
2600 | { | |
2601 | sprintf (digit_buffer, HOST_WIDE_INT_PRINT_DEC, (HOST_WIDE_INT) i); | |
2602 | output_add_string (buffer, digit_buffer); | |
2603 | } | |
2604 | ||
a1066c99 | 2605 | static void |
749ced52 | 2606 | print_non_consecutive_character (buffer, c) |
c3e76028 | 2607 | output_buffer *buffer; |
749ced52 | 2608 | int c; |
c3e76028 | 2609 | { |
749ced52 | 2610 | const char *p = output_last_position (buffer); |
c3e76028 | 2611 | |
749ced52 ZW |
2612 | if (p != NULL && *p == c) |
2613 | output_add_space (buffer); | |
2614 | output_add_character (buffer, c); | |
c3e76028 GDR |
2615 | } |
2616 | ||
749ced52 ZW |
2617 | /* These are temporary wrapper functions which handle the historic |
2618 | behavior of cp_*_at. */ | |
c3e76028 | 2619 | |
749ced52 ZW |
2620 | static tree |
2621 | locate_error (msgid, ap) | |
2622 | const char *msgid; | |
2623 | va_list ap; | |
c3e76028 | 2624 | { |
749ced52 ZW |
2625 | tree here = 0, t; |
2626 | int plus = 0; | |
2627 | const char *f; | |
c3e76028 | 2628 | |
749ced52 | 2629 | for (f = msgid; *f; f++) |
c3e76028 | 2630 | { |
749ced52 ZW |
2631 | plus = 0; |
2632 | if (*f == '%') | |
2633 | { | |
2634 | f++; | |
2635 | if (*f == '+') | |
2636 | f++, plus = 1; | |
2637 | if (*f == '#') | |
2638 | f++; | |
c3e76028 | 2639 | |
749ced52 ZW |
2640 | switch (*f) |
2641 | { | |
2642 | /* Just ignore these possibilities. */ | |
2643 | case '%': break; | |
2644 | case 'd': (void) va_arg (ap, int); break; | |
2645 | case 's': (void) va_arg (ap, char *); break; | |
2646 | case 'L': (void) va_arg (ap, enum languages); break; | |
2647 | case 'C': | |
2648 | case 'O': | |
2649 | case 'Q': (void) va_arg (ap, enum tree_code); break; | |
2650 | ||
2651 | /* These take a tree, which may be where the error is | |
2652 | located. */ | |
2653 | case 'A': | |
2654 | case 'D': | |
2655 | case 'E': | |
2656 | case 'F': | |
2657 | case 'P': | |
2658 | case 'T': | |
2659 | case 'V': | |
2660 | t = va_arg (ap, tree); | |
2661 | if (!here || plus) | |
2662 | here = t; | |
2663 | break; | |
c3e76028 | 2664 | |
749ced52 ZW |
2665 | default: |
2666 | errorcount = 0; /* damn ICE suppression */ | |
2667 | internal_error ("unexpected letter `%c' in locate_error\n", *f); | |
2668 | } | |
2669 | } | |
c3e76028 GDR |
2670 | } |
2671 | ||
749ced52 ZW |
2672 | if (here == 0) |
2673 | here = va_arg (ap, tree); | |
c3e76028 | 2674 | |
749ced52 | 2675 | return here; |
c3e76028 GDR |
2676 | } |
2677 | ||
c3e76028 | 2678 | |
749ced52 ZW |
2679 | void |
2680 | cp_error_at VPARAMS ((const char *msgid, ...)) | |
a1066c99 | 2681 | { |
749ced52 | 2682 | tree here; |
47b69537 | 2683 | diagnostic_info diagnostic; |
bb20cc46 | 2684 | |
749ced52 ZW |
2685 | VA_OPEN (ap, msgid); |
2686 | VA_FIXEDARG (ap, const char *, msgid); | |
2687 | here = locate_error (msgid, ap); | |
2688 | VA_CLOSE (ap); | |
c3e76028 | 2689 | |
749ced52 ZW |
2690 | VA_OPEN (ap, msgid); |
2691 | VA_FIXEDARG (ap, const char *, msgid); | |
c3e76028 | 2692 | |
47b69537 | 2693 | diagnostic_set_info (&diagnostic, msgid, &ap, |
3cb8660c | 2694 | cp_file_of (here), cp_line_of (here), DK_ERROR); |
47b69537 | 2695 | report_diagnostic (&diagnostic); |
749ced52 | 2696 | VA_CLOSE (ap); |
c3e76028 GDR |
2697 | } |
2698 | ||
749ced52 ZW |
2699 | void |
2700 | cp_warning_at VPARAMS ((const char *msgid, ...)) | |
c3e76028 | 2701 | { |
749ced52 | 2702 | tree here; |
47b69537 | 2703 | diagnostic_info diagnostic; |
c3e76028 | 2704 | |
749ced52 ZW |
2705 | VA_OPEN (ap, msgid); |
2706 | VA_FIXEDARG (ap, const char *, msgid); | |
2707 | here = locate_error (msgid, ap); | |
2708 | VA_CLOSE (ap); | |
c3e76028 | 2709 | |
749ced52 ZW |
2710 | VA_OPEN (ap, msgid); |
2711 | VA_FIXEDARG (ap, const char *, msgid); | |
c3e76028 | 2712 | |
47b69537 GDR |
2713 | diagnostic_set_info (&diagnostic, msgid, &ap, |
2714 | cp_file_of (here), cp_line_of (here), DK_WARNING); | |
2715 | report_diagnostic (&diagnostic); | |
749ced52 | 2716 | VA_CLOSE (ap); |
c3e76028 GDR |
2717 | } |
2718 | ||
749ced52 ZW |
2719 | void |
2720 | cp_pedwarn_at VPARAMS ((const char *msgid, ...)) | |
c3e76028 | 2721 | { |
749ced52 | 2722 | tree here; |
47b69537 | 2723 | diagnostic_info diagnostic; |
c3e76028 | 2724 | |
749ced52 ZW |
2725 | VA_OPEN (ap, msgid); |
2726 | VA_FIXEDARG (ap, const char *, msgid); | |
2727 | here = locate_error (msgid, ap); | |
2728 | VA_CLOSE (ap); | |
c3e76028 | 2729 | |
749ced52 ZW |
2730 | VA_OPEN (ap, msgid); |
2731 | VA_FIXEDARG (ap, const char *, msgid); | |
c3e76028 | 2732 | |
47b69537 GDR |
2733 | diagnostic_set_info (&diagnostic, msgid, &ap, |
2734 | cp_file_of (here), cp_line_of (here), | |
2735 | pedantic_error_kind()); | |
2736 | report_diagnostic (&diagnostic); | |
749ced52 | 2737 | VA_CLOSE (ap); |
c3e76028 | 2738 | } |