]>
Commit | Line | Data |
---|---|---|
e1a4dd13 | 1 | /* Implementation of subroutines for the GNU C++ pretty-printer. |
2f990c80 | 2 | Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
e1a4dd13 GDR |
3 | Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> |
4 | ||
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING. If not, write to the Free | |
1788952f KC |
19 | Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA |
20 | 02110-1301, USA. */ | |
e1a4dd13 GDR |
21 | |
22 | #include "config.h" | |
23 | #include "system.h" | |
24 | #include "coretypes.h" | |
25 | #include "tm.h" | |
26 | #include "real.h" | |
27 | #include "cxx-pretty-print.h" | |
28 | #include "cp-tree.h" | |
12ea3302 | 29 | #include "toplev.h" |
4b780675 GDR |
30 | |
31 | static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree); | |
12ea3302 | 32 | static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree); |
4b780675 GDR |
33 | static void pp_cxx_qualified_id (cxx_pretty_printer *, tree); |
34 | static void pp_cxx_assignment_expression (cxx_pretty_printer *, tree); | |
12ea3302 | 35 | static void pp_cxx_expression (cxx_pretty_printer *, tree); |
4b780675 | 36 | static void pp_cxx_template_argument_list (cxx_pretty_printer *, tree); |
12ea3302 GDR |
37 | static void pp_cxx_type_specifier_seq (cxx_pretty_printer *, tree); |
38 | static void pp_cxx_ptr_operator (cxx_pretty_printer *, tree); | |
39 | static void pp_cxx_type_id (cxx_pretty_printer *, tree); | |
40 | static void pp_cxx_direct_abstract_declarator (cxx_pretty_printer *, tree); | |
41 | static void pp_cxx_declarator (cxx_pretty_printer *, tree); | |
7090f4b3 | 42 | static void pp_cxx_parameter_declaration_clause (cxx_pretty_printer *, tree); |
12ea3302 | 43 | static void pp_cxx_abstract_declarator (cxx_pretty_printer *, tree); |
b01150a2 | 44 | static void pp_cxx_statement (cxx_pretty_printer *, tree); |
12ea3302 | 45 | static void pp_cxx_template_parameter (cxx_pretty_printer *, tree); |
392e3d51 | 46 | static void pp_cxx_cast_expression (cxx_pretty_printer *, tree); |
e1a4dd13 | 47 | \f |
4b780675 GDR |
48 | |
49 | static inline void | |
50 | pp_cxx_nonconsecutive_character (cxx_pretty_printer *pp, int c) | |
51 | { | |
52 | const char *p = pp_last_position_in_text (pp); | |
53 | ||
54 | if (p != NULL && *p == c) | |
12ea3302 | 55 | pp_cxx_whitespace (pp); |
4b780675 | 56 | pp_character (pp, c); |
12ea3302 | 57 | pp_base (pp)->padding = pp_none; |
4b780675 GDR |
58 | } |
59 | ||
12ea3302 GDR |
60 | #define pp_cxx_storage_class_specifier(PP, T) \ |
61 | pp_c_storage_class_specifier (pp_c_base (PP), T) | |
62 | #define pp_cxx_expression_list(PP, T) \ | |
63 | pp_c_expression_list (pp_c_base (PP), T) | |
64 | #define pp_cxx_space_for_pointer_operator(PP, T) \ | |
65 | pp_c_space_for_pointer_operator (pp_c_base (PP), T) | |
66 | #define pp_cxx_init_declarator(PP, T) \ | |
67 | pp_c_init_declarator (pp_c_base (PP), T) | |
68 | #define pp_cxx_call_argument_list(PP, T) \ | |
69 | pp_c_call_argument_list (pp_c_base (PP), T) | |
e1a4dd13 | 70 | |
41fd3bac | 71 | void |
12ea3302 | 72 | pp_cxx_colon_colon (cxx_pretty_printer *pp) |
e1a4dd13 | 73 | { |
12ea3302 GDR |
74 | pp_colon_colon (pp); |
75 | pp_base (pp)->padding = pp_none; | |
e1a4dd13 GDR |
76 | } |
77 | ||
41fd3bac GDR |
78 | void |
79 | pp_cxx_begin_template_argument_list (cxx_pretty_printer *pp) | |
80 | { | |
81 | pp_cxx_nonconsecutive_character (pp, '<'); | |
82 | } | |
83 | ||
84 | void | |
85 | pp_cxx_end_template_argument_list (cxx_pretty_printer *pp) | |
86 | { | |
87 | pp_cxx_nonconsecutive_character (pp, '>'); | |
88 | } | |
89 | ||
90 | void | |
91 | pp_cxx_separate_with (cxx_pretty_printer *pp, int c) | |
92 | { | |
93 | pp_separate_with (pp, c); | |
94 | pp_base (pp)->padding = pp_none; | |
95 | } | |
e1a4dd13 | 96 | |
04c06002 | 97 | /* Expressions. */ |
e1a4dd13 | 98 | |
12ea3302 GDR |
99 | static inline bool |
100 | is_destructor_name (tree name) | |
e1a4dd13 | 101 | { |
12ea3302 GDR |
102 | return name == complete_dtor_identifier |
103 | || name == base_dtor_identifier | |
104 | || name == deleting_dtor_identifier; | |
e1a4dd13 GDR |
105 | } |
106 | ||
12ea3302 GDR |
107 | /* conversion-function-id: |
108 | operator conversion-type-id | |
4b780675 | 109 | |
12ea3302 GDR |
110 | conversion-type-id: |
111 | type-specifier-seq conversion-declarator(opt) | |
4b780675 | 112 | |
12ea3302 GDR |
113 | conversion-declarator: |
114 | ptr-operator conversion-declarator(opt) */ | |
b9b44fb9 | 115 | |
12ea3302 GDR |
116 | static inline void |
117 | pp_cxx_conversion_function_id (cxx_pretty_printer *pp, tree t) | |
4b780675 | 118 | { |
12ea3302 GDR |
119 | pp_cxx_identifier (pp, "operator"); |
120 | pp_cxx_type_specifier_seq (pp, TREE_TYPE (t)); | |
4b780675 GDR |
121 | } |
122 | ||
12ea3302 GDR |
123 | static inline void |
124 | pp_cxx_template_id (cxx_pretty_printer *pp, tree t) | |
e1a4dd13 | 125 | { |
12ea3302 GDR |
126 | pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 0)); |
127 | pp_cxx_begin_template_argument_list (pp); | |
128 | pp_cxx_template_argument_list (pp, TREE_OPERAND (t, 1)); | |
129 | pp_cxx_end_template_argument_list (pp); | |
e1a4dd13 GDR |
130 | } |
131 | ||
4b780675 GDR |
132 | /* unqualified-id: |
133 | identifier | |
134 | operator-function-id | |
135 | conversion-function-id | |
136 | ~ class-name | |
137 | template-id */ | |
b9b44fb9 | 138 | |
4b780675 GDR |
139 | static void |
140 | pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) | |
141 | { | |
142 | enum tree_code code = TREE_CODE (t); | |
143 | switch (code) | |
144 | { | |
12ea3302 GDR |
145 | case RESULT_DECL: |
146 | pp_cxx_identifier (pp, "<return-value>"); | |
147 | break; | |
148 | ||
149 | case OVERLOAD: | |
c8094d83 | 150 | t = OVL_CURRENT (t); |
4b780675 GDR |
151 | case VAR_DECL: |
152 | case PARM_DECL: | |
153 | case CONST_DECL: | |
154 | case TYPE_DECL: | |
155 | case FUNCTION_DECL: | |
156 | case NAMESPACE_DECL: | |
157 | case FIELD_DECL: | |
158 | case LABEL_DECL: | |
159 | case USING_DECL: | |
12ea3302 | 160 | case TEMPLATE_DECL: |
4b780675 | 161 | t = DECL_NAME (t); |
c8094d83 | 162 | |
4b780675 | 163 | case IDENTIFIER_NODE: |
12ea3302 | 164 | if (t == NULL) |
0cbd7506 | 165 | pp_cxx_identifier (pp, "<unnamed>"); |
12ea3302 | 166 | else if (IDENTIFIER_TYPENAME_P (t)) |
0cbd7506 | 167 | pp_cxx_conversion_function_id (pp, t); |
4b780675 | 168 | else |
0cbd7506 MS |
169 | { |
170 | if (is_destructor_name (t)) | |
171 | { | |
172 | pp_complement (pp); | |
173 | /* FIXME: Why is this necessary? */ | |
174 | if (TREE_TYPE (t)) | |
175 | t = constructor_name (TREE_TYPE (t)); | |
176 | } | |
177 | pp_cxx_tree_identifier (pp, t); | |
178 | } | |
4b780675 GDR |
179 | break; |
180 | ||
181 | case TEMPLATE_ID_EXPR: | |
12ea3302 GDR |
182 | pp_cxx_template_id (pp, t); |
183 | break; | |
184 | ||
3601f003 KL |
185 | case BASELINK: |
186 | pp_cxx_unqualified_id (pp, BASELINK_FUNCTIONS (t)); | |
187 | break; | |
188 | ||
12ea3302 GDR |
189 | case RECORD_TYPE: |
190 | case UNION_TYPE: | |
191 | case ENUMERAL_TYPE: | |
192 | pp_cxx_unqualified_id (pp, TYPE_NAME (t)); | |
193 | break; | |
194 | ||
195 | case TEMPLATE_TYPE_PARM: | |
41fd3bac GDR |
196 | case TEMPLATE_TEMPLATE_PARM: |
197 | if (TYPE_IDENTIFIER (t)) | |
0cbd7506 | 198 | pp_cxx_unqualified_id (pp, TYPE_IDENTIFIER (t)); |
41fd3bac | 199 | else |
0cbd7506 | 200 | pp_cxx_canonical_template_parameter (pp, t); |
41fd3bac GDR |
201 | break; |
202 | ||
12ea3302 GDR |
203 | case TEMPLATE_PARM_INDEX: |
204 | pp_cxx_unqualified_id (pp, TEMPLATE_PARM_DECL (t)); | |
4b780675 GDR |
205 | break; |
206 | ||
207 | default: | |
208 | pp_unsupported_tree (pp, t); | |
12ea3302 GDR |
209 | break; |
210 | } | |
211 | } | |
212 | ||
b9b44fb9 GDR |
213 | /* Pretty-print out the token sequence ":: template" in template codes |
214 | where it is needed to "inline declare" the (following) member as | |
666c27b9 | 215 | a template. This situation arises when SCOPE of T is dependent |
b9b44fb9 GDR |
216 | on template parameters. */ |
217 | ||
12ea3302 GDR |
218 | static inline void |
219 | pp_cxx_template_keyword_if_needed (cxx_pretty_printer *pp, tree scope, tree t) | |
220 | { | |
221 | if (TREE_CODE (t) == TEMPLATE_ID_EXPR | |
222 | && TYPE_P (scope) && dependent_type_p (scope)) | |
223 | pp_cxx_identifier (pp, "template"); | |
224 | } | |
225 | ||
226 | /* nested-name-specifier: | |
227 | class-or-namespace-name :: nested-name-specifier(opt) | |
228 | class-or-namespace-name :: template nested-name-specifier */ | |
b9b44fb9 | 229 | |
12ea3302 GDR |
230 | static void |
231 | pp_cxx_nested_name_specifier (cxx_pretty_printer *pp, tree t) | |
232 | { | |
233 | if (t != NULL && t != pp->enclosing_scope) | |
234 | { | |
235 | tree scope = TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t); | |
236 | pp_cxx_nested_name_specifier (pp, scope); | |
237 | pp_cxx_template_keyword_if_needed (pp, scope, t); | |
238 | pp_cxx_unqualified_id (pp, t); | |
239 | pp_cxx_colon_colon (pp); | |
4b780675 GDR |
240 | } |
241 | } | |
242 | ||
243 | /* qualified-id: | |
244 | nested-name-specifier template(opt) unqualified-id */ | |
b9b44fb9 | 245 | |
4b780675 GDR |
246 | static void |
247 | pp_cxx_qualified_id (cxx_pretty_printer *pp, tree t) | |
248 | { | |
249 | switch (TREE_CODE (t)) | |
250 | { | |
b9b44fb9 | 251 | /* A pointer-to-member is always qualified. */ |
4b780675 | 252 | case PTRMEM_CST: |
12ea3302 | 253 | pp_cxx_nested_name_specifier (pp, PTRMEM_CST_CLASS (t)); |
4b780675 GDR |
254 | pp_cxx_unqualified_id (pp, PTRMEM_CST_MEMBER (t)); |
255 | break; | |
256 | ||
b9b44fb9 | 257 | /* In Standard C++, functions cannot possibly be used as |
0cbd7506 MS |
258 | nested-name-specifiers. However, there are situations where |
259 | is "makes sense" to output the surrounding function name for the | |
260 | purpose of emphasizing on the scope kind. Just printing the | |
261 | function name might not be sufficient as it may be overloaded; so, | |
262 | we decorate the function with its signature too. | |
263 | FIXME: This is probably the wrong pretty-printing for conversion | |
264 | functions and some function templates. */ | |
12ea3302 GDR |
265 | case OVERLOAD: |
266 | t = OVL_CURRENT (t); | |
267 | case FUNCTION_DECL: | |
268 | if (DECL_FUNCTION_MEMBER_P (t)) | |
0cbd7506 | 269 | pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t)); |
12ea3302 | 270 | pp_cxx_unqualified_id |
0cbd7506 | 271 | (pp, DECL_CONSTRUCTOR_P (t) ? DECL_CONTEXT (t) : t); |
b9b44fb9 | 272 | pp_cxx_parameter_declaration_clause (pp, TREE_TYPE (t)); |
12ea3302 GDR |
273 | break; |
274 | ||
4b780675 GDR |
275 | case OFFSET_REF: |
276 | case SCOPE_REF: | |
12ea3302 | 277 | pp_cxx_nested_name_specifier (pp, TREE_OPERAND (t, 0)); |
4b780675 GDR |
278 | pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 1)); |
279 | break; | |
280 | ||
281 | default: | |
282 | { | |
0cbd7506 MS |
283 | tree scope = TYPE_P (t) ? TYPE_CONTEXT (t) : DECL_CONTEXT (t); |
284 | if (scope != pp->enclosing_scope) | |
285 | { | |
286 | pp_cxx_nested_name_specifier (pp, scope); | |
287 | pp_cxx_template_keyword_if_needed (pp, scope, t); | |
288 | } | |
289 | pp_cxx_unqualified_id (pp, t); | |
4b780675 GDR |
290 | } |
291 | break; | |
292 | } | |
293 | } | |
294 | ||
a176426f GDR |
295 | |
296 | static void | |
297 | pp_cxx_constant (cxx_pretty_printer *pp, tree t) | |
298 | { | |
299 | switch (TREE_CODE (t)) | |
300 | { | |
301 | case STRING_CST: | |
302 | { | |
3db45ab5 MS |
303 | const bool in_parens = PAREN_STRING_LITERAL_P (t); |
304 | if (in_parens) | |
305 | pp_cxx_left_paren (pp); | |
306 | pp_c_constant (pp_c_base (pp), t); | |
307 | if (in_parens) | |
308 | pp_cxx_right_paren (pp); | |
a176426f GDR |
309 | } |
310 | break; | |
311 | ||
312 | default: | |
313 | pp_c_constant (pp_c_base (pp), t); | |
314 | break; | |
315 | } | |
316 | } | |
317 | ||
4b780675 | 318 | /* id-expression: |
cd0be382 | 319 | unqualified-id |
4b780675 | 320 | qualified-id */ |
b9b44fb9 | 321 | |
4b780675 GDR |
322 | static inline void |
323 | pp_cxx_id_expression (cxx_pretty_printer *pp, tree t) | |
324 | { | |
12ea3302 GDR |
325 | if (TREE_CODE (t) == OVERLOAD) |
326 | t = OVL_CURRENT (t); | |
d04a575f | 327 | if (DECL_P (t) && DECL_CONTEXT (t)) |
4b780675 GDR |
328 | pp_cxx_qualified_id (pp, t); |
329 | else | |
330 | pp_cxx_unqualified_id (pp, t); | |
331 | } | |
332 | ||
333 | /* primary-expression: | |
334 | literal | |
335 | this | |
336 | :: identifier | |
337 | :: operator-function-id | |
338 | :: qualifier-id | |
339 | ( expression ) | |
340 | id-expression */ | |
b9b44fb9 | 341 | |
e1a4dd13 GDR |
342 | static void |
343 | pp_cxx_primary_expression (cxx_pretty_printer *pp, tree t) | |
344 | { | |
4b780675 GDR |
345 | switch (TREE_CODE (t)) |
346 | { | |
4b780675 GDR |
347 | case INTEGER_CST: |
348 | case REAL_CST: | |
a176426f GDR |
349 | case STRING_CST: |
350 | pp_cxx_constant (pp, t); | |
4b780675 GDR |
351 | break; |
352 | ||
12ea3302 GDR |
353 | case BASELINK: |
354 | t = BASELINK_FUNCTIONS (t); | |
355 | case VAR_DECL: | |
356 | case PARM_DECL: | |
357 | case FIELD_DECL: | |
358 | case FUNCTION_DECL: | |
359 | case OVERLOAD: | |
360 | case CONST_DECL: | |
361 | case TEMPLATE_DECL: | |
362 | pp_cxx_id_expression (pp, t); | |
363 | break; | |
364 | ||
365 | case RESULT_DECL: | |
366 | case TEMPLATE_TYPE_PARM: | |
41fd3bac | 367 | case TEMPLATE_TEMPLATE_PARM: |
12ea3302 GDR |
368 | case TEMPLATE_PARM_INDEX: |
369 | pp_cxx_unqualified_id (pp, t); | |
370 | break; | |
371 | ||
c3e5898b ILT |
372 | case STMT_EXPR: |
373 | pp_cxx_left_paren (pp); | |
374 | pp_cxx_statement (pp, STMT_EXPR_STMT (t)); | |
375 | pp_cxx_right_paren (pp); | |
376 | break; | |
377 | ||
4b780675 | 378 | default: |
12ea3302 | 379 | pp_c_primary_expression (pp_c_base (pp), t); |
4b780675 GDR |
380 | break; |
381 | } | |
e1a4dd13 GDR |
382 | } |
383 | ||
4b780675 GDR |
384 | /* postfix-expression: |
385 | primary-expression | |
386 | postfix-expression [ expression ] | |
387 | postfix-expression ( expression-list(opt) ) | |
388 | simple-type-specifier ( expression-list(opt) ) | |
389 | typename ::(opt) nested-name-specifier identifier ( expression-list(opt) ) | |
390 | typename ::(opt) nested-name-specifier template(opt) | |
0cbd7506 | 391 | template-id ( expression-list(opt) ) |
4b780675 GDR |
392 | postfix-expression . template(opt) ::(opt) id-expression |
393 | postfix-expression -> template(opt) ::(opt) id-expression | |
394 | postfix-expression . pseudo-destructor-name | |
395 | postfix-expression -> pseudo-destructor-name | |
396 | postfix-expression ++ | |
397 | postfix-expression -- | |
398 | dynamic_cast < type-id > ( expression ) | |
399 | static_cast < type-id > ( expression ) | |
400 | reinterpret_cast < type-id > ( expression ) | |
401 | const_cast < type-id > ( expression ) | |
402 | typeid ( expression ) | |
403 | typeif ( type-id ) */ | |
404 | ||
e1a4dd13 GDR |
405 | static void |
406 | pp_cxx_postfix_expression (cxx_pretty_printer *pp, tree t) | |
407 | { | |
4b780675 | 408 | enum tree_code code = TREE_CODE (t); |
c8094d83 | 409 | |
4b780675 GDR |
410 | switch (code) |
411 | { | |
12ea3302 GDR |
412 | case AGGR_INIT_EXPR: |
413 | case CALL_EXPR: | |
414 | { | |
5039610b SL |
415 | tree fun = (code == AGGR_INIT_EXPR ? AGGR_INIT_EXPR_FN (t) |
416 | : CALL_EXPR_FN (t)); | |
0cbd7506 | 417 | tree saved_scope = pp->enclosing_scope; |
5039610b SL |
418 | bool skipfirst = false; |
419 | tree arg; | |
0cbd7506 MS |
420 | |
421 | if (TREE_CODE (fun) == ADDR_EXPR) | |
422 | fun = TREE_OPERAND (fun, 0); | |
423 | ||
424 | /* In templates, where there is no way to tell whether a given | |
425 | call uses an actual member function. So the parser builds | |
426 | FUN as a COMPONENT_REF or a plain IDENTIFIER_NODE until | |
427 | instantiation time. */ | |
428 | if (TREE_CODE (fun) != FUNCTION_DECL) | |
429 | ; | |
430 | else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun)) | |
431 | { | |
5039610b SL |
432 | tree object = (code == AGGR_INIT_EXPR |
433 | ? (AGGR_INIT_VIA_CTOR_P (t) | |
434 | ? AGGR_INIT_EXPR_SLOT (t) | |
435 | : AGGR_INIT_EXPR_ARG (t, 0)) | |
436 | : CALL_EXPR_ARG (t, 0)); | |
0cbd7506 MS |
437 | |
438 | while (TREE_CODE (object) == NOP_EXPR) | |
439 | object = TREE_OPERAND (object, 0); | |
440 | ||
441 | if (TREE_CODE (object) == ADDR_EXPR) | |
442 | object = TREE_OPERAND (object, 0); | |
443 | ||
444 | if (TREE_CODE (TREE_TYPE (object)) != POINTER_TYPE) | |
445 | { | |
446 | pp_cxx_postfix_expression (pp, object); | |
447 | pp_cxx_dot (pp); | |
448 | } | |
449 | else | |
450 | { | |
451 | pp_cxx_postfix_expression (pp, object); | |
452 | pp_cxx_arrow (pp); | |
453 | } | |
5039610b | 454 | skipfirst = true; |
0cbd7506 MS |
455 | pp->enclosing_scope = strip_pointer_operator (TREE_TYPE (object)); |
456 | } | |
457 | ||
458 | pp_cxx_postfix_expression (pp, fun); | |
459 | pp->enclosing_scope = saved_scope; | |
5039610b SL |
460 | pp_cxx_left_paren (pp); |
461 | if (code == AGGR_INIT_EXPR) | |
462 | { | |
463 | aggr_init_expr_arg_iterator iter; | |
464 | FOR_EACH_AGGR_INIT_EXPR_ARG (arg, iter, t) | |
465 | { | |
466 | if (skipfirst) | |
467 | skipfirst = false; | |
468 | else | |
469 | { | |
470 | pp_cxx_expression (pp, arg); | |
471 | if (more_aggr_init_expr_args_p (&iter)) | |
472 | pp_cxx_separate_with (pp, ','); | |
473 | } | |
474 | } | |
475 | } | |
476 | else | |
477 | { | |
478 | call_expr_arg_iterator iter; | |
479 | FOR_EACH_CALL_EXPR_ARG (arg, iter, t) | |
480 | { | |
481 | if (skipfirst) | |
482 | skipfirst = false; | |
483 | else | |
484 | { | |
485 | pp_cxx_expression (pp, arg); | |
486 | if (more_call_expr_args_p (&iter)) | |
487 | pp_cxx_separate_with (pp, ','); | |
488 | } | |
489 | } | |
490 | } | |
491 | pp_cxx_right_paren (pp); | |
12ea3302 GDR |
492 | } |
493 | if (code == AGGR_INIT_EXPR && AGGR_INIT_VIA_CTOR_P (t)) | |
0cbd7506 MS |
494 | { |
495 | pp_cxx_separate_with (pp, ','); | |
5039610b | 496 | pp_cxx_postfix_expression (pp, AGGR_INIT_EXPR_SLOT (t)); |
0cbd7506 | 497 | } |
12ea3302 GDR |
498 | break; |
499 | ||
500 | case BASELINK: | |
501 | case VAR_DECL: | |
502 | case PARM_DECL: | |
503 | case FIELD_DECL: | |
504 | case FUNCTION_DECL: | |
505 | case OVERLOAD: | |
506 | case CONST_DECL: | |
507 | case TEMPLATE_DECL: | |
508 | case RESULT_DECL: | |
509 | pp_cxx_primary_expression (pp, t); | |
510 | break; | |
511 | ||
4b780675 GDR |
512 | case DYNAMIC_CAST_EXPR: |
513 | case STATIC_CAST_EXPR: | |
514 | case REINTERPRET_CAST_EXPR: | |
515 | case CONST_CAST_EXPR: | |
516 | if (code == DYNAMIC_CAST_EXPR) | |
0cbd7506 | 517 | pp_cxx_identifier (pp, "dynamic_cast"); |
4b780675 | 518 | else if (code == STATIC_CAST_EXPR) |
0cbd7506 | 519 | pp_cxx_identifier (pp, "static_cast"); |
4b780675 | 520 | else if (code == REINTERPRET_CAST_EXPR) |
0cbd7506 | 521 | pp_cxx_identifier (pp, "reinterpret_cast"); |
4b780675 | 522 | else |
0cbd7506 | 523 | pp_cxx_identifier (pp, "const_cast"); |
4b780675 GDR |
524 | pp_cxx_begin_template_argument_list (pp); |
525 | pp_cxx_type_id (pp, TREE_TYPE (t)); | |
526 | pp_cxx_end_template_argument_list (pp); | |
527 | pp_left_paren (pp); | |
12ea3302 | 528 | pp_cxx_expression (pp, TREE_OPERAND (t, 0)); |
4b780675 GDR |
529 | pp_right_paren (pp); |
530 | break; | |
531 | ||
532 | case EMPTY_CLASS_EXPR: | |
533 | pp_cxx_type_id (pp, TREE_TYPE (t)); | |
534 | pp_left_paren (pp); | |
535 | pp_right_paren (pp); | |
536 | break; | |
537 | ||
538 | case TYPEID_EXPR: | |
539 | t = TREE_OPERAND (t, 0); | |
12ea3302 | 540 | pp_cxx_identifier (pp, "typeid"); |
4b780675 GDR |
541 | pp_left_paren (pp); |
542 | if (TYPE_P (t)) | |
0cbd7506 | 543 | pp_cxx_type_id (pp, t); |
4b780675 | 544 | else |
0cbd7506 | 545 | pp_cxx_expression (pp, t); |
4b780675 GDR |
546 | pp_right_paren (pp); |
547 | break; | |
548 | ||
549 | case PSEUDO_DTOR_EXPR: | |
550 | pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0)); | |
12ea3302 | 551 | pp_cxx_dot (pp); |
4b780675 | 552 | pp_cxx_qualified_id (pp, TREE_OPERAND (t, 1)); |
12ea3302 | 553 | pp_cxx_colon_colon (pp); |
4b780675 GDR |
554 | pp_complement (pp); |
555 | pp_cxx_unqualified_id (pp, TREE_OPERAND (t, 2)); | |
556 | break; | |
557 | ||
03a08664 ILT |
558 | case ARROW_EXPR: |
559 | pp_cxx_postfix_expression (pp, TREE_OPERAND (t, 0)); | |
560 | pp_cxx_arrow (pp); | |
561 | break; | |
562 | ||
4b780675 GDR |
563 | default: |
564 | pp_c_postfix_expression (pp_c_base (pp), t); | |
565 | break; | |
566 | } | |
e1a4dd13 GDR |
567 | } |
568 | ||
4b780675 GDR |
569 | /* new-expression: |
570 | ::(opt) new new-placement(opt) new-type-id new-initializer(opt) | |
571 | ::(opt) new new-placement(opt) ( type-id ) new-initializer(opt) | |
572 | ||
573 | new-placement: | |
574 | ( expression-list ) | |
575 | ||
576 | new-type-id: | |
577 | type-specifier-seq new-declarator(opt) | |
578 | ||
579 | new-declarator: | |
580 | ptr-operator new-declarator(opt) | |
581 | direct-new-declarator | |
582 | ||
583 | direct-new-declarator | |
584 | [ expression ] | |
585 | direct-new-declarator [ constant-expression ] | |
586 | ||
587 | new-initializer: | |
588 | ( expression-list(opt) ) */ | |
b9b44fb9 | 589 | |
e1a4dd13 | 590 | static void |
4b780675 | 591 | pp_cxx_new_expression (cxx_pretty_printer *pp, tree t) |
e1a4dd13 | 592 | { |
4b780675 GDR |
593 | enum tree_code code = TREE_CODE (t); |
594 | switch (code) | |
595 | { | |
596 | case NEW_EXPR: | |
597 | case VEC_NEW_EXPR: | |
598 | if (NEW_EXPR_USE_GLOBAL (t)) | |
0cbd7506 | 599 | pp_cxx_colon_colon (pp); |
12ea3302 | 600 | pp_cxx_identifier (pp, "new"); |
4b780675 | 601 | if (TREE_OPERAND (t, 0)) |
0cbd7506 MS |
602 | { |
603 | pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0)); | |
604 | pp_space (pp); | |
605 | } | |
4b780675 GDR |
606 | /* FIXME: array-types are built with one more element. */ |
607 | pp_cxx_type_id (pp, TREE_OPERAND (t, 1)); | |
608 | if (TREE_OPERAND (t, 2)) | |
0cbd7506 MS |
609 | { |
610 | pp_left_paren (pp); | |
611 | t = TREE_OPERAND (t, 2); | |
612 | if (TREE_CODE (t) == TREE_LIST) | |
613 | pp_c_expression_list (pp_c_base (pp), t); | |
614 | else if (t == void_zero_node) | |
615 | ; /* OK, empty initializer list. */ | |
616 | else | |
617 | pp_cxx_expression (pp, t); | |
618 | pp_right_paren (pp); | |
619 | } | |
4b780675 GDR |
620 | break; |
621 | ||
622 | default: | |
623 | pp_unsupported_tree (pp, t); | |
624 | } | |
e1a4dd13 GDR |
625 | } |
626 | ||
4b780675 GDR |
627 | /* delete-expression: |
628 | ::(opt) delete cast-expression | |
629 | ::(opt) delete [ ] cast-expression */ | |
b9b44fb9 | 630 | |
e1a4dd13 | 631 | static void |
4b780675 | 632 | pp_cxx_delete_expression (cxx_pretty_printer *pp, tree t) |
e1a4dd13 | 633 | { |
4b780675 GDR |
634 | enum tree_code code = TREE_CODE (t); |
635 | switch (code) | |
636 | { | |
637 | case DELETE_EXPR: | |
638 | case VEC_DELETE_EXPR: | |
639 | if (DELETE_EXPR_USE_GLOBAL (t)) | |
0cbd7506 | 640 | pp_cxx_colon_colon (pp); |
12ea3302 | 641 | pp_cxx_identifier (pp, "delete"); |
4b780675 | 642 | if (code == VEC_DELETE_EXPR) |
0cbd7506 MS |
643 | { |
644 | pp_left_bracket (pp); | |
645 | pp_right_bracket (pp); | |
646 | } | |
4b780675 | 647 | pp_c_cast_expression (pp_c_base (pp), TREE_OPERAND (t, 0)); |
c8094d83 MS |
648 | break; |
649 | ||
4b780675 GDR |
650 | default: |
651 | pp_unsupported_tree (pp, t); | |
652 | } | |
e1a4dd13 GDR |
653 | } |
654 | ||
4b780675 GDR |
655 | /* unary-expression: |
656 | postfix-expression | |
657 | ++ cast-expression | |
658 | -- cast-expression | |
659 | unary-operator cast-expression | |
660 | sizeof unary-expression | |
661 | sizeof ( type-id ) | |
662 | new-expression | |
663 | delete-expression | |
664 | ||
665 | unary-operator: one of | |
666 | * & + - ! | |
667 | ||
668 | GNU extensions: | |
669 | __alignof__ unary-expression | |
670 | __alignof__ ( type-id ) */ | |
b9b44fb9 | 671 | |
e1a4dd13 | 672 | static void |
4b780675 | 673 | pp_cxx_unary_expression (cxx_pretty_printer *pp, tree t) |
e1a4dd13 | 674 | { |
4b780675 GDR |
675 | enum tree_code code = TREE_CODE (t); |
676 | switch (code) | |
677 | { | |
678 | case NEW_EXPR: | |
679 | case VEC_NEW_EXPR: | |
680 | pp_cxx_new_expression (pp, t); | |
681 | break; | |
682 | ||
683 | case DELETE_EXPR: | |
684 | case VEC_DELETE_EXPR: | |
685 | pp_cxx_delete_expression (pp, t); | |
686 | break; | |
c8094d83 | 687 | |
03a08664 ILT |
688 | case SIZEOF_EXPR: |
689 | case ALIGNOF_EXPR: | |
690 | pp_cxx_identifier (pp, code == SIZEOF_EXPR ? "sizeof" : "__alignof__"); | |
691 | pp_cxx_whitespace (pp); | |
692 | if (TYPE_P (TREE_OPERAND (t, 0))) | |
693 | { | |
694 | pp_cxx_left_paren (pp); | |
695 | pp_cxx_type_id (pp, TREE_OPERAND (t, 0)); | |
696 | pp_cxx_right_paren (pp); | |
697 | } | |
698 | else | |
699 | pp_unary_expression (pp, TREE_OPERAND (t, 0)); | |
700 | break; | |
701 | ||
392e3d51 RS |
702 | case UNARY_PLUS_EXPR: |
703 | pp_plus (pp); | |
704 | pp_cxx_cast_expression (pp, TREE_OPERAND (t, 0)); | |
705 | break; | |
706 | ||
4b780675 GDR |
707 | default: |
708 | pp_c_unary_expression (pp_c_base (pp), t); | |
709 | break; | |
710 | } | |
e1a4dd13 GDR |
711 | } |
712 | ||
12ea3302 GDR |
713 | /* cast-expression: |
714 | unary-expression | |
715 | ( type-id ) cast-expression */ | |
b9b44fb9 | 716 | |
12ea3302 GDR |
717 | static void |
718 | pp_cxx_cast_expression (cxx_pretty_printer *pp, tree t) | |
719 | { | |
720 | switch (TREE_CODE (t)) | |
721 | { | |
722 | case CAST_EXPR: | |
723 | pp_cxx_type_id (pp, TREE_TYPE (t)); | |
724 | pp_cxx_call_argument_list (pp, TREE_OPERAND (t, 0)); | |
725 | break; | |
726 | ||
727 | default: | |
728 | pp_c_cast_expression (pp_c_base (pp), t); | |
729 | break; | |
730 | } | |
731 | } | |
732 | ||
4b780675 GDR |
733 | /* pm-expression: |
734 | cast-expression | |
735 | pm-expression .* cast-expression | |
736 | pm-expression ->* cast-expression */ | |
b9b44fb9 | 737 | |
e1a4dd13 | 738 | static void |
4b780675 | 739 | pp_cxx_pm_expression (cxx_pretty_printer *pp, tree t) |
e1a4dd13 | 740 | { |
4b780675 GDR |
741 | switch (TREE_CODE (t)) |
742 | { | |
743 | /* Handle unfortunate OFFESET_REF overloading here. */ | |
744 | case OFFSET_REF: | |
745 | if (TYPE_P (TREE_OPERAND (t, 0))) | |
0cbd7506 MS |
746 | { |
747 | pp_cxx_qualified_id (pp, t); | |
748 | break; | |
749 | } | |
f4f206f4 | 750 | /* Else fall through. */ |
4b780675 GDR |
751 | case MEMBER_REF: |
752 | case DOTSTAR_EXPR: | |
753 | pp_cxx_pm_expression (pp, TREE_OPERAND (t, 0)); | |
12ea3302 | 754 | pp_cxx_dot (pp); |
4b780675 | 755 | pp_star(pp); |
12ea3302 | 756 | pp_cxx_cast_expression (pp, TREE_OPERAND (t, 1)); |
4b780675 GDR |
757 | break; |
758 | ||
759 | ||
760 | default: | |
12ea3302 | 761 | pp_cxx_cast_expression (pp, t); |
4b780675 GDR |
762 | break; |
763 | } | |
e1a4dd13 GDR |
764 | } |
765 | ||
4b780675 GDR |
766 | /* multiplicative-expression: |
767 | pm-expression | |
768 | multiplicative-expression * pm-expression | |
769 | multiplicative-expression / pm-expression | |
770 | multiplicative-expression % pm-expression */ | |
b9b44fb9 | 771 | |
e1a4dd13 | 772 | static void |
4b780675 | 773 | pp_cxx_multiplicative_expression (cxx_pretty_printer *pp, tree e) |
e1a4dd13 | 774 | { |
4b780675 GDR |
775 | enum tree_code code = TREE_CODE (e); |
776 | switch (code) | |
777 | { | |
778 | case MULT_EXPR: | |
779 | case TRUNC_DIV_EXPR: | |
780 | case TRUNC_MOD_EXPR: | |
781 | pp_cxx_multiplicative_expression (pp, TREE_OPERAND (e, 0)); | |
782 | pp_space (pp); | |
783 | if (code == MULT_EXPR) | |
784 | pp_star (pp); | |
785 | else if (code == TRUNC_DIV_EXPR) | |
786 | pp_slash (pp); | |
787 | else | |
788 | pp_modulo (pp); | |
789 | pp_space (pp); | |
790 | pp_cxx_pm_expression (pp, TREE_OPERAND (e, 1)); | |
791 | break; | |
792 | ||
793 | default: | |
794 | pp_cxx_pm_expression (pp, e); | |
795 | break; | |
796 | } | |
e1a4dd13 GDR |
797 | } |
798 | ||
4b780675 GDR |
799 | /* conditional-expression: |
800 | logical-or-expression | |
801 | logical-or-expression ? expression : assignment-expression */ | |
b9b44fb9 | 802 | |
4b780675 GDR |
803 | static void |
804 | pp_cxx_conditional_expression (cxx_pretty_printer *pp, tree e) | |
e1a4dd13 | 805 | { |
4b780675 GDR |
806 | if (TREE_CODE (e) == COND_EXPR) |
807 | { | |
808 | pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0)); | |
809 | pp_space (pp); | |
810 | pp_question (pp); | |
811 | pp_space (pp); | |
12ea3302 | 812 | pp_cxx_expression (pp, TREE_OPERAND (e, 1)); |
4b780675 GDR |
813 | pp_space (pp); |
814 | pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2)); | |
815 | } | |
816 | else | |
817 | pp_c_logical_or_expression (pp_c_base (pp), e); | |
818 | } | |
819 | ||
b9b44fb9 GDR |
820 | /* Pretty-print a compound assignment operator token as indicated by T. */ |
821 | ||
12ea3302 GDR |
822 | static void |
823 | pp_cxx_assignment_operator (cxx_pretty_printer *pp, tree t) | |
824 | { | |
825 | const char *op; | |
826 | ||
827 | switch (TREE_CODE (t)) | |
828 | { | |
829 | case NOP_EXPR: | |
830 | op = "="; | |
831 | break; | |
832 | ||
833 | case PLUS_EXPR: | |
834 | op = "+="; | |
835 | break; | |
836 | ||
837 | case MINUS_EXPR: | |
838 | op = "-="; | |
839 | break; | |
840 | ||
841 | case TRUNC_DIV_EXPR: | |
842 | op = "/="; | |
843 | break; | |
844 | ||
845 | case TRUNC_MOD_EXPR: | |
846 | op = "%="; | |
847 | break; | |
848 | ||
849 | default: | |
850 | op = tree_code_name[TREE_CODE (t)]; | |
851 | break; | |
852 | } | |
853 | ||
854 | pp_cxx_identifier (pp, op); | |
855 | } | |
856 | ||
857 | ||
4b780675 GDR |
858 | /* assignment-expression: |
859 | conditional-expression | |
860 | logical-or-expression assignment-operator assignment-expression | |
12ea3302 GDR |
861 | throw-expression |
862 | ||
863 | throw-expression: | |
864 | throw assignment-expression(opt) | |
4b780675 | 865 | |
12ea3302 | 866 | assignment-operator: one of |
4b780675 | 867 | = *= /= %= += -= >>= <<= &= ^= |= */ |
b9b44fb9 | 868 | |
4b780675 GDR |
869 | static void |
870 | pp_cxx_assignment_expression (cxx_pretty_printer *pp, tree e) | |
871 | { | |
12ea3302 | 872 | switch (TREE_CODE (e)) |
4b780675 | 873 | { |
12ea3302 GDR |
874 | case MODIFY_EXPR: |
875 | case INIT_EXPR: | |
4b780675 GDR |
876 | pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0)); |
877 | pp_space (pp); | |
878 | pp_equal (pp); | |
879 | pp_space (pp); | |
880 | pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 1)); | |
12ea3302 | 881 | break; |
e1a4dd13 | 882 | |
12ea3302 GDR |
883 | case THROW_EXPR: |
884 | pp_cxx_identifier (pp, "throw"); | |
885 | if (TREE_OPERAND (e, 0)) | |
0cbd7506 | 886 | pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 0)); |
12ea3302 | 887 | break; |
e1a4dd13 | 888 | |
12ea3302 GDR |
889 | case MODOP_EXPR: |
890 | pp_c_logical_or_expression (pp_c_base (pp), TREE_OPERAND (e, 0)); | |
891 | pp_cxx_assignment_operator (pp, TREE_OPERAND (e, 1)); | |
892 | pp_cxx_assignment_expression (pp, TREE_OPERAND (e, 2)); | |
893 | break; | |
e1a4dd13 | 894 | |
12ea3302 GDR |
895 | default: |
896 | pp_cxx_conditional_expression (pp, e); | |
897 | break; | |
898 | } | |
899 | } | |
900 | ||
901 | static void | |
902 | pp_cxx_expression (cxx_pretty_printer *pp, tree t) | |
903 | { | |
904 | switch (TREE_CODE (t)) | |
905 | { | |
906 | case STRING_CST: | |
907 | case INTEGER_CST: | |
908 | case REAL_CST: | |
a176426f | 909 | pp_cxx_constant (pp, t); |
12ea3302 GDR |
910 | break; |
911 | ||
912 | case RESULT_DECL: | |
913 | pp_cxx_unqualified_id (pp, t); | |
914 | break; | |
915 | ||
c8094d83 | 916 | #if 0 |
12ea3302 | 917 | case OFFSET_REF: |
c8094d83 | 918 | #endif |
12ea3302 GDR |
919 | case SCOPE_REF: |
920 | case PTRMEM_CST: | |
921 | pp_cxx_qualified_id (pp, t); | |
922 | break; | |
923 | ||
924 | case OVERLOAD: | |
925 | t = OVL_CURRENT (t); | |
926 | case VAR_DECL: | |
927 | case PARM_DECL: | |
928 | case FIELD_DECL: | |
929 | case CONST_DECL: | |
930 | case FUNCTION_DECL: | |
931 | case BASELINK: | |
932 | case TEMPLATE_DECL: | |
933 | case TEMPLATE_TYPE_PARM: | |
934 | case TEMPLATE_PARM_INDEX: | |
41fd3bac | 935 | case TEMPLATE_TEMPLATE_PARM: |
c3e5898b | 936 | case STMT_EXPR: |
12ea3302 GDR |
937 | pp_cxx_primary_expression (pp, t); |
938 | break; | |
939 | ||
940 | case CALL_EXPR: | |
941 | case DYNAMIC_CAST_EXPR: | |
942 | case STATIC_CAST_EXPR: | |
943 | case REINTERPRET_CAST_EXPR: | |
944 | case CONST_CAST_EXPR: | |
c8094d83 | 945 | #if 0 |
12ea3302 | 946 | case MEMBER_REF: |
c8094d83 | 947 | #endif |
12ea3302 GDR |
948 | case EMPTY_CLASS_EXPR: |
949 | case TYPEID_EXPR: | |
950 | case PSEUDO_DTOR_EXPR: | |
951 | case AGGR_INIT_EXPR: | |
03a08664 | 952 | case ARROW_EXPR: |
12ea3302 GDR |
953 | pp_cxx_postfix_expression (pp, t); |
954 | break; | |
955 | ||
956 | case NEW_EXPR: | |
957 | case VEC_NEW_EXPR: | |
958 | pp_cxx_new_expression (pp, t); | |
959 | break; | |
960 | ||
961 | case DELETE_EXPR: | |
962 | case VEC_DELETE_EXPR: | |
963 | pp_cxx_delete_expression (pp, t); | |
964 | break; | |
965 | ||
03a08664 ILT |
966 | case SIZEOF_EXPR: |
967 | case ALIGNOF_EXPR: | |
968 | pp_cxx_unary_expression (pp, t); | |
969 | break; | |
970 | ||
12ea3302 GDR |
971 | case CAST_EXPR: |
972 | pp_cxx_cast_expression (pp, t); | |
973 | break; | |
974 | ||
975 | case OFFSET_REF: | |
976 | case MEMBER_REF: | |
977 | case DOTSTAR_EXPR: | |
978 | pp_cxx_pm_expression (pp, t); | |
979 | break; | |
980 | ||
981 | case MULT_EXPR: | |
982 | case TRUNC_DIV_EXPR: | |
983 | case TRUNC_MOD_EXPR: | |
984 | pp_cxx_multiplicative_expression (pp, t); | |
985 | break; | |
986 | ||
987 | case COND_EXPR: | |
988 | pp_cxx_conditional_expression (pp, t); | |
989 | break; | |
990 | ||
991 | case MODIFY_EXPR: | |
992 | case INIT_EXPR: | |
993 | case THROW_EXPR: | |
994 | case MODOP_EXPR: | |
995 | pp_cxx_assignment_expression (pp, t); | |
996 | break; | |
997 | ||
b9b44fb9 GDR |
998 | case NON_DEPENDENT_EXPR: |
999 | case MUST_NOT_THROW_EXPR: | |
1000 | pp_cxx_expression (pp, t); | |
1001 | break; | |
1002 | ||
12ea3302 GDR |
1003 | default: |
1004 | pp_c_expression (pp_c_base (pp), t); | |
c8094d83 | 1005 | break; |
12ea3302 GDR |
1006 | } |
1007 | } | |
1008 | ||
1009 | ||
1010 | /* Declarations. */ | |
1011 | ||
1012 | /* function-specifier: | |
1013 | inline | |
1014 | virtual | |
1015 | explicit */ | |
b9b44fb9 | 1016 | |
12ea3302 GDR |
1017 | static void |
1018 | pp_cxx_function_specifier (cxx_pretty_printer *pp, tree t) | |
1019 | { | |
1020 | switch (TREE_CODE (t)) | |
1021 | { | |
1022 | case FUNCTION_DECL: | |
1023 | if (DECL_VIRTUAL_P (t)) | |
0cbd7506 | 1024 | pp_cxx_identifier (pp, "virtual"); |
12ea3302 | 1025 | else if (DECL_CONSTRUCTOR_P (t) && DECL_NONCONVERTING_P (t)) |
0cbd7506 | 1026 | pp_cxx_identifier (pp, "explicit"); |
12ea3302 | 1027 | else |
0cbd7506 | 1028 | pp_c_function_specifier (pp_c_base (pp), t); |
12ea3302 GDR |
1029 | |
1030 | default: | |
1031 | break; | |
1032 | } | |
1033 | } | |
1034 | ||
1035 | /* decl-specifier-seq: | |
1036 | decl-specifier-seq(opt) decl-specifier | |
1037 | ||
1038 | decl-specifier: | |
1039 | storage-class-specifier | |
1040 | type-specifier | |
1041 | function-specifier | |
1042 | friend | |
1043 | typedef */ | |
b9b44fb9 | 1044 | |
12ea3302 GDR |
1045 | static void |
1046 | pp_cxx_decl_specifier_seq (cxx_pretty_printer *pp, tree t) | |
1047 | { | |
1048 | switch (TREE_CODE (t)) | |
1049 | { | |
1050 | case VAR_DECL: | |
1051 | case PARM_DECL: | |
1052 | case CONST_DECL: | |
1053 | case FIELD_DECL: | |
1054 | pp_cxx_storage_class_specifier (pp, t); | |
1055 | pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t)); | |
1056 | break; | |
c8094d83 | 1057 | |
12ea3302 GDR |
1058 | case TYPE_DECL: |
1059 | pp_cxx_identifier (pp, "typedef"); | |
1060 | pp_cxx_decl_specifier_seq (pp, TREE_TYPE (t)); | |
1061 | break; | |
1062 | ||
1063 | case RECORD_TYPE: | |
1064 | if (TYPE_PTRMEMFUNC_P (t)) | |
0cbd7506 MS |
1065 | { |
1066 | tree pfm = TYPE_PTRMEMFUNC_FN_TYPE (t); | |
1067 | pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (pfm))); | |
1068 | pp_cxx_whitespace (pp); | |
1069 | pp_cxx_ptr_operator (pp, t); | |
1070 | } | |
12ea3302 GDR |
1071 | break; |
1072 | ||
1073 | case FUNCTION_DECL: | |
1074 | /* Constructors don't have return types. And conversion functions | |
0cbd7506 | 1075 | do not have a type-specifier in their return types. */ |
12ea3302 | 1076 | if (DECL_CONSTRUCTOR_P (t) || DECL_CONV_FN_P (t)) |
0cbd7506 | 1077 | pp_cxx_function_specifier (pp, t); |
12ea3302 | 1078 | else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t)) |
0cbd7506 | 1079 | pp_cxx_decl_specifier_seq (pp, TREE_TYPE (TREE_TYPE (t))); |
12ea3302 | 1080 | else |
0cbd7506 | 1081 | default: |
12ea3302 GDR |
1082 | pp_c_declaration_specifiers (pp_c_base (pp), t); |
1083 | break; | |
1084 | } | |
1085 | } | |
1086 | ||
1087 | /* simple-type-specifier: | |
1088 | ::(opt) nested-name-specifier(opt) type-name | |
1089 | ::(opt) nested-name-specifier(opt) template(opt) template-id | |
1090 | char | |
1091 | wchar_t | |
1092 | bool | |
1093 | short | |
1094 | int | |
1095 | long | |
1096 | signed | |
1097 | unsigned | |
1098 | float | |
1099 | double | |
1100 | void */ | |
b9b44fb9 | 1101 | |
12ea3302 GDR |
1102 | static void |
1103 | pp_cxx_simple_type_specifier (cxx_pretty_printer *pp, tree t) | |
1104 | { | |
1105 | switch (TREE_CODE (t)) | |
1106 | { | |
1107 | case RECORD_TYPE: | |
1108 | case UNION_TYPE: | |
1109 | case ENUMERAL_TYPE: | |
1110 | pp_cxx_qualified_id (pp, t); | |
1111 | break; | |
1112 | ||
1113 | case TEMPLATE_TYPE_PARM: | |
41fd3bac | 1114 | case TEMPLATE_TEMPLATE_PARM: |
12ea3302 GDR |
1115 | case TEMPLATE_PARM_INDEX: |
1116 | pp_cxx_unqualified_id (pp, t); | |
1117 | break; | |
1118 | ||
1119 | case TYPENAME_TYPE: | |
1120 | pp_cxx_identifier (pp, "typename"); | |
1121 | pp_cxx_nested_name_specifier (pp, TYPE_CONTEXT (t)); | |
1122 | pp_cxx_unqualified_id (pp, TYPE_NAME (t)); | |
1123 | break; | |
1124 | ||
1125 | default: | |
1126 | pp_c_type_specifier (pp_c_base (pp), t); | |
1127 | break; | |
1128 | } | |
1129 | } | |
1130 | ||
1131 | /* type-specifier-seq: | |
1132 | type-specifier type-specifier-seq(opt) | |
1133 | ||
1134 | type-specifier: | |
1135 | simple-type-specifier | |
1136 | class-specifier | |
1137 | enum-specifier | |
1138 | elaborated-type-specifier | |
cd0be382 | 1139 | cv-qualifier */ |
12ea3302 GDR |
1140 | |
1141 | static void | |
1142 | pp_cxx_type_specifier_seq (cxx_pretty_printer *pp, tree t) | |
1143 | { | |
12ea3302 GDR |
1144 | switch (TREE_CODE (t)) |
1145 | { | |
1146 | case TEMPLATE_DECL: | |
1147 | case TEMPLATE_TYPE_PARM: | |
41fd3bac | 1148 | case TEMPLATE_TEMPLATE_PARM: |
12ea3302 GDR |
1149 | case TYPE_DECL: |
1150 | case BOUND_TEMPLATE_TEMPLATE_PARM: | |
41fd3bac | 1151 | pp_cxx_cv_qualifier_seq (pp, t); |
12ea3302 GDR |
1152 | pp_cxx_simple_type_specifier (pp, t); |
1153 | break; | |
1154 | ||
1155 | case METHOD_TYPE: | |
1156 | pp_cxx_type_specifier_seq (pp, TREE_TYPE (t)); | |
1157 | pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (t)); | |
1158 | pp_cxx_nested_name_specifier (pp, TYPE_METHOD_BASETYPE (t)); | |
1159 | break; | |
1160 | ||
1161 | default: | |
1162 | if (!(TREE_CODE (t) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (t))) | |
0cbd7506 | 1163 | pp_c_specifier_qualifier_list (pp_c_base (pp), t); |
12ea3302 GDR |
1164 | } |
1165 | } | |
1166 | ||
1167 | /* ptr-operator: | |
1168 | * cv-qualifier-seq(opt) | |
1169 | & | |
1170 | ::(opt) nested-name-specifier * cv-qualifier-seq(opt) */ | |
1171 | ||
1172 | static void | |
1173 | pp_cxx_ptr_operator (cxx_pretty_printer *pp, tree t) | |
1174 | { | |
1175 | if (!TYPE_P (t) && TREE_CODE (t) != TYPE_DECL) | |
1176 | t = TREE_TYPE (t); | |
1177 | switch (TREE_CODE (t)) | |
1178 | { | |
1179 | case REFERENCE_TYPE: | |
1180 | case POINTER_TYPE: | |
1181 | if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE | |
0cbd7506 MS |
1182 | || TYPE_PTR_TO_MEMBER_P (TREE_TYPE (t))) |
1183 | pp_cxx_ptr_operator (pp, TREE_TYPE (t)); | |
12ea3302 | 1184 | if (TREE_CODE (t) == POINTER_TYPE) |
0cbd7506 MS |
1185 | { |
1186 | pp_star (pp); | |
1187 | pp_cxx_cv_qualifier_seq (pp, t); | |
1188 | } | |
12ea3302 | 1189 | else |
0cbd7506 | 1190 | pp_ampersand (pp); |
12ea3302 GDR |
1191 | break; |
1192 | ||
1193 | case RECORD_TYPE: | |
1194 | if (TYPE_PTRMEMFUNC_P (t)) | |
0cbd7506 MS |
1195 | { |
1196 | pp_cxx_left_paren (pp); | |
1197 | pp_cxx_nested_name_specifier (pp, TYPE_PTRMEMFUNC_OBJECT_TYPE (t)); | |
1198 | pp_star (pp); | |
1199 | break; | |
1200 | } | |
12ea3302 GDR |
1201 | case OFFSET_TYPE: |
1202 | if (TYPE_PTR_TO_MEMBER_P (t)) | |
0cbd7506 MS |
1203 | { |
1204 | if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE) | |
1205 | pp_cxx_left_paren (pp); | |
1206 | pp_cxx_nested_name_specifier (pp, TYPE_PTRMEM_CLASS_TYPE (t)); | |
1207 | pp_star (pp); | |
1208 | pp_cxx_cv_qualifier_seq (pp, t); | |
1209 | break; | |
1210 | } | |
da1d7781 | 1211 | /* else fall through. */ |
12ea3302 GDR |
1212 | |
1213 | default: | |
1214 | pp_unsupported_tree (pp, t); | |
1215 | break; | |
1216 | } | |
1217 | } | |
1218 | ||
1219 | static inline tree | |
1220 | pp_cxx_implicit_parameter_type (tree mf) | |
1221 | { | |
1222 | return TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (mf)))); | |
1223 | } | |
1224 | ||
1225 | /* | |
1226 | parameter-declaration: | |
1227 | decl-specifier-seq declarator | |
1228 | decl-specifier-seq declarator = assignment-expression | |
1229 | decl-specifier-seq abstract-declarator(opt) | |
1230 | decl-specifier-seq abstract-declarator(opt) assignment-expression */ | |
b9b44fb9 | 1231 | |
12ea3302 GDR |
1232 | static inline void |
1233 | pp_cxx_parameter_declaration (cxx_pretty_printer *pp, tree t) | |
1234 | { | |
1235 | pp_cxx_decl_specifier_seq (pp, t); | |
1236 | if (TYPE_P (t)) | |
1237 | pp_cxx_abstract_declarator (pp, t); | |
1238 | else | |
1239 | pp_cxx_declarator (pp, t); | |
1240 | } | |
1241 | ||
1242 | /* parameter-declaration-clause: | |
1243 | parameter-declaration-list(opt) ...(opt) | |
1244 | parameter-declaration-list , ... | |
1245 | ||
1246 | parameter-declaration-list: | |
1247 | parameter-declaration | |
1248 | parameter-declaration-list , parameter-declaration */ | |
b9b44fb9 | 1249 | |
12ea3302 GDR |
1250 | static void |
1251 | pp_cxx_parameter_declaration_clause (cxx_pretty_printer *pp, tree t) | |
1252 | { | |
1253 | tree args = TYPE_P (t) ? NULL : FUNCTION_FIRST_USER_PARM (t); | |
c8094d83 | 1254 | tree types = |
6615c446 | 1255 | TYPE_P (t) ? TYPE_ARG_TYPES (t) : FUNCTION_FIRST_USER_PARMTYPE (t); |
12ea3302 GDR |
1256 | const bool abstract = args == NULL |
1257 | || pp_c_base (pp)->flags & pp_c_flag_abstract; | |
1258 | bool first = true; | |
1259 | ||
1260 | /* Skip artificial parameter for nonstatic member functions. */ | |
1261 | if (TREE_CODE (t) == METHOD_TYPE) | |
1262 | types = TREE_CHAIN (types); | |
1263 | ||
1264 | pp_cxx_left_paren (pp); | |
1265 | for (; args; args = TREE_CHAIN (args), types = TREE_CHAIN (types)) | |
1266 | { | |
1267 | if (!first) | |
0cbd7506 | 1268 | pp_cxx_separate_with (pp, ','); |
12ea3302 GDR |
1269 | first = false; |
1270 | pp_cxx_parameter_declaration (pp, abstract ? TREE_VALUE (types) : args); | |
1271 | if (!abstract && pp_c_base (pp)->flags & pp_cxx_flag_default_argument) | |
0cbd7506 MS |
1272 | { |
1273 | pp_cxx_whitespace (pp); | |
1274 | pp_equal (pp); | |
1275 | pp_cxx_whitespace (pp); | |
1276 | pp_cxx_assignment_expression (pp, TREE_PURPOSE (types)); | |
1277 | } | |
12ea3302 GDR |
1278 | } |
1279 | pp_cxx_right_paren (pp); | |
1280 | } | |
1281 | ||
1282 | /* exception-specification: | |
1283 | throw ( type-id-list(opt) ) | |
1284 | ||
1285 | type-id-list | |
1286 | type-id | |
1287 | type-id-list , type-id */ | |
b9b44fb9 | 1288 | |
12ea3302 GDR |
1289 | static void |
1290 | pp_cxx_exception_specification (cxx_pretty_printer *pp, tree t) | |
1291 | { | |
1292 | tree ex_spec = TYPE_RAISES_EXCEPTIONS (t); | |
1293 | ||
1294 | if (!TYPE_NOTHROW_P (t) && ex_spec == NULL) | |
1295 | return; | |
1296 | pp_cxx_identifier (pp, "throw"); | |
1297 | pp_cxx_left_paren (pp); | |
1298 | for (; ex_spec && TREE_VALUE (ex_spec); ex_spec = TREE_CHAIN (ex_spec)) | |
1299 | { | |
1300 | pp_cxx_type_id (pp, TREE_VALUE (ex_spec)); | |
1301 | if (TREE_CHAIN (ex_spec)) | |
0cbd7506 | 1302 | pp_cxx_separate_with (pp, ','); |
12ea3302 GDR |
1303 | } |
1304 | pp_cxx_right_paren (pp); | |
1305 | } | |
1306 | ||
1307 | /* direct-declarator: | |
1308 | declarator-id | |
1309 | direct-declarator ( parameter-declaration-clause ) cv-qualifier-seq(opt) | |
0cbd7506 | 1310 | exception-specification(opt) |
12ea3302 GDR |
1311 | direct-declaration [ constant-expression(opt) ] |
1312 | ( declarator ) */ | |
b9b44fb9 | 1313 | |
12ea3302 GDR |
1314 | static void |
1315 | pp_cxx_direct_declarator (cxx_pretty_printer *pp, tree t) | |
1316 | { | |
1317 | switch (TREE_CODE (t)) | |
1318 | { | |
1319 | case VAR_DECL: | |
1320 | case PARM_DECL: | |
1321 | case CONST_DECL: | |
1322 | case FIELD_DECL: | |
1323 | if (DECL_NAME (t)) | |
0cbd7506 MS |
1324 | { |
1325 | pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (t)); | |
1326 | pp_cxx_id_expression (pp, DECL_NAME (t)); | |
1327 | } | |
12ea3302 GDR |
1328 | pp_cxx_abstract_declarator (pp, TREE_TYPE (t)); |
1329 | break; | |
c8094d83 | 1330 | |
12ea3302 GDR |
1331 | case FUNCTION_DECL: |
1332 | pp_cxx_space_for_pointer_operator (pp, TREE_TYPE (TREE_TYPE (t))); | |
1333 | pp_cxx_id_expression (pp, t); | |
1334 | pp_cxx_parameter_declaration_clause (pp, t); | |
c8094d83 | 1335 | |
12ea3302 | 1336 | if (DECL_NONSTATIC_MEMBER_FUNCTION_P (t)) |
0cbd7506 MS |
1337 | { |
1338 | pp_base (pp)->padding = pp_before; | |
1339 | pp_cxx_cv_qualifier_seq (pp, pp_cxx_implicit_parameter_type (t)); | |
1340 | } | |
12ea3302 GDR |
1341 | |
1342 | pp_cxx_exception_specification (pp, TREE_TYPE (t)); | |
1343 | break; | |
1344 | ||
1345 | case TYPENAME_TYPE: | |
1346 | case TEMPLATE_DECL: | |
1347 | case TEMPLATE_TYPE_PARM: | |
1348 | case TEMPLATE_PARM_INDEX: | |
41fd3bac | 1349 | case TEMPLATE_TEMPLATE_PARM: |
12ea3302 GDR |
1350 | break; |
1351 | ||
1352 | default: | |
1353 | pp_c_direct_declarator (pp_c_base (pp), t); | |
1354 | break; | |
1355 | } | |
1356 | } | |
1357 | ||
1358 | /* declarator: | |
1359 | direct-declarator | |
1360 | ptr-operator declarator */ | |
b9b44fb9 | 1361 | |
12ea3302 GDR |
1362 | static void |
1363 | pp_cxx_declarator (cxx_pretty_printer *pp, tree t) | |
1364 | { | |
1365 | pp_cxx_direct_declarator (pp, t); | |
1366 | } | |
1367 | ||
1368 | /* ctor-initializer: | |
1369 | : mem-initializer-list | |
1370 | ||
1371 | mem-initializer-list: | |
1372 | mem-initializer | |
1373 | mem-initializer , mem-initializer-list | |
1374 | ||
1375 | mem-initializer: | |
1376 | mem-initializer-id ( expression-list(opt) ) | |
1377 | ||
1378 | mem-initializer-id: | |
1379 | ::(opt) nested-name-specifier(opt) class-name | |
1380 | identifier */ | |
b9b44fb9 | 1381 | |
12ea3302 GDR |
1382 | static void |
1383 | pp_cxx_ctor_initializer (cxx_pretty_printer *pp, tree t) | |
1384 | { | |
1385 | t = TREE_OPERAND (t, 0); | |
1386 | pp_cxx_whitespace (pp); | |
1387 | pp_colon (pp); | |
1388 | pp_cxx_whitespace (pp); | |
1389 | for (; t; t = TREE_CHAIN (t)) | |
1390 | { | |
1391 | pp_cxx_primary_expression (pp, TREE_PURPOSE (t)); | |
1392 | pp_cxx_call_argument_list (pp, TREE_VALUE (t)); | |
1393 | if (TREE_CHAIN (t)) | |
0cbd7506 | 1394 | pp_cxx_separate_with (pp, ','); |
12ea3302 GDR |
1395 | } |
1396 | } | |
1397 | ||
1398 | /* function-definition: | |
1399 | decl-specifier-seq(opt) declarator ctor-initializer(opt) function-body | |
1400 | decl-specifier-seq(opt) declarator function-try-block */ | |
1401 | ||
b01150a2 | 1402 | static void |
12ea3302 GDR |
1403 | pp_cxx_function_definition (cxx_pretty_printer *pp, tree t) |
1404 | { | |
1405 | tree saved_scope = pp->enclosing_scope; | |
1406 | pp_cxx_decl_specifier_seq (pp, t); | |
1407 | pp_cxx_declarator (pp, t); | |
1408 | pp_needs_newline (pp) = true; | |
1409 | pp->enclosing_scope = DECL_CONTEXT (t); | |
1410 | if (DECL_SAVED_TREE (t)) | |
5882f0f3 | 1411 | pp_cxx_statement (pp, DECL_SAVED_TREE (t)); |
12ea3302 GDR |
1412 | else |
1413 | { | |
1414 | pp_cxx_semicolon (pp); | |
1415 | pp_needs_newline (pp) = true; | |
1416 | } | |
1417 | pp_flush (pp); | |
1418 | pp->enclosing_scope = saved_scope; | |
1419 | } | |
1420 | ||
1421 | /* abstract-declarator: | |
1422 | ptr-operator abstract-declarator(opt) | |
1423 | direct-abstract-declarator */ | |
b9b44fb9 | 1424 | |
12ea3302 GDR |
1425 | static void |
1426 | pp_cxx_abstract_declarator (cxx_pretty_printer *pp, tree t) | |
1427 | { | |
1428 | if (TYPE_PTRMEM_P (t) || TYPE_PTRMEMFUNC_P (t)) | |
1429 | pp_cxx_right_paren (pp); | |
1430 | else if (POINTER_TYPE_P (t)) | |
1431 | { | |
1432 | if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE | |
0cbd7506 MS |
1433 | || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE) |
1434 | pp_cxx_right_paren (pp); | |
12ea3302 GDR |
1435 | t = TREE_TYPE (t); |
1436 | } | |
1437 | pp_cxx_direct_abstract_declarator (pp, t); | |
1438 | } | |
1439 | ||
1440 | /* direct-abstract-declarator: | |
1441 | direct-abstract-declarator(opt) ( parameter-declaration-clause ) | |
0cbd7506 | 1442 | cv-qualifier-seq(opt) exception-specification(opt) |
12ea3302 GDR |
1443 | direct-abstract-declarator(opt) [ constant-expression(opt) ] |
1444 | ( abstract-declarator ) */ | |
b9b44fb9 | 1445 | |
12ea3302 GDR |
1446 | static void |
1447 | pp_cxx_direct_abstract_declarator (cxx_pretty_printer *pp, tree t) | |
1448 | { | |
1449 | switch (TREE_CODE (t)) | |
1450 | { | |
1451 | case REFERENCE_TYPE: | |
1452 | pp_cxx_abstract_declarator (pp, t); | |
1453 | break; | |
1454 | ||
1455 | case RECORD_TYPE: | |
1456 | if (TYPE_PTRMEMFUNC_P (t)) | |
0cbd7506 | 1457 | pp_cxx_direct_abstract_declarator (pp, TYPE_PTRMEMFUNC_FN_TYPE (t)); |
12ea3302 GDR |
1458 | break; |
1459 | ||
1460 | case METHOD_TYPE: | |
1461 | case FUNCTION_TYPE: | |
1462 | pp_cxx_parameter_declaration_clause (pp, t); | |
1463 | pp_cxx_direct_abstract_declarator (pp, TREE_TYPE (t)); | |
1464 | if (TREE_CODE (t) == METHOD_TYPE) | |
0cbd7506 MS |
1465 | { |
1466 | pp_base (pp)->padding = pp_before; | |
1467 | pp_cxx_cv_qualifier_seq | |
1468 | (pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t)))); | |
1469 | } | |
12ea3302 GDR |
1470 | pp_cxx_exception_specification (pp, t); |
1471 | break; | |
1472 | ||
1473 | case TYPENAME_TYPE: | |
1474 | case TEMPLATE_TYPE_PARM: | |
1475 | case TEMPLATE_TEMPLATE_PARM: | |
1476 | case BOUND_TEMPLATE_TEMPLATE_PARM: | |
1477 | case UNBOUND_CLASS_TEMPLATE: | |
1478 | break; | |
1479 | ||
1480 | default: | |
1481 | pp_c_direct_abstract_declarator (pp_c_base (pp), t); | |
c8094d83 | 1482 | break; |
12ea3302 GDR |
1483 | } |
1484 | } | |
1485 | ||
1486 | /* type-id: | |
1487 | type-specifier-seq abstract-declarator(opt) */ | |
b9b44fb9 | 1488 | |
12ea3302 GDR |
1489 | static void |
1490 | pp_cxx_type_id (cxx_pretty_printer *pp, tree t) | |
1491 | { | |
1492 | pp_flags saved_flags = pp_c_base (pp)->flags; | |
1493 | pp_c_base (pp)->flags |= pp_c_flag_abstract; | |
1494 | ||
1495 | switch (TREE_CODE (t)) | |
1496 | { | |
1497 | case TYPE_DECL: | |
1498 | case UNION_TYPE: | |
1499 | case RECORD_TYPE: | |
1500 | case ENUMERAL_TYPE: | |
1501 | case TYPENAME_TYPE: | |
1502 | case BOUND_TEMPLATE_TEMPLATE_PARM: | |
1503 | case UNBOUND_CLASS_TEMPLATE: | |
1504 | case TEMPLATE_TEMPLATE_PARM: | |
1505 | case TEMPLATE_TYPE_PARM: | |
1506 | case TEMPLATE_PARM_INDEX: | |
1507 | case TEMPLATE_DECL: | |
1508 | case TYPEOF_TYPE: | |
1509 | case TEMPLATE_ID_EXPR: | |
12ea3302 | 1510 | pp_cxx_type_specifier_seq (pp, t); |
12ea3302 GDR |
1511 | break; |
1512 | ||
1513 | default: | |
1514 | pp_c_type_id (pp_c_base (pp), t); | |
1515 | break; | |
1516 | } | |
1517 | ||
1518 | pp_c_base (pp)->flags = saved_flags; | |
1519 | } | |
1520 | ||
1521 | /* template-argument-list: | |
1522 | template-argument | |
1523 | template-argument-list, template-argument | |
1524 | ||
1525 | template-argument: | |
1526 | assignment-expression | |
1527 | type-id | |
1528 | template-name */ | |
b9b44fb9 | 1529 | |
12ea3302 GDR |
1530 | static void |
1531 | pp_cxx_template_argument_list (cxx_pretty_printer *pp, tree t) | |
1532 | { | |
1533 | int i; | |
1534 | if (t == NULL) | |
1535 | return; | |
1536 | for (i = 0; i < TREE_VEC_LENGTH (t); ++i) | |
1537 | { | |
1538 | tree arg = TREE_VEC_ELT (t, i); | |
1539 | if (i != 0) | |
0cbd7506 | 1540 | pp_cxx_separate_with (pp, ','); |
12ea3302 | 1541 | if (TYPE_P (arg) || (TREE_CODE (arg) == TEMPLATE_DECL |
6615c446 | 1542 | && TYPE_P (DECL_TEMPLATE_RESULT (arg)))) |
0cbd7506 | 1543 | pp_cxx_type_id (pp, arg); |
12ea3302 | 1544 | else |
0cbd7506 | 1545 | pp_cxx_expression (pp, arg); |
12ea3302 GDR |
1546 | } |
1547 | } | |
1548 | ||
1549 | ||
1550 | static void | |
1551 | pp_cxx_exception_declaration (cxx_pretty_printer *pp, tree t) | |
1552 | { | |
350fae66 | 1553 | t = DECL_EXPR_DECL (t); |
12ea3302 GDR |
1554 | pp_cxx_type_specifier_seq (pp, t); |
1555 | if (TYPE_P (t)) | |
1556 | pp_cxx_abstract_declarator (pp, t); | |
1557 | else | |
1558 | pp_cxx_declarator (pp, t); | |
1559 | } | |
1560 | ||
1561 | /* Statements. */ | |
1562 | ||
b01150a2 | 1563 | static void |
12ea3302 GDR |
1564 | pp_cxx_statement (cxx_pretty_printer *pp, tree t) |
1565 | { | |
1566 | switch (TREE_CODE (t)) | |
1567 | { | |
5882f0f3 RH |
1568 | case CTOR_INITIALIZER: |
1569 | pp_cxx_ctor_initializer (pp, t); | |
1570 | break; | |
1571 | ||
12ea3302 GDR |
1572 | case USING_STMT: |
1573 | pp_cxx_identifier (pp, "using"); | |
1574 | pp_cxx_identifier (pp, "namespace"); | |
91b1ca65 MM |
1575 | if (DECL_CONTEXT (t)) |
1576 | pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t)); | |
12ea3302 GDR |
1577 | pp_cxx_qualified_id (pp, USING_STMT_NAMESPACE (t)); |
1578 | break; | |
1579 | ||
1580 | case USING_DECL: | |
1581 | pp_cxx_identifier (pp, "using"); | |
98ed9dae | 1582 | pp_cxx_nested_name_specifier (pp, USING_DECL_SCOPE (t)); |
12ea3302 GDR |
1583 | pp_cxx_unqualified_id (pp, DECL_NAME (t)); |
1584 | break; | |
1585 | ||
1586 | case EH_SPEC_BLOCK: | |
1587 | break; | |
1588 | ||
1589 | /* try-block: | |
0cbd7506 | 1590 | try compound-statement handler-seq */ |
12ea3302 GDR |
1591 | case TRY_BLOCK: |
1592 | pp_maybe_newline_and_indent (pp, 0); | |
1593 | pp_cxx_identifier (pp, "try"); | |
1594 | pp_newline_and_indent (pp, 3); | |
1595 | pp_cxx_statement (pp, TRY_STMTS (t)); | |
1596 | pp_newline_and_indent (pp, -3); | |
1597 | if (CLEANUP_P (t)) | |
0cbd7506 | 1598 | ; |
12ea3302 | 1599 | else |
0cbd7506 | 1600 | pp_cxx_statement (pp, TRY_HANDLERS (t)); |
12ea3302 GDR |
1601 | break; |
1602 | ||
1603 | /* | |
0cbd7506 MS |
1604 | handler-seq: |
1605 | handler handler-seq(opt) | |
12ea3302 | 1606 | |
0cbd7506 MS |
1607 | handler: |
1608 | catch ( exception-declaration ) compound-statement | |
12ea3302 | 1609 | |
0cbd7506 MS |
1610 | exception-declaration: |
1611 | type-specifier-seq declarator | |
1612 | type-specifier-seq abstract-declarator | |
1613 | ... */ | |
12ea3302 GDR |
1614 | case HANDLER: |
1615 | pp_cxx_identifier (pp, "catch"); | |
1616 | pp_cxx_left_paren (pp); | |
1617 | pp_cxx_exception_declaration (pp, HANDLER_PARMS (t)); | |
1618 | pp_cxx_right_paren (pp); | |
1619 | pp_indentation (pp) += 3; | |
1620 | pp_needs_newline (pp) = true; | |
1621 | pp_cxx_statement (pp, HANDLER_BODY (t)); | |
1622 | pp_indentation (pp) -= 3; | |
1623 | pp_needs_newline (pp) = true; | |
1624 | break; | |
1625 | ||
5a508662 | 1626 | /* selection-statement: |
0cbd7506 MS |
1627 | if ( expression ) statement |
1628 | if ( expression ) statement else statement */ | |
5a508662 RH |
1629 | case IF_STMT: |
1630 | pp_cxx_identifier (pp, "if"); | |
1631 | pp_cxx_whitespace (pp); | |
1632 | pp_cxx_left_paren (pp); | |
1633 | pp_cxx_expression (pp, IF_COND (t)); | |
1634 | pp_cxx_right_paren (pp); | |
1635 | pp_newline_and_indent (pp, 2); | |
1636 | pp_cxx_statement (pp, THEN_CLAUSE (t)); | |
1637 | pp_newline_and_indent (pp, -2); | |
1638 | if (ELSE_CLAUSE (t)) | |
1639 | { | |
1640 | tree else_clause = ELSE_CLAUSE (t); | |
1641 | pp_cxx_identifier (pp, "else"); | |
1642 | if (TREE_CODE (else_clause) == IF_STMT) | |
1643 | pp_cxx_whitespace (pp); | |
1644 | else | |
1645 | pp_newline_and_indent (pp, 2); | |
1646 | pp_cxx_statement (pp, else_clause); | |
1647 | if (TREE_CODE (else_clause) != IF_STMT) | |
1648 | pp_newline_and_indent (pp, -2); | |
1649 | } | |
1650 | break; | |
1651 | ||
fbc315db ILT |
1652 | case SWITCH_STMT: |
1653 | pp_cxx_identifier (pp, "switch"); | |
1654 | pp_space (pp); | |
1655 | pp_cxx_left_paren (pp); | |
934790cc | 1656 | pp_cxx_expression (pp, SWITCH_STMT_COND (t)); |
fbc315db ILT |
1657 | pp_cxx_right_paren (pp); |
1658 | pp_indentation (pp) += 3; | |
1659 | pp_needs_newline (pp) = true; | |
c3e5898b | 1660 | pp_cxx_statement (pp, SWITCH_STMT_BODY (t)); |
fbc315db ILT |
1661 | pp_newline_and_indent (pp, -3); |
1662 | break; | |
1663 | ||
1664 | /* iteration-statement: | |
0cbd7506 MS |
1665 | while ( expression ) statement |
1666 | do statement while ( expression ) ; | |
1667 | for ( expression(opt) ; expression(opt) ; expression(opt) ) statement | |
1668 | for ( declaration expression(opt) ; expression(opt) ) statement */ | |
fbc315db ILT |
1669 | case WHILE_STMT: |
1670 | pp_cxx_identifier (pp, "while"); | |
1671 | pp_space (pp); | |
1672 | pp_cxx_left_paren (pp); | |
934790cc | 1673 | pp_cxx_expression (pp, WHILE_COND (t)); |
fbc315db ILT |
1674 | pp_cxx_right_paren (pp); |
1675 | pp_newline_and_indent (pp, 3); | |
c3e5898b | 1676 | pp_cxx_statement (pp, WHILE_BODY (t)); |
fbc315db ILT |
1677 | pp_indentation (pp) -= 3; |
1678 | pp_needs_newline (pp) = true; | |
1679 | break; | |
1680 | ||
1681 | case DO_STMT: | |
1682 | pp_cxx_identifier (pp, "do"); | |
1683 | pp_newline_and_indent (pp, 3); | |
c3e5898b | 1684 | pp_cxx_statement (pp, DO_BODY (t)); |
fbc315db ILT |
1685 | pp_newline_and_indent (pp, -3); |
1686 | pp_cxx_identifier (pp, "while"); | |
1687 | pp_space (pp); | |
1688 | pp_cxx_left_paren (pp); | |
934790cc | 1689 | pp_cxx_expression (pp, DO_COND (t)); |
fbc315db ILT |
1690 | pp_cxx_right_paren (pp); |
1691 | pp_cxx_semicolon (pp); | |
1692 | pp_needs_newline (pp) = true; | |
1693 | break; | |
1694 | ||
1695 | case FOR_STMT: | |
1696 | pp_cxx_identifier (pp, "for"); | |
1697 | pp_space (pp); | |
1698 | pp_cxx_left_paren (pp); | |
1699 | if (FOR_INIT_STMT (t)) | |
0cbd7506 | 1700 | pp_cxx_statement (pp, FOR_INIT_STMT (t)); |
fbc315db | 1701 | else |
0cbd7506 | 1702 | pp_cxx_semicolon (pp); |
fbc315db ILT |
1703 | pp_needs_newline (pp) = false; |
1704 | pp_cxx_whitespace (pp); | |
1705 | if (FOR_COND (t)) | |
934790cc | 1706 | pp_cxx_expression (pp, FOR_COND (t)); |
fbc315db ILT |
1707 | pp_cxx_semicolon (pp); |
1708 | pp_needs_newline (pp) = false; | |
1709 | pp_cxx_whitespace (pp); | |
1710 | if (FOR_EXPR (t)) | |
934790cc | 1711 | pp_cxx_expression (pp, FOR_EXPR (t)); |
fbc315db ILT |
1712 | pp_cxx_right_paren (pp); |
1713 | pp_newline_and_indent (pp, 3); | |
c3e5898b | 1714 | pp_cxx_statement (pp, FOR_BODY (t)); |
fbc315db ILT |
1715 | pp_indentation (pp) -= 3; |
1716 | pp_needs_newline (pp) = true; | |
1717 | break; | |
1718 | ||
1719 | /* jump-statement: | |
0cbd7506 MS |
1720 | goto identifier; |
1721 | continue ; | |
1722 | return expression(opt) ; */ | |
fbc315db ILT |
1723 | case BREAK_STMT: |
1724 | case CONTINUE_STMT: | |
1725 | pp_identifier (pp, TREE_CODE (t) == BREAK_STMT ? "break" : "continue"); | |
1726 | pp_cxx_semicolon (pp); | |
1727 | pp_needs_newline (pp) = true; | |
1728 | break; | |
1729 | ||
934790cc | 1730 | /* expression-statement: |
0cbd7506 | 1731 | expression(opt) ; */ |
934790cc ILT |
1732 | case EXPR_STMT: |
1733 | pp_cxx_expression (pp, EXPR_STMT_EXPR (t)); | |
1734 | pp_cxx_semicolon (pp); | |
1735 | pp_needs_newline (pp) = true; | |
1736 | break; | |
1737 | ||
5a508662 RH |
1738 | case CLEANUP_STMT: |
1739 | pp_cxx_identifier (pp, "try"); | |
1740 | pp_newline_and_indent (pp, 2); | |
1741 | pp_cxx_statement (pp, CLEANUP_BODY (t)); | |
1742 | pp_newline_and_indent (pp, -2); | |
1743 | pp_cxx_identifier (pp, CLEANUP_EH_ONLY (t) ? "catch" : "finally"); | |
1744 | pp_newline_and_indent (pp, 2); | |
1745 | pp_cxx_statement (pp, CLEANUP_EXPR (t)); | |
1746 | pp_newline_and_indent (pp, -2); | |
1747 | break; | |
1748 | ||
55a3debe DG |
1749 | case STATIC_ASSERT: |
1750 | pp_cxx_declaration (pp, t); | |
1751 | break; | |
1752 | ||
12ea3302 GDR |
1753 | default: |
1754 | pp_c_statement (pp_c_base (pp), t); | |
1755 | break; | |
1756 | } | |
1757 | } | |
1758 | ||
a2a9e21c GDR |
1759 | /* original-namespace-definition: |
1760 | namespace identifier { namespace-body } | |
1761 | ||
1762 | As an edge case, we also handle unnamed namespace definition here. */ | |
1763 | ||
1764 | static void | |
1765 | pp_cxx_original_namespace_definition (cxx_pretty_printer *pp, tree t) | |
1766 | { | |
1767 | pp_cxx_identifier (pp, "namespace"); | |
91b1ca65 MM |
1768 | if (DECL_CONTEXT (t)) |
1769 | pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t)); | |
ed36980c | 1770 | if (DECL_NAME (t)) |
a2a9e21c GDR |
1771 | pp_cxx_unqualified_id (pp, t); |
1772 | pp_cxx_whitespace (pp); | |
1773 | pp_cxx_left_brace (pp); | |
1774 | /* We do not print the namespace-body. */ | |
1775 | pp_cxx_whitespace (pp); | |
1776 | pp_cxx_right_brace (pp); | |
1777 | } | |
1778 | ||
1779 | /* namespace-alias: | |
1780 | identifier | |
1781 | ||
1782 | namespace-alias-definition: | |
1783 | namespace identifier = qualified-namespace-specifier ; | |
1784 | ||
1785 | qualified-namespace-specifier: | |
1786 | ::(opt) nested-name-specifier(opt) namespace-name */ | |
1787 | ||
1788 | static void | |
1789 | pp_cxx_namespace_alias_definition (cxx_pretty_printer *pp, tree t) | |
1790 | { | |
1791 | pp_cxx_identifier (pp, "namespace"); | |
91b1ca65 MM |
1792 | if (DECL_CONTEXT (t)) |
1793 | pp_cxx_nested_name_specifier (pp, DECL_CONTEXT (t)); | |
a2a9e21c GDR |
1794 | pp_cxx_unqualified_id (pp, t); |
1795 | pp_cxx_whitespace (pp); | |
1796 | pp_equal (pp); | |
1797 | pp_cxx_whitespace (pp); | |
91b1ca65 | 1798 | if (DECL_CONTEXT (DECL_NAMESPACE_ALIAS (t))) |
3db45ab5 | 1799 | pp_cxx_nested_name_specifier (pp, |
91b1ca65 | 1800 | DECL_CONTEXT (DECL_NAMESPACE_ALIAS (t))); |
a2a9e21c GDR |
1801 | pp_cxx_qualified_id (pp, DECL_NAMESPACE_ALIAS (t)); |
1802 | pp_cxx_semicolon (pp); | |
1803 | } | |
1804 | ||
12ea3302 GDR |
1805 | /* simple-declaration: |
1806 | decl-specifier-seq(opt) init-declarator-list(opt) */ | |
b9b44fb9 | 1807 | |
12ea3302 GDR |
1808 | static void |
1809 | pp_cxx_simple_declaration (cxx_pretty_printer *pp, tree t) | |
1810 | { | |
1811 | pp_cxx_decl_specifier_seq (pp, t); | |
1812 | pp_cxx_init_declarator (pp, t); | |
1813 | pp_cxx_semicolon (pp); | |
1814 | pp_needs_newline (pp) = true; | |
1815 | } | |
1816 | ||
1817 | /* | |
1818 | template-parameter-list: | |
1819 | template-parameter | |
1820 | template-parameter-list , template-parameter */ | |
1821 | ||
1822 | static inline void | |
1823 | pp_cxx_template_parameter_list (cxx_pretty_printer *pp, tree t) | |
1824 | { | |
1825 | const int n = TREE_VEC_LENGTH (t); | |
1826 | int i; | |
1827 | for (i = 0; i < n; ++i) | |
1828 | { | |
1829 | if (i) | |
0cbd7506 | 1830 | pp_cxx_separate_with (pp, ','); |
12ea3302 GDR |
1831 | pp_cxx_template_parameter (pp, TREE_VEC_ELT (t, i)); |
1832 | } | |
1833 | } | |
1834 | ||
1835 | /* template-parameter: | |
1836 | type-parameter | |
1837 | parameter-declaration | |
1838 | ||
1839 | type-parameter: | |
1840 | class identifier(opt) | |
1841 | class identifier(op) = type-id | |
1842 | typename identifier(opt) | |
1843 | typename identifier(opt) = type-id | |
1844 | template < template-parameter-list > class identifier(opt) | |
3db45ab5 | 1845 | template < template-parameter-list > class identifier(opt) = template-name */ |
b9b44fb9 | 1846 | |
12ea3302 GDR |
1847 | static void |
1848 | pp_cxx_template_parameter (cxx_pretty_printer *pp, tree t) | |
1849 | { | |
1850 | tree parameter = TREE_VALUE (t); | |
1851 | switch (TREE_CODE (parameter)) | |
1852 | { | |
1853 | case TYPE_DECL: | |
1854 | pp_cxx_identifier (pp, "class"); | |
1855 | if (DECL_NAME (parameter)) | |
0cbd7506 | 1856 | pp_cxx_tree_identifier (pp, DECL_NAME (parameter)); |
12ea3302 GDR |
1857 | /* FIXME: Chech if we should print also default argument. */ |
1858 | break; | |
1859 | ||
1860 | case PARM_DECL: | |
1861 | pp_cxx_parameter_declaration (pp, parameter); | |
1862 | break; | |
1863 | ||
1864 | case TEMPLATE_DECL: | |
1865 | break; | |
1866 | ||
1867 | default: | |
1868 | pp_unsupported_tree (pp, t); | |
1869 | break; | |
1870 | } | |
1871 | } | |
1872 | ||
b2517173 GDR |
1873 | /* Pretty-print a template parameter in the canonical form |
1874 | "template-parameter-<level>-<position in parameter list>". */ | |
1875 | ||
1876 | void | |
1877 | pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm) | |
1878 | { | |
1879 | const enum tree_code code = TREE_CODE (parm); | |
1880 | ||
04c06002 | 1881 | /* Brings type template parameters to the canonical forms. */ |
b2517173 GDR |
1882 | if (code == TEMPLATE_TYPE_PARM || code == TEMPLATE_TEMPLATE_PARM |
1883 | || code == BOUND_TEMPLATE_TEMPLATE_PARM) | |
1884 | parm = TEMPLATE_TYPE_PARM_INDEX (parm); | |
c8094d83 | 1885 | |
b2517173 GDR |
1886 | pp_cxx_begin_template_argument_list (pp); |
1887 | pp_cxx_identifier (pp, "template-parameter-"); | |
1888 | pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm)); | |
1889 | pp_minus (pp); | |
1890 | pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1); | |
1891 | pp_cxx_end_template_argument_list (pp); | |
1892 | } | |
1893 | ||
12ea3302 GDR |
1894 | /* |
1895 | template-declaration: | |
1896 | export(opt) template < template-parameter-list > declaration */ | |
b9b44fb9 | 1897 | |
12ea3302 GDR |
1898 | static void |
1899 | pp_cxx_template_declaration (cxx_pretty_printer *pp, tree t) | |
1900 | { | |
1901 | tree tmpl = most_general_template (t); | |
1902 | tree level; | |
1903 | int i = 0; | |
1904 | ||
1905 | pp_maybe_newline_and_indent (pp, 0); | |
1906 | for (level = DECL_TEMPLATE_PARMS (tmpl); level; level = TREE_CHAIN (level)) | |
1907 | { | |
1908 | pp_cxx_identifier (pp, "template"); | |
1909 | pp_cxx_begin_template_argument_list (pp); | |
1910 | pp_cxx_template_parameter_list (pp, TREE_VALUE (level)); | |
1911 | pp_cxx_end_template_argument_list (pp); | |
1912 | pp_newline_and_indent (pp, 3); | |
1913 | i += 3; | |
1914 | } | |
1915 | if (TREE_CODE (t) == FUNCTION_DECL && DECL_SAVED_TREE (t)) | |
1916 | pp_cxx_function_definition (pp, t); | |
1917 | else | |
1918 | pp_cxx_simple_declaration (pp, t); | |
1919 | } | |
1920 | ||
1921 | static void | |
1922 | pp_cxx_explicit_specialization (cxx_pretty_printer *pp, tree t) | |
1923 | { | |
1924 | pp_unsupported_tree (pp, t); | |
1925 | } | |
1926 | ||
1927 | static void | |
1928 | pp_cxx_explicit_instantiation (cxx_pretty_printer *pp, tree t) | |
1929 | { | |
1930 | pp_unsupported_tree (pp, t); | |
1931 | } | |
1932 | ||
1933 | /* | |
1934 | declaration: | |
1935 | block-declaration | |
1936 | function-definition | |
1937 | template-declaration | |
1938 | explicit-instantiation | |
1939 | explicit-specialization | |
1940 | linkage-specification | |
1941 | namespace-definition | |
1942 | ||
1943 | block-declaration: | |
1944 | simple-declaration | |
1945 | asm-definition | |
1946 | namespace-alias-definition | |
1947 | using-declaration | |
55a3debe DG |
1948 | using-directive |
1949 | static_assert-declaration */ | |
12ea3302 GDR |
1950 | void |
1951 | pp_cxx_declaration (cxx_pretty_printer *pp, tree t) | |
1952 | { | |
55a3debe DG |
1953 | if (TREE_CODE (t) == STATIC_ASSERT) |
1954 | { | |
1955 | pp_cxx_identifier (pp, "static_assert"); | |
1956 | pp_cxx_left_paren (pp); | |
1957 | pp_cxx_expression (pp, STATIC_ASSERT_CONDITION (t)); | |
1958 | pp_cxx_separate_with (pp, ','); | |
1959 | pp_cxx_expression (pp, STATIC_ASSERT_MESSAGE (t)); | |
1960 | pp_cxx_right_paren (pp); | |
1961 | } | |
1962 | else if (!DECL_LANG_SPECIFIC (t)) | |
12ea3302 | 1963 | pp_cxx_simple_declaration (pp, t); |
a2a9e21c | 1964 | else if (DECL_USE_TEMPLATE (t)) |
12ea3302 GDR |
1965 | switch (DECL_USE_TEMPLATE (t)) |
1966 | { | |
a2a9e21c | 1967 | case 1: |
0cbd7506 MS |
1968 | pp_cxx_template_declaration (pp, t); |
1969 | break; | |
c8094d83 | 1970 | |
12ea3302 | 1971 | case 2: |
0cbd7506 MS |
1972 | pp_cxx_explicit_specialization (pp, t); |
1973 | break; | |
12ea3302 GDR |
1974 | |
1975 | case 3: | |
0cbd7506 MS |
1976 | pp_cxx_explicit_instantiation (pp, t); |
1977 | break; | |
12ea3302 GDR |
1978 | |
1979 | default: | |
0cbd7506 | 1980 | break; |
12ea3302 | 1981 | } |
12ea3302 GDR |
1982 | else switch (TREE_CODE (t)) |
1983 | { | |
1984 | case VAR_DECL: | |
1985 | case TYPE_DECL: | |
1986 | pp_cxx_simple_declaration (pp, t); | |
1987 | break; | |
c8094d83 | 1988 | |
12ea3302 GDR |
1989 | case FUNCTION_DECL: |
1990 | if (DECL_SAVED_TREE (t)) | |
0cbd7506 | 1991 | pp_cxx_function_definition (pp, t); |
12ea3302 | 1992 | else |
0cbd7506 | 1993 | pp_cxx_simple_declaration (pp, t); |
12ea3302 GDR |
1994 | break; |
1995 | ||
a2a9e21c GDR |
1996 | case NAMESPACE_DECL: |
1997 | if (DECL_NAMESPACE_ALIAS (t)) | |
0cbd7506 | 1998 | pp_cxx_namespace_alias_definition (pp, t); |
a2a9e21c | 1999 | else |
0cbd7506 | 2000 | pp_cxx_original_namespace_definition (pp, t); |
a2a9e21c GDR |
2001 | break; |
2002 | ||
12ea3302 GDR |
2003 | default: |
2004 | pp_unsupported_tree (pp, t); | |
2005 | break; | |
2006 | } | |
2007 | } | |
2008 | ||
2009 | \f | |
2010 | typedef c_pretty_print_fn pp_fun; | |
2011 | ||
b9b44fb9 GDR |
2012 | /* Initialization of a C++ pretty-printer object. */ |
2013 | ||
12ea3302 GDR |
2014 | void |
2015 | pp_cxx_pretty_printer_init (cxx_pretty_printer *pp) | |
2016 | { | |
2017 | pp_c_pretty_printer_init (pp_c_base (pp)); | |
2018 | pp_set_line_maximum_length (pp, 0); | |
e1a4dd13 GDR |
2019 | |
2020 | pp->c_base.declaration = (pp_fun) pp_cxx_declaration; | |
12ea3302 GDR |
2021 | pp->c_base.declaration_specifiers = (pp_fun) pp_cxx_decl_specifier_seq; |
2022 | pp->c_base.function_specifier = (pp_fun) pp_cxx_function_specifier; | |
2023 | pp->c_base.type_specifier_seq = (pp_fun) pp_cxx_type_specifier_seq; | |
e1a4dd13 GDR |
2024 | pp->c_base.declarator = (pp_fun) pp_cxx_declarator; |
2025 | pp->c_base.direct_declarator = (pp_fun) pp_cxx_direct_declarator; | |
12ea3302 | 2026 | pp->c_base.parameter_list = (pp_fun) pp_cxx_parameter_declaration_clause; |
e1a4dd13 | 2027 | pp->c_base.type_id = (pp_fun) pp_cxx_type_id; |
12ea3302 GDR |
2028 | pp->c_base.abstract_declarator = (pp_fun) pp_cxx_abstract_declarator; |
2029 | pp->c_base.direct_abstract_declarator = | |
2030 | (pp_fun) pp_cxx_direct_abstract_declarator; | |
2031 | pp->c_base.simple_type_specifier = (pp_fun)pp_cxx_simple_type_specifier; | |
2032 | ||
2033 | /* pp->c_base.statement = (pp_fun) pp_cxx_statement; */ | |
2034 | ||
a176426f | 2035 | pp->c_base.constant = (pp_fun) pp_cxx_constant; |
4b780675 | 2036 | pp->c_base.id_expression = (pp_fun) pp_cxx_id_expression; |
e1a4dd13 GDR |
2037 | pp->c_base.primary_expression = (pp_fun) pp_cxx_primary_expression; |
2038 | pp->c_base.postfix_expression = (pp_fun) pp_cxx_postfix_expression; | |
2039 | pp->c_base.unary_expression = (pp_fun) pp_cxx_unary_expression; | |
4b780675 | 2040 | pp->c_base.multiplicative_expression = (pp_fun) pp_cxx_multiplicative_expression; |
e1a4dd13 GDR |
2041 | pp->c_base.conditional_expression = (pp_fun) pp_cxx_conditional_expression; |
2042 | pp->c_base.assignment_expression = (pp_fun) pp_cxx_assignment_expression; | |
12ea3302 GDR |
2043 | pp->c_base.expression = (pp_fun) pp_cxx_expression; |
2044 | pp->enclosing_scope = global_namespace; | |
e1a4dd13 | 2045 | } |