1 /* Perform the semantic phase of parsing, i.e., the process of
2 building tree structure, checking semantic consistency, and
3 building RTL. These routines are used both during actual parsing
4 and during the instantiation of template functions.
6 Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
7 Written by Mark Mitchell (mmitchell@usa.net) based on code found
8 formerly in parse.y and pt.c.
10 This file is part of GNU CC.
12 GNU CC is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
17 GNU CC is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with GNU CC; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
41 /* There routines provide a modular interface to perform many parsing
42 operations. They may therefore be used during actual parsing, or
43 during template instantiation, which may be regarded as a
44 degenerate form of parsing. Since the current g++ parser is
45 lacking in several respects, and will be reimplemented, we are
46 attempting to move most code that is not directly related to
47 parsing into this file; that will make implementing the new parser
48 much easier since it will be able to make use of these routines. */
50 static tree maybe_convert_cond
PARAMS ((tree
));
51 static tree simplify_aggr_init_exprs_r
PARAMS ((tree
*, int *, void *));
52 static void deferred_type_access_control
PARAMS ((void));
53 static void emit_associated_thunks
PARAMS ((tree
));
54 static void genrtl_try_block
PARAMS ((tree
));
55 static void genrtl_eh_spec_block
PARAMS ((tree
));
56 static void genrtl_handler
PARAMS ((tree
));
57 static void genrtl_catch_block
PARAMS ((tree
));
58 static void genrtl_ctor_stmt
PARAMS ((tree
));
59 static void genrtl_subobject
PARAMS ((tree
));
60 static void genrtl_named_return_value
PARAMS ((void));
61 static void cp_expand_stmt
PARAMS ((tree
));
62 static void genrtl_start_function
PARAMS ((tree
));
63 static void genrtl_finish_function
PARAMS ((tree
));
64 static tree clear_decl_rtl
PARAMS ((tree
*, int *, void *));
66 /* Finish processing the COND, the SUBSTMT condition for STMT. */
68 #define FINISH_COND(cond, stmt, substmt) \
70 if (last_tree != stmt) \
72 RECHAIN_STMTS (stmt, substmt); \
73 if (!processing_template_decl) \
75 cond = build_tree_list (substmt, cond); \
83 /* Returns non-zero if the current statement is a full expression,
84 i.e. temporaries created during that statement should be destroyed
85 at the end of the statement. */
88 stmts_are_full_exprs_p ()
90 return current_stmt_tree ()->stmts_are_full_exprs_p
;
93 /* Returns the stmt_tree (if any) to which statements are currently
94 being added. If there is no active statement-tree, NULL is
101 ? &cfun
->language
->x_stmt_tree
102 : &scope_chain
->x_stmt_tree
);
105 /* Nonzero if TYPE is an anonymous union or struct type. We have to use a
106 flag for this because "A union for which objects or pointers are
107 declared is not an anonymous union" [class.union]. */
110 anon_aggr_type_p (node
)
113 return (CLASS_TYPE_P (node
) && TYPE_LANG_SPECIFIC(node
)->anon_aggr
);
116 /* Finish a scope. */
121 tree block
= NULL_TREE
;
123 if (stmts_are_full_exprs_p ())
125 tree scope_stmts
= NULL_TREE
;
127 if (!processing_template_decl
)
128 scope_stmts
= add_scope_stmt (/*begin_p=*/0, /*partial_p=*/0);
130 block
= poplevel (kept_level_p (), 1, 0);
131 if (block
&& !processing_template_decl
)
133 SCOPE_STMT_BLOCK (TREE_PURPOSE (scope_stmts
)) = block
;
134 SCOPE_STMT_BLOCK (TREE_VALUE (scope_stmts
)) = block
;
141 /* Begin a new scope. */
146 if (stmts_are_full_exprs_p ())
149 if (!processing_template_decl
)
150 add_scope_stmt (/*begin_p=*/1, /*partial_p=*/0);
154 /* Finish a goto-statement. */
157 finish_goto_stmt (destination
)
160 if (TREE_CODE (destination
) == IDENTIFIER_NODE
)
161 destination
= lookup_label (destination
);
163 /* We warn about unused labels with -Wunused. That means we have to
164 mark the used labels as used. */
165 if (TREE_CODE (destination
) == LABEL_DECL
)
166 TREE_USED (destination
) = 1;
168 if (TREE_CODE (destination
) != LABEL_DECL
)
169 /* We don't inline calls to functions with computed gotos.
170 Those functions are typically up to some funny business,
171 and may be depending on the labels being at particular
172 addresses, or some such. */
173 DECL_UNINLINABLE (current_function_decl
) = 1;
175 check_goto (destination
);
177 return add_stmt (build_stmt (GOTO_STMT
, destination
));
180 /* COND is the condition-expression for an if, while, etc.,
181 statement. Convert it to a boolean value, if appropriate. */
184 maybe_convert_cond (cond
)
187 /* Empty conditions remain empty. */
191 /* Wait until we instantiate templates before doing conversion. */
192 if (processing_template_decl
)
195 /* Do the conversion. */
196 cond
= convert_from_reference (cond
);
197 return condition_conversion (cond
);
200 /* Finish an expression-statement, whose EXPRESSION is as indicated. */
203 finish_expr_stmt (expr
)
208 if (expr
!= NULL_TREE
)
210 if (!processing_template_decl
211 && !(stmts_are_full_exprs_p ())
212 && ((TREE_CODE (TREE_TYPE (expr
)) == ARRAY_TYPE
214 || TREE_CODE (TREE_TYPE (expr
)) == FUNCTION_TYPE
))
215 expr
= default_conversion (expr
);
217 if (stmts_are_full_exprs_p ())
218 expr
= convert_to_void (expr
, "statement");
220 r
= add_stmt (build_stmt (EXPR_STMT
, expr
));
225 /* This was an expression-statement, so we save the type of the
227 last_expr_type
= expr
? TREE_TYPE (expr
) : NULL_TREE
;
233 /* Begin an if-statement. Returns a newly created IF_STMT if
241 r
= build_stmt (IF_STMT
, NULL_TREE
, NULL_TREE
, NULL_TREE
);
246 /* Process the COND of an if-statement, which may be given by
250 finish_if_stmt_cond (cond
, if_stmt
)
254 cond
= maybe_convert_cond (cond
);
255 FINISH_COND (cond
, if_stmt
, IF_COND (if_stmt
));
258 /* Finish the then-clause of an if-statement, which may be given by
262 finish_then_clause (if_stmt
)
265 RECHAIN_STMTS (if_stmt
, THEN_CLAUSE (if_stmt
));
270 /* Begin the else-clause of an if-statement. */
277 /* Finish the else-clause of an if-statement, which may be given by
281 finish_else_clause (if_stmt
)
284 RECHAIN_STMTS (if_stmt
, ELSE_CLAUSE (if_stmt
));
287 /* Finsh an if-statement. */
299 /* If COND wasn't a declaration, clear out the
300 block we made for it and start a new one here so the
301 optimization in expand_end_loop will work. */
302 if (getdecls () == NULL_TREE
)
309 /* Begin a while-statement. Returns a newly created WHILE_STMT if
316 r
= build_stmt (WHILE_STMT
, NULL_TREE
, NULL_TREE
);
322 /* Process the COND of a while-statement, which may be given by
326 finish_while_stmt_cond (cond
, while_stmt
)
330 cond
= maybe_convert_cond (cond
);
331 FINISH_COND (cond
, while_stmt
, WHILE_COND (while_stmt
));
335 /* Finish a while-statement, which may be given by WHILE_STMT. */
338 finish_while_stmt (while_stmt
)
342 RECHAIN_STMTS (while_stmt
, WHILE_BODY (while_stmt
));
346 /* Begin a do-statement. Returns a newly created DO_STMT if
352 tree r
= build_stmt (DO_STMT
, NULL_TREE
, NULL_TREE
);
357 /* Finish the body of a do-statement, which may be given by DO_STMT. */
360 finish_do_body (do_stmt
)
363 RECHAIN_STMTS (do_stmt
, DO_BODY (do_stmt
));
366 /* Finish a do-statement, which may be given by DO_STMT, and whose
367 COND is as indicated. */
370 finish_do_stmt (cond
, do_stmt
)
374 cond
= maybe_convert_cond (cond
);
375 DO_COND (do_stmt
) = cond
;
379 /* Finish a return-statement. The EXPRESSION returned, if any, is as
383 finish_return_stmt (expr
)
388 if (!processing_template_decl
)
389 expr
= check_return_expr (expr
);
390 if (!processing_template_decl
)
392 if (DECL_CONSTRUCTOR_P (current_function_decl
) && ctor_label
)
394 /* Even returns without a value in a constructor must return
395 `this'. We accomplish this by sending all returns in a
396 constructor to the CTOR_LABEL; finish_function emits code to
397 return a value there. When we finally generate the real
398 return statement, CTOR_LABEL is no longer set, and we fall
399 through into the normal return-processing code below. */
400 return finish_goto_stmt (ctor_label
);
402 else if (DECL_DESTRUCTOR_P (current_function_decl
))
404 /* Similarly, all destructors must run destructors for
405 base-classes before returning. So, all returns in a
406 destructor get sent to the DTOR_LABEL; finsh_function emits
407 code to return a value there. */
408 return finish_goto_stmt (dtor_label
);
411 r
= add_stmt (build_stmt (RETURN_STMT
, expr
));
417 /* Begin a for-statement. Returns a new FOR_STMT if appropriate. */
424 r
= build_stmt (FOR_STMT
, NULL_TREE
, NULL_TREE
,
425 NULL_TREE
, NULL_TREE
);
426 NEW_FOR_SCOPE_P (r
) = flag_new_for_scope
> 0;
428 if (NEW_FOR_SCOPE_P (r
))
431 note_level_for_for ();
437 /* Finish the for-init-statement of a for-statement, which may be
438 given by FOR_STMT. */
441 finish_for_init_stmt (for_stmt
)
444 if (last_tree
!= for_stmt
)
445 RECHAIN_STMTS (for_stmt
, FOR_INIT_STMT (for_stmt
));
449 /* Finish the COND of a for-statement, which may be given by
453 finish_for_cond (cond
, for_stmt
)
457 cond
= maybe_convert_cond (cond
);
458 FINISH_COND (cond
, for_stmt
, FOR_COND (for_stmt
));
462 /* Finish the increment-EXPRESSION in a for-statement, which may be
463 given by FOR_STMT. */
466 finish_for_expr (expr
, for_stmt
)
470 FOR_EXPR (for_stmt
) = expr
;
473 /* Finish the body of a for-statement, which may be given by
474 FOR_STMT. The increment-EXPR for the loop must be
478 finish_for_stmt (for_stmt
)
481 /* Pop the scope for the body of the loop. */
483 RECHAIN_STMTS (for_stmt
, FOR_BODY (for_stmt
));
484 if (NEW_FOR_SCOPE_P (for_stmt
))
489 /* Finish a break-statement. */
494 return add_stmt (build_break_stmt ());
497 /* Finish a continue-statement. */
500 finish_continue_stmt ()
502 return add_stmt (build_continue_stmt ());
505 /* Begin a switch-statement. Returns a new SWITCH_STMT if
512 r
= build_stmt (SWITCH_STMT
, NULL_TREE
, NULL_TREE
);
518 /* Finish the cond of a switch-statement. */
521 finish_switch_cond (cond
, switch_stmt
)
525 if (!processing_template_decl
)
530 /* Convert the condition to an integer or enumeration type. */
531 cond
= build_expr_type_conversion (WANT_INT
| WANT_ENUM
, cond
, 1);
532 if (cond
== NULL_TREE
)
534 error ("switch quantity not an integer");
535 cond
= error_mark_node
;
537 if (cond
!= error_mark_node
)
539 cond
= default_conversion (cond
);
540 cond
= fold (build1 (CLEANUP_POINT_EXPR
, TREE_TYPE (cond
), cond
));
543 type
= TREE_TYPE (cond
);
544 index
= get_unwidened (cond
, NULL_TREE
);
545 /* We can't strip a conversion from a signed type to an unsigned,
546 because if we did, int_fits_type_p would do the wrong thing
547 when checking case values for being in range,
548 and it's too hard to do the right thing. */
549 if (TREE_UNSIGNED (TREE_TYPE (cond
))
550 == TREE_UNSIGNED (TREE_TYPE (index
)))
553 FINISH_COND (cond
, switch_stmt
, SWITCH_COND (switch_stmt
));
554 push_switch (switch_stmt
);
557 /* Finish the body of a switch-statement, which may be given by
558 SWITCH_STMT. The COND to switch on is indicated. */
561 finish_switch_stmt (switch_stmt
)
564 RECHAIN_STMTS (switch_stmt
, SWITCH_BODY (switch_stmt
));
570 /* Generate the RTL for T, which is a TRY_BLOCK. */
578 expand_eh_region_start ();
579 expand_stmt (TRY_STMTS (t
));
580 expand_eh_region_end_cleanup (TRY_HANDLERS (t
));
584 if (!FN_TRY_BLOCK_P (t
))
585 emit_line_note (input_filename
, lineno
);
587 expand_eh_region_start ();
588 expand_stmt (TRY_STMTS (t
));
590 if (FN_TRY_BLOCK_P (t
))
592 end_protect_partials ();
593 expand_start_all_catch ();
594 in_function_try_handler
= 1;
595 expand_stmt (TRY_HANDLERS (t
));
596 in_function_try_handler
= 0;
597 expand_end_all_catch ();
601 expand_start_all_catch ();
602 expand_stmt (TRY_HANDLERS (t
));
603 expand_end_all_catch ();
608 /* Generate the RTL for T, which is an EH_SPEC_BLOCK. */
611 genrtl_eh_spec_block (t
)
614 expand_eh_region_start ();
615 expand_stmt (EH_SPEC_STMTS (t
));
616 expand_eh_region_end_allowed (EH_SPEC_RAISES (t
),
617 build_call (call_unexpected_node
,
618 tree_cons (NULL_TREE
,
623 /* Begin a try-block. Returns a newly-created TRY_BLOCK if
629 tree r
= build_stmt (TRY_BLOCK
, NULL_TREE
, NULL_TREE
);
634 /* Likewise, for a function-try-block. */
637 begin_function_try_block ()
639 tree r
= build_stmt (TRY_BLOCK
, NULL_TREE
, NULL_TREE
);
640 FN_TRY_BLOCK_P (r
) = 1;
645 /* Finish a try-block, which may be given by TRY_BLOCK. */
648 finish_try_block (try_block
)
651 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
654 /* Finish the body of a cleanup try-block, which may be given by
658 finish_cleanup_try_block (try_block
)
661 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
664 /* Finish an implicitly generated try-block, with a cleanup is given
668 finish_cleanup (cleanup
, try_block
)
672 TRY_HANDLERS (try_block
) = cleanup
;
673 CLEANUP_P (try_block
) = 1;
676 /* Likewise, for a function-try-block. */
679 finish_function_try_block (try_block
)
682 if (TREE_CHAIN (try_block
)
683 && TREE_CODE (TREE_CHAIN (try_block
)) == CTOR_INITIALIZER
)
685 /* Chain the compound statement after the CTOR_INITIALIZER. */
686 TREE_CHAIN (TREE_CHAIN (try_block
)) = last_tree
;
687 /* And make the CTOR_INITIALIZER the body of the try-block. */
688 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
691 RECHAIN_STMTS (try_block
, TRY_STMTS (try_block
));
692 in_function_try_handler
= 1;
695 /* Finish a handler-sequence for a try-block, which may be given by
699 finish_handler_sequence (try_block
)
702 RECHAIN_STMTS (try_block
, TRY_HANDLERS (try_block
));
703 check_handlers (TRY_HANDLERS (try_block
));
706 /* Likewise, for a function-try-block. */
709 finish_function_handler_sequence (try_block
)
712 in_function_try_handler
= 0;
713 RECHAIN_STMTS (try_block
, TRY_HANDLERS (try_block
));
714 check_handlers (TRY_HANDLERS (try_block
));
717 /* Generate the RTL for T, which is a HANDLER. */
723 genrtl_do_pushlevel ();
724 expand_stmt (HANDLER_BODY (t
));
725 if (!processing_template_decl
)
729 /* Begin a handler. Returns a HANDLER if appropriate. */
735 r
= build_stmt (HANDLER
, NULL_TREE
, NULL_TREE
);
741 /* Finish the handler-parameters for a handler, which may be given by
742 HANDLER. DECL is the declaration for the catch parameter, or NULL
743 if this is a `catch (...)' clause. */
746 finish_handler_parms (decl
, handler
)
750 tree blocks
= NULL_TREE
;
752 if (processing_template_decl
)
756 decl
= pushdecl (decl
);
757 decl
= push_template_decl (decl
);
758 add_decl_stmt (decl
);
759 RECHAIN_STMTS (handler
, HANDLER_PARMS (handler
));
763 blocks
= expand_start_catch_block (decl
);
766 TREE_TYPE (handler
) = TREE_TYPE (decl
);
771 /* Generate the RTL for a START_CATCH_STMT. */
774 genrtl_catch_block (type
)
777 expand_start_catch (type
);
780 /* Note the beginning of a handler for TYPE. This function is called
781 at the point to which control should be transferred when an
782 appropriately-typed exception is thrown. */
785 begin_catch_block (type
)
788 add_stmt (build (START_CATCH_STMT
, type
));
791 /* Finish a handler, which may be given by HANDLER. The BLOCKs are
792 the return value from the matching call to finish_handler_parms. */
795 finish_handler (blocks
, handler
)
799 if (!processing_template_decl
)
800 expand_end_catch_block (blocks
);
802 RECHAIN_STMTS (handler
, HANDLER_BODY (handler
));
805 /* Generate the RTL for T, which is a CTOR_STMT. */
811 if (CTOR_BEGIN_P (t
))
812 begin_protect_partials ();
814 /* After this point, any exceptions will cause the
815 destructor to be executed, so we no longer need to worry
816 about destroying the various subobjects ourselves. */
817 end_protect_partials ();
820 /* Begin a compound-statement. If HAS_NO_SCOPE is non-zero, the
821 compound-statement does not define a scope. Returns a new
822 COMPOUND_STMT if appropriate. */
825 begin_compound_stmt (has_no_scope
)
831 r
= build_stmt (COMPOUND_STMT
, NULL_TREE
);
833 if (last_tree
&& TREE_CODE (last_tree
) == TRY_BLOCK
)
838 COMPOUND_STMT_NO_SCOPE (r
) = 1;
840 last_expr_type
= NULL_TREE
;
846 note_level_for_try ();
849 /* Normally, we try hard to keep the BLOCK for a
850 statement-expression. But, if it's a statement-expression with
851 a scopeless block, there's nothing to keep, and we don't want
852 to accidentally keep a block *inside* the scopeless block. */
855 /* If this is the outermost block of the function, declare the
856 variables __FUNCTION__, __PRETTY_FUNCTION__, and so forth. */
858 && !function_name_declared_p
861 function_name_declared_p
= 1;
862 declare_function_name ();
868 /* Finish a compound-statement, which may be given by COMPOUND_STMT.
869 If HAS_NO_SCOPE is non-zero, the compound statement does not define
873 finish_compound_stmt (has_no_scope
, compound_stmt
)
885 RECHAIN_STMTS (compound_stmt
, COMPOUND_BODY (compound_stmt
));
887 /* When we call finish_stmt we will lose LAST_EXPR_TYPE. But, since
888 the precise purpose of that variable is store the type of the
889 last expression statement within the last compound statement, we
890 preserve the value. */
898 /* Finish an asm-statement, whose components are a CV_QUALIFIER, a
899 STRING, some OUTPUT_OPERANDS, some INPUT_OPERANDS, and some
903 finish_asm_stmt (cv_qualifier
, string
, output_operands
,
904 input_operands
, clobbers
)
907 tree output_operands
;
914 if (TREE_CHAIN (string
))
915 string
= combine_strings (string
);
917 if (cv_qualifier
!= NULL_TREE
918 && cv_qualifier
!= ridpointers
[(int) RID_VOLATILE
])
920 cp_warning ("%s qualifier ignored on asm",
921 IDENTIFIER_POINTER (cv_qualifier
));
922 cv_qualifier
= NULL_TREE
;
925 if (!processing_template_decl
)
926 for (t
= input_operands
; t
; t
= TREE_CHAIN (t
))
928 tree converted_operand
929 = decay_conversion (TREE_VALUE (t
));
931 /* If the type of the operand hasn't been determined (e.g.,
932 because it involves an overloaded function), then issue an
933 error message. There's no context available to resolve the
935 if (TREE_TYPE (converted_operand
) == unknown_type_node
)
937 cp_error ("type of asm operand `%E' could not be determined",
939 converted_operand
= error_mark_node
;
941 TREE_VALUE (t
) = converted_operand
;
944 r
= build_stmt (ASM_STMT
, cv_qualifier
, string
,
945 output_operands
, input_operands
,
950 /* Finish a label with the indicated NAME. */
953 finish_label_stmt (name
)
956 tree decl
= define_label (input_filename
, lineno
, name
);
957 add_stmt (build_stmt (LABEL_STMT
, decl
));
960 /* Finish a series of declarations for local labels. G++ allows users
961 to declare "local" labels, i.e., labels with scope. This extension
962 is useful when writing code involving statement-expressions. */
965 finish_label_decl (name
)
968 tree decl
= declare_local_label (name
);
969 add_decl_stmt (decl
);
972 /* Generate the RTL for a SUBOBJECT. */
975 genrtl_subobject (cleanup
)
978 add_partial_entry (cleanup
);
981 /* We're in a constructor, and have just constructed a a subobject of
982 *THIS. CLEANUP is code to run if an exception is thrown before the
983 end of the current function is reached. */
986 finish_subobject (cleanup
)
989 tree r
= build_stmt (SUBOBJECT
, cleanup
);
993 /* When DECL goes out of scope, make sure that CLEANUP is executed. */
996 finish_decl_cleanup (decl
, cleanup
)
1000 add_stmt (build_stmt (CLEANUP_STMT
, decl
, cleanup
));
1003 /* Generate the RTL for a RETURN_INIT. */
1006 genrtl_named_return_value ()
1008 tree decl
= DECL_RESULT (current_function_decl
);
1010 /* If this named return value comes in a register, put it in a
1012 if (DECL_REGISTER (decl
))
1014 /* Note that the mode of the old DECL_RTL may be wider than the
1015 mode of DECL_RESULT, depending on the calling conventions for
1016 the processor. For example, on the Alpha, a 32-bit integer
1017 is returned in a DImode register -- the DECL_RESULT has
1018 SImode but the DECL_RTL for the DECL_RESULT has DImode. So,
1019 here, we use the mode the back-end has already assigned for
1020 the return value. */
1021 SET_DECL_RTL (decl
, gen_reg_rtx (GET_MODE (DECL_RTL (decl
))));
1022 if (TREE_ADDRESSABLE (decl
))
1023 put_var_into_stack (decl
);
1026 emit_local_var (decl
);
1029 /* Bind a name and initialization to the return value of
1030 the current function. */
1033 finish_named_return_value (return_id
, init
)
1034 tree return_id
, init
;
1036 tree decl
= DECL_RESULT (current_function_decl
);
1038 /* Give this error as many times as there are occurrences, so that
1039 users can use Emacs compilation buffers to find and fix all such
1042 pedwarn ("ISO C++ does not permit named return values");
1043 cp_deprecated ("the named return value extension");
1045 if (return_id
!= NULL_TREE
)
1047 if (DECL_NAME (decl
) == NULL_TREE
)
1048 DECL_NAME (decl
) = return_id
;
1051 cp_error ("return identifier `%D' already in place", return_id
);
1056 /* Can't let this happen for constructors. */
1057 if (DECL_CONSTRUCTOR_P (current_function_decl
))
1059 error ("can't redefine default return value for constructors");
1063 /* If we have a named return value, put that in our scope as well. */
1064 if (DECL_NAME (decl
) != NULL_TREE
)
1066 /* Let `cp_finish_decl' know that this initializer is ok. */
1067 DECL_INITIAL (decl
) = init
;
1068 if (doing_semantic_analysis_p ())
1070 if (!processing_template_decl
)
1072 cp_finish_decl (decl
, init
, NULL_TREE
, 0);
1073 add_stmt (build_stmt (RETURN_INIT
, NULL_TREE
, NULL_TREE
));
1076 add_stmt (build_stmt (RETURN_INIT
, return_id
, init
));
1079 /* Don't use tree-inlining for functions with named return values.
1080 That doesn't work properly because we don't do any translation of
1081 the RETURN_INITs when they are copied. */
1082 DECL_UNINLINABLE (current_function_decl
) = 1;
1085 /* The INIT_LIST is a list of mem-initializers, in the order they were
1086 written by the user. The TREE_VALUE of each node is a list of
1087 initializers for a particular subobject. The TREE_PURPOSE is a
1088 FIELD_DECL is the initializer is for a non-static data member, and
1089 a class type if the initializer is for a base class. */
1092 finish_mem_initializers (init_list
)
1095 tree member_init_list
;
1096 tree base_init_list
;
1097 tree last_base_warned_about
;
1101 member_init_list
= NULL_TREE
;
1102 base_init_list
= NULL_TREE
;
1103 last_base_warned_about
= NULL_TREE
;
1105 for (init
= init_list
; init
; init
= next
)
1107 next
= TREE_CHAIN (init
);
1108 if (TREE_CODE (TREE_PURPOSE (init
)) == FIELD_DECL
)
1110 TREE_CHAIN (init
) = member_init_list
;
1111 member_init_list
= init
;
1113 /* We're running through the initializers from right to left
1114 as we process them here. So, if we see a data member
1115 initializer after we see a base initializer, that
1116 actually means that the base initializer preceeded the
1117 data member initializer. */
1118 if (warn_reorder
&& last_base_warned_about
!= base_init_list
)
1122 for (base
= base_init_list
;
1123 base
!= last_base_warned_about
;
1124 base
= TREE_CHAIN (base
))
1126 cp_warning ("base initializer for `%T'",
1127 TREE_PURPOSE (base
));
1128 warning (" will be re-ordered to precede member initializations");
1131 last_base_warned_about
= base_init_list
;
1136 TREE_CHAIN (init
) = base_init_list
;
1137 base_init_list
= init
;
1141 setup_vtbl_ptr (member_init_list
, base_init_list
);
1144 /* Cache the value of this class's main virtual function table pointer
1145 in a register variable. This will save one indirection if a
1146 more than one virtual function call is made this function. */
1149 setup_vtbl_ptr (member_init_list
, base_init_list
)
1150 tree member_init_list
;
1151 tree base_init_list
;
1153 my_friendly_assert (doing_semantic_analysis_p (), 19990919);
1155 /* If we've already done this, there's no need to do it again. */
1159 if (DECL_CONSTRUCTOR_P (current_function_decl
))
1161 if (processing_template_decl
)
1162 add_stmt (build_min_nt
1164 member_init_list
, base_init_list
));
1169 /* Mark the beginning of the constructor. */
1170 ctor_stmt
= build_stmt (CTOR_STMT
);
1171 CTOR_BEGIN_P (ctor_stmt
) = 1;
1172 add_stmt (ctor_stmt
);
1174 /* And actually initialize the base-classes and members. */
1175 emit_base_init (member_init_list
, base_init_list
);
1178 else if (DECL_DESTRUCTOR_P (current_function_decl
)
1179 && !processing_template_decl
)
1185 /* If the dtor is empty, and we know there is not any possible
1186 way we could use any vtable entries, before they are possibly
1187 set by a base class dtor, we don't have to setup the vtables,
1188 as we know that any base class dtor will set up any vtables
1189 it needs. We avoid MI, because one base class dtor can do a
1190 virtual dispatch to an overridden function that would need to
1191 have a non-related vtable set up, we cannot avoid setting up
1192 vtables in that case. We could change this to see if there
1193 is just one vtable. */
1194 if_stmt
= begin_if_stmt ();
1196 /* If it is not safe to avoid setting up the vtables, then
1197 someone will change the condition to be boolean_true_node.
1198 (Actually, for now, we do not have code to set the condition
1199 appropriately, so we just assume that we always need to
1200 initialize the vtables.) */
1201 finish_if_stmt_cond (boolean_true_node
, if_stmt
);
1202 current_vcalls_possible_p
= &IF_COND (if_stmt
);
1204 /* Don't declare __PRETTY_FUNCTION__ and friends here when we
1205 open the block for the if-body. */
1206 saved_cfnd
= function_name_declared_p
;
1207 function_name_declared_p
= 1;
1208 compound_stmt
= begin_compound_stmt (/*has_no_scope=*/0);
1209 function_name_declared_p
= saved_cfnd
;
1211 /* Make all virtual function table pointers in non-virtual base
1212 classes point to CURRENT_CLASS_TYPE's virtual function
1214 initialize_vtbl_ptrs (current_class_ptr
);
1216 finish_compound_stmt (/*has_no_scope=*/0, compound_stmt
);
1217 finish_then_clause (if_stmt
);
1221 /* Always keep the BLOCK node associated with the outermost pair of
1222 curly braces of a function. These are needed for correct
1223 operation of dwarfout.c. */
1224 keep_next_level (1);
1226 /* The virtual function tables are set up now. */
1230 /* Returns the stack of SCOPE_STMTs for the current function. */
1233 current_scope_stmt_stack ()
1235 return &cfun
->language
->x_scope_stmt_stack
;
1238 /* Finish a parenthesized expression EXPR. */
1241 finish_parenthesized_expr (expr
)
1244 if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (expr
))))
1245 /* This inhibits warnings in truthvalue_conversion. */
1246 C_SET_EXP_ORIGINAL_CODE (expr
, ERROR_MARK
);
1248 if (TREE_CODE (expr
) == OFFSET_REF
)
1249 /* [expr.unary.op]/3 The qualified id of a pointer-to-member must not be
1250 enclosed in parentheses. */
1251 PTRMEM_OK_P (expr
) = 0;
1255 /* Begin a statement-expression. The value returned must be passed to
1256 finish_stmt_expr. */
1261 /* If we're outside a function, we won't have a statement-tree to
1262 work with. But, if we see a statement-expression we need to
1264 if (! cfun
&& !last_tree
)
1265 begin_stmt_tree (&scope_chain
->x_saved_tree
);
1267 keep_next_level (1);
1268 /* If we're building a statement tree, then the upcoming compound
1269 statement will be chained onto the tree structure, starting at
1270 last_tree. We return last_tree so that we can later unhook the
1271 compound statement. */
1275 /* Used when beginning a statement-expression outside function scope.
1276 For example, when handling a file-scope initializer, we use this
1280 begin_global_stmt_expr ()
1282 if (! cfun
&& !last_tree
)
1283 begin_stmt_tree (&scope_chain
->x_saved_tree
);
1285 keep_next_level (1);
1287 return (last_tree
!= NULL_TREE
) ? last_tree
: expand_start_stmt_expr();
1290 /* Finish the STMT_EXPR last begun with begin_global_stmt_expr. */
1293 finish_global_stmt_expr (stmt_expr
)
1296 stmt_expr
= expand_end_stmt_expr (stmt_expr
);
1299 && TREE_CHAIN (scope_chain
->x_saved_tree
) == NULL_TREE
)
1300 finish_stmt_tree (&scope_chain
->x_saved_tree
);
1305 /* Finish a statement-expression. RTL_EXPR should be the value
1306 returned by the previous begin_stmt_expr; EXPR is the
1307 statement-expression. Returns an expression representing the
1308 statement-expression. */
1311 finish_stmt_expr (rtl_expr
)
1316 /* If the last thing in the statement-expression was not an
1317 expression-statement, then it has type `void'. */
1318 if (!last_expr_type
)
1319 last_expr_type
= void_type_node
;
1320 result
= build_min (STMT_EXPR
, last_expr_type
, last_tree
);
1321 TREE_SIDE_EFFECTS (result
) = 1;
1323 /* Remove the compound statement from the tree structure; it is
1324 now saved in the STMT_EXPR. */
1325 last_tree
= rtl_expr
;
1326 TREE_CHAIN (last_tree
) = NULL_TREE
;
1328 /* If we created a statement-tree for this statement-expression,
1331 && TREE_CHAIN (scope_chain
->x_saved_tree
) == NULL_TREE
)
1332 finish_stmt_tree (&scope_chain
->x_saved_tree
);
1337 /* Finish a call to FN with ARGS. Returns a representation of the
1341 finish_call_expr (fn
, args
, koenig
)
1350 if (TREE_CODE (fn
) == BIT_NOT_EXPR
)
1351 fn
= build_x_unary_op (BIT_NOT_EXPR
, TREE_OPERAND (fn
, 0));
1352 else if (TREE_CODE (fn
) != TEMPLATE_ID_EXPR
)
1353 fn
= do_identifier (fn
, 2, args
);
1355 result
= build_x_function_call (fn
, args
, current_class_ref
);
1357 if (TREE_CODE (result
) == CALL_EXPR
1358 && (! TREE_TYPE (result
)
1359 || TREE_CODE (TREE_TYPE (result
)) != VOID_TYPE
))
1360 result
= require_complete_type (result
);
1365 /* Finish a call to a postfix increment or decrement or EXPR. (Which
1366 is indicated by CODE, which should be POSTINCREMENT_EXPR or
1367 POSTDECREMENT_EXPR.) */
1370 finish_increment_expr (expr
, code
)
1372 enum tree_code code
;
1374 /* If we get an OFFSET_REF, turn it into what it really means (e.g.,
1375 a COMPONENT_REF). This way if we've got, say, a reference to a
1376 static member that's being operated on, we don't end up trying to
1377 find a member operator for the class it's in. */
1379 if (TREE_CODE (expr
) == OFFSET_REF
)
1380 expr
= resolve_offset_ref (expr
);
1381 return build_x_unary_op (code
, expr
);
1384 /* Finish a use of `this'. Returns an expression for `this'. */
1391 if (current_class_ptr
)
1393 #ifdef WARNING_ABOUT_CCD
1394 TREE_USED (current_class_ptr
) = 1;
1396 result
= current_class_ptr
;
1398 else if (current_function_decl
1399 && DECL_STATIC_FUNCTION_P (current_function_decl
))
1401 error ("`this' is unavailable for static member functions");
1402 result
= error_mark_node
;
1406 if (current_function_decl
)
1407 error ("invalid use of `this' in non-member function");
1409 error ("invalid use of `this' at top level");
1410 result
= error_mark_node
;
1416 /* Finish a member function call using OBJECT and ARGS as arguments to
1417 FN. Returns an expression for the call. */
1420 finish_object_call_expr (fn
, object
, args
)
1426 /* This is a future direction of this code, but because
1427 build_x_function_call cannot always undo what is done in
1428 build_component_ref entirely yet, we cannot do this. */
1430 tree real_fn
= build_component_ref (object
, fn
, NULL_TREE
, 1);
1431 return finish_call_expr (real_fn
, args
);
1433 if (DECL_DECLARES_TYPE_P (fn
))
1435 if (processing_template_decl
)
1436 /* This can happen on code like:
1439 template <class T> void f(T t) {
1443 We just grab the underlying IDENTIFIER. */
1444 fn
= DECL_NAME (fn
);
1447 cp_error ("calling type `%T' like a method", fn
);
1448 return error_mark_node
;
1452 return build_method_call (object
, fn
, args
, NULL_TREE
, LOOKUP_NORMAL
);
1456 /* Finish a qualified member function call using OBJECT and ARGS as
1457 arguments to FN. Returns an expression for the call. */
1460 finish_qualified_object_call_expr (fn
, object
, args
)
1465 return build_scoped_method_call (object
, TREE_OPERAND (fn
, 0),
1466 TREE_OPERAND (fn
, 1), args
);
1469 /* Finish a pseudo-destructor call expression of OBJECT, with SCOPE
1470 being the scope, if any, of DESTRUCTOR. Returns an expression for
1474 finish_pseudo_destructor_call_expr (object
, scope
, destructor
)
1479 if (processing_template_decl
)
1480 return build_min_nt (PSEUDO_DTOR_EXPR
, object
, scope
, destructor
);
1482 if (scope
&& scope
!= destructor
)
1483 cp_error ("destructor specifier `%T::~%T()' must have matching names",
1486 if ((scope
== NULL_TREE
|| IDENTIFIER_GLOBAL_VALUE (destructor
))
1487 && (TREE_CODE (TREE_TYPE (object
)) !=
1488 TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (destructor
)))))
1489 cp_error ("`%E' is not of type `%T'", object
, destructor
);
1491 return cp_convert (void_type_node
, object
);
1494 /* Finish a call to a globally qualified member function FN using
1495 ARGS. Returns an expression for the call. */
1498 finish_qualified_call_expr (fn
, args
)
1502 if (processing_template_decl
)
1503 return build_min_nt (CALL_EXPR
, fn
, args
, NULL_TREE
);
1505 return build_member_call (TREE_OPERAND (fn
, 0),
1506 TREE_OPERAND (fn
, 1),
1510 /* Finish an expression taking the address of LABEL. Returns an
1511 expression for the address. */
1514 finish_label_address_expr (label
)
1519 label
= lookup_label (label
);
1520 if (label
== NULL_TREE
)
1521 result
= null_pointer_node
;
1524 TREE_USED (label
) = 1;
1525 result
= build1 (ADDR_EXPR
, ptr_type_node
, label
);
1526 TREE_CONSTANT (result
) = 1;
1527 /* This function cannot be inlined. All jumps to the addressed
1528 label should wind up at the same point. */
1529 DECL_UNINLINABLE (current_function_decl
) = 1;
1535 /* Finish an expression of the form CODE EXPR. */
1538 finish_unary_op_expr (code
, expr
)
1539 enum tree_code code
;
1542 tree result
= build_x_unary_op (code
, expr
);
1543 /* Inside a template, build_x_unary_op does not fold the
1544 expression. So check whether the result is folded before
1545 setting TREE_NEGATED_INT. */
1546 if (code
== NEGATE_EXPR
&& TREE_CODE (expr
) == INTEGER_CST
1547 && TREE_CODE (result
) == INTEGER_CST
1548 && !TREE_UNSIGNED (TREE_TYPE (result
))
1549 && INT_CST_LT (result
, integer_zero_node
))
1550 TREE_NEGATED_INT (result
) = 1;
1551 overflow_warning (result
);
1555 /* Finish an id-expression. */
1558 finish_id_expr (expr
)
1561 if (TREE_CODE (expr
) == IDENTIFIER_NODE
)
1562 expr
= do_identifier (expr
, 1, NULL_TREE
);
1564 if (TREE_TYPE (expr
) == error_mark_node
)
1565 expr
= error_mark_node
;
1569 static tree current_type_lookups
;
1571 /* Perform deferred access control for types used in the type of a
1575 deferred_type_access_control ()
1577 tree lookup
= type_lookups
;
1579 if (lookup
== error_mark_node
)
1582 for (; lookup
; lookup
= TREE_CHAIN (lookup
))
1583 enforce_access (TREE_PURPOSE (lookup
), TREE_VALUE (lookup
));
1587 decl_type_access_control (decl
)
1592 if (type_lookups
== error_mark_node
)
1595 save_fn
= current_function_decl
;
1597 if (decl
&& TREE_CODE (decl
) == FUNCTION_DECL
)
1598 current_function_decl
= decl
;
1600 deferred_type_access_control ();
1602 current_function_decl
= save_fn
;
1604 /* Now strip away the checks for the current declarator; they were
1605 added to type_lookups after typed_declspecs saved the copy that
1606 ended up in current_type_lookups. */
1607 type_lookups
= current_type_lookups
;
1609 current_type_lookups
= NULL_TREE
;
1612 /* Record the lookups, if we're doing deferred access control. */
1615 save_type_access_control (lookups
)
1618 if (type_lookups
!= error_mark_node
)
1620 my_friendly_assert (!current_type_lookups
, 20010301);
1621 current_type_lookups
= lookups
;
1624 my_friendly_assert (!lookups
|| lookups
== error_mark_node
, 20010301);
1627 /* Set things up so that the next deferred access control will succeed.
1628 This is needed for friend declarations see grokdeclarator for details. */
1631 skip_type_access_control ()
1633 type_lookups
= NULL_TREE
;
1636 /* Reset the deferred access control. */
1639 reset_type_access_control ()
1641 type_lookups
= NULL_TREE
;
1642 current_type_lookups
= NULL_TREE
;
1645 /* Begin a function definition declared with DECL_SPECS and
1646 DECLARATOR. Returns non-zero if the function-declaration is
1650 begin_function_definition (decl_specs
, declarator
)
1657 split_specs_attrs (decl_specs
, &specs
, &attrs
);
1658 if (!start_function (specs
, declarator
, attrs
, SF_DEFAULT
))
1661 deferred_type_access_control ();
1662 type_lookups
= error_mark_node
;
1664 /* The things we're about to see are not directly qualified by any
1665 template headers we've seen thus far. */
1666 reset_specialization ();
1671 /* Begin a constructor declarator of the form `SCOPE::NAME'. Returns
1675 begin_constructor_declarator (scope
, name
)
1679 tree result
= build_nt (SCOPE_REF
, scope
, name
);
1680 enter_scope_of (result
);
1684 /* Finish an init-declarator. Returns a DECL. */
1687 finish_declarator (declarator
, declspecs
, attributes
,
1688 prefix_attributes
, initialized
)
1692 tree prefix_attributes
;
1695 return start_decl (declarator
, declspecs
, initialized
, attributes
,
1699 /* Finish a translation unit. */
1702 finish_translation_unit ()
1704 /* In case there were missing closebraces,
1705 get us back to the global binding level. */
1707 while (current_namespace
!= global_namespace
)
1712 /* Finish a template type parameter, specified as AGGR IDENTIFIER.
1713 Returns the parameter. */
1716 finish_template_type_parm (aggr
, identifier
)
1720 if (aggr
!= class_type_node
)
1722 pedwarn ("template type parameters must use the keyword `class' or `typename'");
1723 aggr
= class_type_node
;
1726 return build_tree_list (aggr
, identifier
);
1729 /* Finish a template template parameter, specified as AGGR IDENTIFIER.
1730 Returns the parameter. */
1733 finish_template_template_parm (aggr
, identifier
)
1737 tree decl
= build_decl (TYPE_DECL
, identifier
, NULL_TREE
);
1738 tree tmpl
= build_lang_decl (TEMPLATE_DECL
, identifier
, NULL_TREE
);
1739 DECL_TEMPLATE_PARMS (tmpl
) = current_template_parms
;
1740 DECL_TEMPLATE_RESULT (tmpl
) = decl
;
1741 DECL_ARTIFICIAL (decl
) = 1;
1742 end_template_decl ();
1744 my_friendly_assert (DECL_TEMPLATE_PARMS (tmpl
), 20010110);
1746 return finish_template_type_parm (aggr
, tmpl
);
1749 /* Finish a parameter list, indicated by PARMS. If ELLIPSIS is
1750 non-zero, the parameter list was terminated by a `...'. */
1753 finish_parmlist (parms
, ellipsis
)
1759 /* We mark the PARMS as a parmlist so that declarator processing can
1760 disambiguate certain constructs. */
1761 TREE_PARMLIST (parms
) = 1;
1762 /* We do not append void_list_node here, but leave it to grokparms
1764 PARMLIST_ELLIPSIS_P (parms
) = ellipsis
;
1769 /* Begin a class definition, as indicated by T. */
1772 begin_class_definition (t
)
1775 /* Check the bases are accessible. */
1776 decl_type_access_control (TYPE_NAME (t
));
1777 reset_type_access_control ();
1779 if (processing_template_parmlist
)
1781 cp_error ("definition of `%#T' inside template parameter list", t
);
1782 return error_mark_node
;
1784 if (t
== error_mark_node
1785 || ! IS_AGGR_TYPE (t
))
1787 t
= make_aggr_type (RECORD_TYPE
);
1788 pushtag (make_anon_name (), t
, 0);
1791 /* In a definition of a member class template, we will get here with an
1792 implicit typename, a TYPENAME_TYPE with a type. */
1793 if (TREE_CODE (t
) == TYPENAME_TYPE
)
1796 /* If we generated a partial instantiation of this type, but now
1797 we're seeing a real definition, we're actually looking at a
1798 partial specialization. Consider:
1800 template <class T, class U>
1806 template <class T, class U>
1809 typename X<Y<T, U> >::A a;
1812 template <class T, class U>
1817 We have to undo the effects of the previous partial
1819 if (PARTIAL_INSTANTIATION_P (t
))
1823 /* Unfortunately, when we're not in pedantic mode, we
1824 attempt to actually fill in some of the fields of the
1825 partial instantiation, in order to support the implicit
1826 typename extension. Clear those fields now, in
1827 preparation for the definition here. The fields cleared
1828 here must match those set in instantiate_class_template.
1829 Look for a comment mentioning begin_class_definition
1831 TYPE_BINFO_BASETYPES (t
) = NULL_TREE
;
1832 TYPE_FIELDS (t
) = NULL_TREE
;
1833 TYPE_METHODS (t
) = NULL_TREE
;
1834 CLASSTYPE_TAGS (t
) = NULL_TREE
;
1835 CLASSTYPE_VBASECLASSES (t
) = NULL_TREE
;
1836 TYPE_SIZE (t
) = NULL_TREE
;
1839 /* This isn't a partial instantiation any more. */
1840 PARTIAL_INSTANTIATION_P (t
) = 0;
1842 /* If this type was already complete, and we see another definition,
1844 else if (COMPLETE_TYPE_P (t
))
1845 duplicate_tag_error (t
);
1847 /* Update the location of the decl. */
1848 DECL_SOURCE_FILE (TYPE_NAME (t
)) = input_filename
;
1849 DECL_SOURCE_LINE (TYPE_NAME (t
)) = lineno
;
1851 if (TYPE_BEING_DEFINED (t
))
1853 t
= make_aggr_type (TREE_CODE (t
));
1854 pushtag (TYPE_IDENTIFIER (t
), t
, 0);
1856 maybe_process_partial_specialization (t
);
1858 TYPE_BEING_DEFINED (t
) = 1;
1859 TYPE_PACKED (t
) = flag_pack_struct
;
1860 /* Reset the interface data, at the earliest possible
1861 moment, as it might have been set via a class foo;
1863 if (! TYPE_ANONYMOUS_P (t
))
1865 CLASSTYPE_INTERFACE_ONLY (t
) = interface_only
;
1866 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
1867 (t
, interface_unknown
);
1869 reset_specialization();
1871 /* Make a declaration for this class in its own scope. */
1872 build_self_reference ();
1877 /* Finish the member declaration given by DECL. */
1880 finish_member_declaration (decl
)
1883 if (decl
== error_mark_node
|| decl
== NULL_TREE
)
1886 if (decl
== void_type_node
)
1887 /* The COMPONENT was a friend, not a member, and so there's
1888 nothing for us to do. */
1891 /* We should see only one DECL at a time. */
1892 my_friendly_assert (TREE_CHAIN (decl
) == NULL_TREE
, 0);
1894 /* Set up access control for DECL. */
1896 = (current_access_specifier
== access_private_node
);
1897 TREE_PROTECTED (decl
)
1898 = (current_access_specifier
== access_protected_node
);
1899 if (TREE_CODE (decl
) == TEMPLATE_DECL
)
1901 TREE_PRIVATE (DECL_TEMPLATE_RESULT (decl
)) = TREE_PRIVATE (decl
);
1902 TREE_PROTECTED (DECL_TEMPLATE_RESULT (decl
)) = TREE_PROTECTED (decl
);
1905 /* Mark the DECL as a member of the current class. */
1906 DECL_CONTEXT (decl
) = current_class_type
;
1910 A C language linkage is ignored for the names of class members
1911 and the member function type of class member functions. */
1912 if (DECL_LANG_SPECIFIC (decl
) && DECL_LANGUAGE (decl
) == lang_c
)
1913 DECL_LANGUAGE (decl
) = lang_cplusplus
;
1915 /* Put functions on the TYPE_METHODS list and everything else on the
1916 TYPE_FIELDS list. Note that these are built up in reverse order.
1917 We reverse them (to obtain declaration order) in finish_struct. */
1918 if (TREE_CODE (decl
) == FUNCTION_DECL
1919 || DECL_FUNCTION_TEMPLATE_P (decl
))
1921 /* We also need to add this function to the
1922 CLASSTYPE_METHOD_VEC. */
1923 add_method (current_class_type
, decl
, /*error_p=*/0);
1925 TREE_CHAIN (decl
) = TYPE_METHODS (current_class_type
);
1926 TYPE_METHODS (current_class_type
) = decl
;
1930 /* All TYPE_DECLs go at the end of TYPE_FIELDS. Ordinary fields
1931 go at the beginning. The reason is that lookup_field_1
1932 searches the list in order, and we want a field name to
1933 override a type name so that the "struct stat hack" will
1934 work. In particular:
1936 struct S { enum E { }; int E } s;
1939 is legal. In addition, the FIELD_DECLs must be maintained in
1940 declaration order so that class layout works as expected.
1941 However, we don't need that order until class layout, so we
1942 save a little time by putting FIELD_DECLs on in reverse order
1943 here, and then reversing them in finish_struct_1. (We could
1944 also keep a pointer to the correct insertion points in the
1947 if (TREE_CODE (decl
) == TYPE_DECL
)
1948 TYPE_FIELDS (current_class_type
)
1949 = chainon (TYPE_FIELDS (current_class_type
), decl
);
1952 TREE_CHAIN (decl
) = TYPE_FIELDS (current_class_type
);
1953 TYPE_FIELDS (current_class_type
) = decl
;
1956 /* Enter the DECL into the scope of the class. */
1957 if (TREE_CODE (decl
) != USING_DECL
)
1958 pushdecl_class_level (decl
);
1962 /* Finish a class definition T with the indicate ATTRIBUTES. If SEMI,
1963 the definition is immediately followed by a semicolon. Returns the
1967 finish_class_definition (t
, attributes
, semi
, pop_scope_p
)
1973 /* finish_struct nukes this anyway; if finish_exception does too,
1976 note_got_semicolon (t
);
1978 /* If we got any attributes in class_head, xref_tag will stick them in
1979 TREE_TYPE of the type. Grab them now. */
1980 attributes
= chainon (TREE_TYPE (t
), attributes
);
1981 TREE_TYPE (t
) = NULL_TREE
;
1983 if (TREE_CODE (t
) == ENUMERAL_TYPE
)
1987 t
= finish_struct (t
, attributes
);
1989 note_got_semicolon (t
);
1993 check_for_missing_semicolon (t
);
1995 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL (t
)));
1996 if (current_function_decl
)
1997 type_lookups
= error_mark_node
;
1998 if (current_scope () == current_function_decl
)
1999 do_pending_defargs ();
2004 /* Finish processing the default argument expressions cached during
2005 the processing of a class definition. */
2008 begin_inline_definitions ()
2010 if (current_scope () == current_function_decl
)
2011 do_pending_inlines ();
2014 /* Finish processing the inline function definitions cached during the
2015 processing of a class definition. */
2018 finish_inline_definitions ()
2020 if (current_class_type
== NULL_TREE
)
2021 clear_inline_text_obstack ();
2024 /* Finish processing the declaration of a member class template
2025 TYPES whose template parameters are given by PARMS. */
2028 finish_member_class_template (types
)
2033 /* If there are declared, but undefined, partial specializations
2034 mixed in with the typespecs they will not yet have passed through
2035 maybe_process_partial_specialization, so we do that here. */
2036 for (t
= types
; t
!= NULL_TREE
; t
= TREE_CHAIN (t
))
2037 if (IS_AGGR_TYPE_CODE (TREE_CODE (TREE_VALUE (t
))))
2038 maybe_process_partial_specialization (TREE_VALUE (t
));
2040 note_list_got_semicolon (types
);
2041 grok_x_components (types
);
2042 if (TYPE_CONTEXT (TREE_VALUE (types
)) != current_class_type
)
2043 /* The component was in fact a friend declaration. We avoid
2044 finish_member_template_decl performing certain checks by
2048 finish_member_template_decl (types
);
2050 /* As with other component type declarations, we do
2051 not store the new DECL on the list of
2056 /* Finish processsing a complete template declaration. The PARMS are
2057 the template parameters. */
2060 finish_template_decl (parms
)
2064 end_template_decl ();
2066 end_specialization ();
2069 /* Finish processing a template-id (which names a type) of the form
2070 NAME < ARGS >. Return the TYPE_DECL for the type named by the
2071 template-id. If ENTERING_SCOPE is non-zero we are about to enter
2072 the scope of template-id indicated. */
2075 finish_template_type (name
, args
, entering_scope
)
2082 decl
= lookup_template_class (name
, args
,
2083 NULL_TREE
, NULL_TREE
,
2084 entering_scope
, /*complain=*/1);
2085 if (decl
!= error_mark_node
)
2086 decl
= TYPE_STUB_DECL (decl
);
2091 /* SR is a SCOPE_REF node. Enter the scope of SR, whether it is a
2092 namespace scope or a class scope. */
2098 tree scope
= TREE_OPERAND (sr
, 0);
2100 if (TREE_CODE (scope
) == NAMESPACE_DECL
)
2102 push_decl_namespace (scope
);
2103 TREE_COMPLEXITY (sr
) = -1;
2105 else if (scope
!= current_class_type
)
2107 if (TREE_CODE (scope
) == TYPENAME_TYPE
)
2109 /* In a declarator for a template class member, the scope will
2110 get here as an implicit typename, a TYPENAME_TYPE with a type. */
2111 scope
= TREE_TYPE (scope
);
2112 TREE_OPERAND (sr
, 0) = scope
;
2114 push_nested_class (scope
, 3);
2115 TREE_COMPLEXITY (sr
) = current_class_depth
;
2119 /* Finish processing a BASE_CLASS with the indicated ACCESS_SPECIFIER.
2120 Return a TREE_LIST containing the ACCESS_SPECIFIER and the
2121 BASE_CLASS, or NULL_TREE if an error occurred. The
2122 ACCESSS_SPECIFIER is one of
2123 access_{default,public,protected_private}[_virtual]_node.*/
2126 finish_base_specifier (access_specifier
, base_class
)
2127 tree access_specifier
;
2132 if (! is_aggr_type (base_class
, 1))
2136 if (CP_TYPE_QUALS (base_class
) != 0)
2138 cp_error ("base class `%T' has cv qualifiers", base_class
);
2139 base_class
= TYPE_MAIN_VARIANT (base_class
);
2141 result
= build_tree_list (access_specifier
, base_class
);
2147 /* Called when multiple declarators are processed. If that is not
2148 premitted in this context, an error is issued. */
2151 check_multiple_declarators ()
2155 In a template-declaration, explicit specialization, or explicit
2156 instantiation the init-declarator-list in the declaration shall
2157 contain at most one declarator.
2159 We don't just use PROCESSING_TEMPLATE_DECL for the first
2160 condition since that would disallow the perfectly legal code,
2161 like `template <class T> struct S { int i, j; };'. */
2162 tree scope
= current_scope ();
2164 if (scope
&& TREE_CODE (scope
) == FUNCTION_DECL
)
2165 /* It's OK to write `template <class T> void f() { int i, j;}'. */
2168 if (PROCESSING_REAL_TEMPLATE_DECL_P ()
2169 || processing_explicit_instantiation
2170 || processing_specialization
)
2171 cp_error ("multiple declarators in template declaration");
2175 finish_typeof (expr
)
2178 if (processing_template_decl
)
2182 t
= make_aggr_type (TYPEOF_TYPE
);
2183 TYPE_FIELDS (t
) = expr
;
2188 if (TREE_CODE (expr
) == OFFSET_REF
)
2189 expr
= resolve_offset_ref (expr
);
2191 return TREE_TYPE (expr
);
2194 /* Generate RTL for the statement T, and its substatements, and any
2195 other statements at its nesting level. */
2201 switch (TREE_CODE (t
))
2204 genrtl_decl_cleanup (CLEANUP_DECL (t
), CLEANUP_EXPR (t
));
2207 case START_CATCH_STMT
:
2208 genrtl_catch_block (TREE_TYPE (t
));
2212 genrtl_ctor_stmt (t
);
2216 genrtl_try_block (t
);
2220 genrtl_eh_spec_block (t
);
2228 genrtl_subobject (SUBOBJECT_CLEANUP (t
));
2232 genrtl_named_return_value ();
2236 my_friendly_abort (19990810);
2241 /* Called from expand_body via walk_tree. Replace all AGGR_INIT_EXPRs
2242 will equivalent CALL_EXPRs. */
2245 simplify_aggr_init_exprs_r (tp
, walk_subtrees
, data
)
2247 int *walk_subtrees ATTRIBUTE_UNUSED
;
2248 void *data ATTRIBUTE_UNUSED
;
2250 tree aggr_init_expr
;
2256 int copy_from_buffer_p
;
2258 aggr_init_expr
= *tp
;
2259 /* We don't need to walk into types; there's nothing in a type that
2260 needs simplification. (And, furthermore, there are places we
2261 actively don't want to go. For example, we don't want to wander
2262 into the default arguments for a FUNCTION_DECL that appears in a
2264 if (TYPE_P (aggr_init_expr
))
2269 /* Only AGGR_INIT_EXPRs are interesting. */
2270 else if (TREE_CODE (aggr_init_expr
) != AGGR_INIT_EXPR
)
2273 /* Form an appropriate CALL_EXPR. */
2274 fn
= TREE_OPERAND (aggr_init_expr
, 0);
2275 args
= TREE_OPERAND (aggr_init_expr
, 1);
2276 slot
= TREE_OPERAND (aggr_init_expr
, 2);
2277 type
= TREE_TYPE (aggr_init_expr
);
2278 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr
))
2280 /* Replace the first argument with the address of the third
2281 argument to the AGGR_INIT_EXPR. */
2282 mark_addressable (slot
);
2283 args
= tree_cons (NULL_TREE
,
2285 build_pointer_type (TREE_TYPE (slot
)),
2289 call_expr
= build (CALL_EXPR
,
2290 TREE_TYPE (TREE_TYPE (TREE_TYPE (fn
))),
2291 fn
, args
, NULL_TREE
);
2292 TREE_SIDE_EFFECTS (call_expr
) = 1;
2294 /* If we're using the non-reentrant PCC calling convention, then we
2295 need to copy the returned value out of the static buffer into the
2297 copy_from_buffer_p
= 0;
2298 #ifdef PCC_STATIC_STRUCT_RETURN
2299 if (!AGGR_INIT_VIA_CTOR_P (aggr_init_expr
) && aggregate_value_p (type
))
2301 int old_ac
= flag_access_control
;
2303 flag_access_control
= 0;
2304 call_expr
= build_aggr_init (slot
, call_expr
, LOOKUP_ONLYCONVERTING
);
2305 flag_access_control
= old_ac
;
2306 copy_from_buffer_p
= 1;
2310 /* If this AGGR_INIT_EXPR indicates the value returned by a
2311 function, then we want to use the value of the initialized
2312 location as the result. */
2313 if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr
) || copy_from_buffer_p
)
2315 call_expr
= build (COMPOUND_EXPR
, type
,
2317 TREE_SIDE_EFFECTS (call_expr
) = 1;
2320 /* Replace the AGGR_INIT_EXPR with the CALL_EXPR. */
2321 TREE_CHAIN (call_expr
) = TREE_CHAIN (aggr_init_expr
);
2324 /* Keep iterating. */
2328 /* Emit all thunks to FN that should be emitted when FN is emitted. */
2331 emit_associated_thunks (fn
)
2334 /* When we use vcall offsets, we emit thunks with the virtual
2335 functions to which they thunk. The whole point of vcall offsets
2336 is so that you can know statically the entire set of thunks that
2337 will ever be needed for a given virtual function, thereby
2338 enabling you to output all the thunks with the function itself. */
2339 if (vcall_offsets_in_vtable_p () && DECL_VIRTUAL_P (fn
))
2344 for (binfo
= TYPE_BINFO (DECL_CONTEXT (fn
));
2346 binfo
= TREE_CHAIN (binfo
))
2347 for (v
= BINFO_VIRTUALS (binfo
); v
; v
= TREE_CHAIN (v
))
2349 && (!integer_zerop (BV_DELTA (v
))
2350 || BV_VCALL_INDEX (v
)))
2355 if (BV_USE_VCALL_INDEX_P (v
))
2357 vcall_index
= BV_VCALL_INDEX (v
);
2358 my_friendly_assert (vcall_index
!= NULL_TREE
, 20000621);
2361 vcall_index
= NULL_TREE
;
2363 thunk
= make_thunk (build1 (ADDR_EXPR
,
2364 vfunc_ptr_type_node
,
2368 /*generate_with_vtable_p=*/0);
2369 use_thunk (thunk
, /*emit_p=*/1);
2374 /* Generate RTL for FN. */
2381 const char *saved_input_filename
;
2383 /* When the parser calls us after finishing the body of a template
2384 function, we don't really want to expand the body. When we're
2385 processing an in-class definition of an inline function,
2386 PROCESSING_TEMPLATE_DECL will no longer be set here, so we have
2387 to look at the function itself. */
2388 if (processing_template_decl
2389 || (DECL_LANG_SPECIFIC (fn
)
2390 && DECL_TEMPLATE_INFO (fn
)
2391 && uses_template_parms (DECL_TI_ARGS (fn
))))
2393 /* Normally, collection only occurs in rest_of_compilation. So,
2394 if we don't collect here, we never collect junk generated
2395 during the processing of templates until we hit a
2396 non-template function. */
2401 /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs. */
2402 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn
),
2403 simplify_aggr_init_exprs_r
,
2406 /* If this is a constructor or destructor body, we have to clone it
2407 under the new ABI. */
2408 if (maybe_clone_body (fn
))
2410 /* We don't want to process FN again, so pretend we've written
2411 it out, even though we haven't. */
2412 TREE_ASM_WRITTEN (fn
) = 1;
2416 /* There's no reason to do any of the work here if we're only doing
2417 semantic analysis; this code just generates RTL. */
2418 if (flag_syntax_only
)
2421 /* If possible, avoid generating RTL for this function. Instead,
2422 just record it as an inline function, and wait until end-of-file
2423 to decide whether to write it out or not. */
2424 if (/* We have to generate RTL if it's not an inline function. */
2425 (DECL_INLINE (fn
) || DECL_COMDAT (fn
))
2426 /* Or if we have to keep all inline functions anyhow. */
2427 && !flag_keep_inline_functions
2428 /* Or if we actually have a reference to the function. */
2429 && !DECL_NEEDED_P (fn
)
2430 /* Or if this is a nested function. */
2431 && !decl_function_context (fn
))
2433 /* Set DECL_EXTERNAL so that assemble_external will be called as
2434 necessary. We'll clear it again in finish_file. */
2435 if (!DECL_EXTERNAL (fn
))
2437 DECL_NOT_REALLY_EXTERN (fn
) = 1;
2438 DECL_EXTERNAL (fn
) = 1;
2440 /* Remember this function. In finish_file we'll decide if
2441 we actually need to write this function out. */
2443 /* Let the back-end know that this funtion exists. */
2444 note_deferral_of_defined_inline_function (fn
);
2448 /* Compute the appropriate object-file linkage for inline
2450 if (DECL_DECLARED_INLINE_P (fn
))
2451 import_export_decl (fn
);
2453 /* Emit any thunks that should be emitted at the same time as FN. */
2454 emit_associated_thunks (fn
);
2456 timevar_push (TV_INTEGRATION
);
2458 /* Optimize the body of the function before expanding it. */
2459 optimize_function (fn
);
2461 timevar_pop (TV_INTEGRATION
);
2462 timevar_push (TV_EXPAND
);
2464 /* Save the current file name and line number. When we expand the
2465 body of the function, we'll set LINENO and INPUT_FILENAME so that
2466 error-mesages come out in the right places. */
2467 saved_lineno
= lineno
;
2468 saved_input_filename
= input_filename
;
2469 lineno
= DECL_SOURCE_LINE (fn
);
2470 input_filename
= DECL_SOURCE_FILE (fn
);
2472 genrtl_start_function (fn
);
2473 current_function_is_thunk
= DECL_THUNK_P (fn
);
2475 /* We don't need to redeclare __FUNCTION__, __PRETTY_FUNCTION__, or
2476 any of the other magic variables we set up when starting a
2478 function_name_declared_p
= 1;
2480 /* Expand the body. */
2481 expand_stmt (DECL_SAVED_TREE (fn
));
2483 /* Statements should always be full-expressions at the outermost set
2484 of curly braces for a function. */
2485 my_friendly_assert (stmts_are_full_exprs_p (), 19990831);
2487 /* The outermost statement for a function contains the line number
2488 recorded when we finished processing the function. */
2489 lineno
= STMT_LINENO (DECL_SAVED_TREE (fn
));
2491 /* Generate code for the function. */
2492 genrtl_finish_function (fn
);
2494 /* If possible, obliterate the body of the function so that it can
2495 be garbage collected. */
2496 if (flag_dump_translation_unit
)
2497 /* Keep the body; we're going to dump it. */
2499 else if (DECL_INLINE (fn
) && flag_inline_trees
)
2500 /* We might need the body of this function so that we can expand
2501 it inline somewhere else. */
2504 /* We don't need the body; blow it away. */
2505 DECL_SAVED_TREE (fn
) = NULL_TREE
;
2507 /* And restore the current source position. */
2508 lineno
= saved_lineno
;
2509 input_filename
= saved_input_filename
;
2510 extract_interface_info ();
2512 timevar_pop (TV_EXPAND
);
2515 /* Start generating the RTL for FN. */
2518 genrtl_start_function (fn
)
2523 /* Tell everybody what function we're processing. */
2524 current_function_decl
= fn
;
2525 /* Get the RTL machinery going for this function. */
2526 init_function_start (fn
, DECL_SOURCE_FILE (fn
), DECL_SOURCE_LINE (fn
));
2527 /* Let everybody know that we're expanding this function, not doing
2528 semantic analysis. */
2531 /* Even though we're inside a function body, we still don't want to
2532 call expand_expr to calculate the size of a variable-sized array.
2533 We haven't necessarily assigned RTL to all variables yet, so it's
2534 not safe to try to expand expressions involving them. */
2535 immediate_size_expand
= 0;
2536 cfun
->x_dont_save_pending_sizes_p
= 1;
2538 /* Let the user know we're compiling this function. */
2539 announce_function (fn
);
2541 /* Initialize the per-function data. */
2542 my_friendly_assert (!DECL_PENDING_INLINE_P (fn
), 20000911);
2543 if (DECL_SAVED_FUNCTION_DATA (fn
))
2545 /* If we already parsed this function, and we're just expanding it
2546 now, restore saved state. */
2547 *cp_function_chain
= *DECL_SAVED_FUNCTION_DATA (fn
);
2549 /* This function is being processed in whole-function mode; we
2550 already did semantic analysis. */
2551 cfun
->x_whole_function_mode_p
= 1;
2553 /* If we decided that we didn't want to inline this function,
2554 make sure the back-end knows that. */
2555 if (!current_function_cannot_inline
)
2556 current_function_cannot_inline
= cp_function_chain
->cannot_inline
;
2558 /* We don't need the saved data anymore. */
2559 free (DECL_SAVED_FUNCTION_DATA (fn
));
2560 DECL_SAVED_FUNCTION_DATA (fn
) = NULL
;
2563 /* Tell the cross-reference machinery that we're defining this
2565 GNU_xref_function (fn
, DECL_ARGUMENTS (fn
));
2567 /* Keep track of how many functions we're presently expanding. */
2570 /* Create a binding level for the parameters. */
2571 expand_start_bindings (2);
2572 /* Clear out any previously saved instructions for this function, in
2573 case it was defined more than once. */
2574 DECL_SAVED_INSNS (fn
) = NULL
;
2575 /* Go through the PARM_DECLs for this function to see if any need
2577 for (parm
= DECL_ARGUMENTS (fn
); parm
; parm
= TREE_CHAIN (parm
))
2578 if (TREE_TYPE (parm
) != error_mark_node
2579 && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (parm
)))
2581 expand_function_start (fn
, /*parms_have_cleanups=*/1);
2585 expand_function_start (fn
, /*parms_have_cleanups=*/0);
2586 /* If this function is `main'. */
2587 if (DECL_MAIN_P (fn
))
2588 expand_main_function ();
2589 /* Create a binding contour which can be used to catch
2590 cleanup-generated temporaries. */
2591 expand_start_bindings (2);
2594 /* Finish generating the RTL for FN. */
2597 genrtl_finish_function (fn
)
2600 tree no_return_label
= NULL_TREE
;
2603 if (write_symbols
!= NO_DEBUG
)
2605 /* Keep this code around in case we later want to control debug info
2606 based on whether a type is "used". (jason 1999-11-11) */
2608 tree ttype
= target_type (fntype
);
2611 if (IS_AGGR_TYPE (ttype
))
2612 /* Let debugger know it should output info for this type. */
2613 note_debug_info_needed (ttype
);
2615 for (parmdecl
= DECL_ARGUMENTS (fndecl
); parmdecl
; parmdecl
= TREE_CHAIN (parmdecl
))
2617 ttype
= target_type (TREE_TYPE (parmdecl
));
2618 if (IS_AGGR_TYPE (ttype
))
2619 /* Let debugger know it should output info for this type. */
2620 note_debug_info_needed (ttype
);
2625 /* Clean house because we will need to reorder insns here. */
2626 do_pending_stack_adjust ();
2628 if (!dtor_label
&& !DECL_CONSTRUCTOR_P (fn
)
2629 && return_label
!= NULL_RTX
2630 && current_function_return_value
== NULL_TREE
2631 && ! DECL_NAME (DECL_RESULT (current_function_decl
)))
2632 no_return_label
= build_decl (LABEL_DECL
, NULL_TREE
, NULL_TREE
);
2634 /* If this function is supposed to return a value, ensure that
2635 we do not fall into the cleanups by mistake. The end of our
2636 function will look like this:
2638 user code (may have return stmt somewhere)
2639 goto no_return_label
2644 NOTE_INSN_FUNCTION_END
2648 If the user omits a return stmt in the USER CODE section, we
2649 will have a control path which reaches NOTE_INSN_FUNCTION_END.
2650 Otherwise, we won't. */
2651 if (no_return_label
)
2653 DECL_CONTEXT (no_return_label
) = fn
;
2654 DECL_INITIAL (no_return_label
) = error_mark_node
;
2655 DECL_SOURCE_FILE (no_return_label
) = input_filename
;
2656 DECL_SOURCE_LINE (no_return_label
) = lineno
;
2657 expand_goto (no_return_label
);
2662 /* Remove the binding contour which is used to catch
2663 cleanup-generated temporaries. */
2664 expand_end_bindings (0, 0, 0);
2667 /* Emit label at beginning of cleanup code for parameters. */
2668 emit_label (cleanup_label
);
2671 /* Finish building code that will trigger warnings if users forget
2672 to make their functions return values. */
2674 emit_jump (return_label
);
2675 if (no_return_label
)
2677 /* We don't need to call `expand_*_return' here because we don't
2678 need any cleanups here--this path of code is only for error
2679 checking purposes. */
2680 expand_label (no_return_label
);
2683 /* We hard-wired immediate_size_expand to zero in start_function.
2684 Expand_function_end will decrement this variable. So, we set the
2685 variable to one here, so that after the decrement it will remain
2687 immediate_size_expand
= 1;
2689 /* Generate rtl for function exit. */
2690 expand_function_end (input_filename
, lineno
, 1);
2692 /* If this is a nested function (like a template instantiation that
2693 we're compiling in the midst of compiling something else), push a
2694 new GC context. That will keep local variables on the stack from
2695 being collected while we're doing the compilation of this
2697 if (function_depth
> 1)
2698 ggc_push_context ();
2700 /* There's no need to defer outputting this function any more; we
2701 know we want to output it. */
2702 DECL_DEFER_OUTPUT (fn
) = 0;
2704 /* Run the optimizers and output the assembler code for this
2706 rest_of_compilation (fn
);
2708 /* Undo the call to ggc_push_context above. */
2709 if (function_depth
> 1)
2712 if (DECL_SAVED_INSNS (fn
) && ! TREE_ASM_WRITTEN (fn
))
2714 /* Set DECL_EXTERNAL so that assemble_external will be called as
2715 necessary. We'll clear it again in finish_file. */
2716 if (! DECL_EXTERNAL (fn
))
2717 DECL_NOT_REALLY_EXTERN (fn
) = 1;
2718 DECL_EXTERNAL (fn
) = 1;
2723 /* Keep this code around in case we later want to control debug info
2724 based on whether a type is "used". (jason 1999-11-11) */
2726 if (ctype
&& TREE_ASM_WRITTEN (fn
))
2727 note_debug_info_needed (ctype
);
2730 /* If this function is marked with the constructor attribute, add it
2731 to the list of functions to be called along with constructors
2732 from static duration objects. */
2733 if (DECL_STATIC_CONSTRUCTOR (fn
))
2734 static_ctors
= tree_cons (NULL_TREE
, fn
, static_ctors
);
2736 /* If this function is marked with the destructor attribute, add it
2737 to the list of functions to be called along with destructors from
2738 static duration objects. */
2739 if (DECL_STATIC_DESTRUCTOR (fn
))
2740 static_dtors
= tree_cons (NULL_TREE
, fn
, static_dtors
);
2744 /* If we don't need the RTL for this function anymore, stop pointing
2745 to it. That's especially important for LABEL_DECLs, since you
2746 can reach all the instructions in the function from the
2747 CODE_LABEL stored in the DECL_RTL for the LABEL_DECL. */
2748 if (!DECL_SAVED_INSNS (fn
))
2752 /* Walk the BLOCK-tree, clearing DECL_RTL for LABEL_DECLs and
2753 non-static local variables. */
2754 walk_tree_without_duplicates (&DECL_SAVED_TREE (fn
),
2758 /* Clear out the RTL for the arguments. */
2759 for (t
= DECL_ARGUMENTS (fn
); t
; t
= TREE_CHAIN (t
))
2761 SET_DECL_RTL (t
, NULL_RTX
);
2762 DECL_INCOMING_RTL (t
) = NULL_RTX
;
2765 if (!(flag_inline_trees
&& DECL_INLINE (fn
)))
2766 /* DECL_INITIAL must remain nonzero so we know this was an
2767 actual function definition. */
2768 DECL_INITIAL (fn
) = error_mark_node
;
2771 /* Let the error reporting routines know that we're outside a
2772 function. For a nested function, this value is used in
2773 pop_cp_function_context and then reset via pop_function_context. */
2774 current_function_decl
= NULL_TREE
;
2777 /* Clear out the DECL_RTL for the non-static variables in BLOCK and
2781 clear_decl_rtl (tp
, walk_subtrees
, data
)
2783 int *walk_subtrees ATTRIBUTE_UNUSED
;
2784 void *data ATTRIBUTE_UNUSED
;
2786 if (nonstatic_local_decl_p (*tp
))
2787 SET_DECL_RTL (*tp
, NULL_RTX
);
2792 /* Perform initialization related to this module. */
2795 init_cp_semantics ()
2797 lang_expand_stmt
= cp_expand_stmt
;