C++ PATCH: More cleanups
Mark Mitchell
mark@codesourcery.com
Tue Apr 11 09:28:00 GMT 2000
This patch removes one of the parameters to finish_function since the
same value was being passed everywhere. Also, I've introduced
copy_decl, which is like copy_node, but calls copy_lang_decl as well
to copy the language-specific bits.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-04-11 Mark Mitchell <mark@codesourcery.com>
* cp-tre.h (finish_function): Change prototype.
* decl.c (end_cleanup_fn): Adjust caller.
(finish_function): Take only one parameter.
* decl2.c (finish_objects): Adjust caller.
(finish_static_storage_duration_function): Likewise.
* method.c (emit_thunk): Likewise.
* parse.y: Likewise.
* parse.c: Regenerated.
* pt.c (instantiate_decl): Likewise.
* rtti.c (synthesize_tinfo_fn): Likewise.
* semantics.c (expand_body): Likewise.
* cp-tree.h (copy_decl): New function.
* class.c (finish_struct_1): Use it.
* lex.c (copy_decl): Define it.
* pt.c (tsubst_decl): Likewise.
* tree.c (copy_template_template_parm): Likewise.
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.438
diff -c -p -r1.438 cp-tree.h
*** cp-tree.h 2000/04/11 07:39:05 1.438
--- cp-tree.h 2000/04/11 07:47:00
*************** extern int start_function PARAMS ((tre
*** 3833,3839 ****
extern void expand_start_early_try_stmts PARAMS ((void));
extern void store_parm_decls PARAMS ((void));
extern void store_return_init PARAMS ((tree));
! extern tree finish_function PARAMS ((int, int));
extern tree start_method PARAMS ((tree, tree, tree));
extern tree finish_method PARAMS ((tree));
extern void hack_incomplete_structures PARAMS ((tree));
--- 3833,3839 ----
extern void expand_start_early_try_stmts PARAMS ((void));
extern void store_parm_decls PARAMS ((void));
extern void store_return_init PARAMS ((tree));
! extern tree finish_function PARAMS ((int));
extern tree start_method PARAMS ((tree, tree, tree));
extern tree finish_method PARAMS ((tree));
extern void hack_incomplete_structures PARAMS ((tree));
*************** extern int real_yylex PARAMS ((void))
*** 4048,4053 ****
--- 4048,4054 ----
extern int is_rid PARAMS ((tree));
extern tree build_lang_decl PARAMS ((enum tree_code, tree, tree));
extern void retrofit_lang_decl PARAMS ((tree));
+ extern tree copy_decl PARAMS ((tree));
extern void copy_lang_decl PARAMS ((tree));
extern tree cp_make_lang_type PARAMS ((enum tree_code));
extern tree make_aggr_type PARAMS ((enum tree_code));
Index: class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/class.c,v
retrieving revision 1.288
diff -c -p -r1.288 class.c
*** class.c 2000/04/11 07:39:04 1.288
--- class.c 2000/04/11 07:46:57
*************** finish_struct_1 (t)
*** 4645,4652 ****
{
tree binfo = get_binfo (DECL_FIELD_CONTEXT (vfield), t, 0);
! vfield = copy_node (vfield);
! copy_lang_decl (vfield);
DECL_FIELD_CONTEXT (vfield) = t;
DECL_FIELD_OFFSET (vfield)
--- 4645,4651 ----
{
tree binfo = get_binfo (DECL_FIELD_CONTEXT (vfield), t, 0);
! vfield = copy_decl (vfield);
DECL_FIELD_CONTEXT (vfield) = t;
DECL_FIELD_OFFSET (vfield)
Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.586
diff -c -p -r1.586 decl.c
*** decl.c 2000/04/11 00:38:37 1.586
--- decl.c 2000/04/11 07:47:09
*************** end_cleanup_fn ()
*** 8283,8289 ****
{
do_poplevel ();
! expand_body (finish_function (lineno, 0));
pop_from_top_level ();
}
--- 8283,8289 ----
{
do_poplevel ();
! expand_body (finish_function (0));
pop_from_top_level ();
}
*************** finish_destructor_body ()
*** 13939,13946 ****
after the class definition is complete.) */
tree
! finish_function (lineno, flags)
! int lineno;
int flags;
{
register tree fndecl = current_function_decl;
--- 13939,13945 ----
after the class definition is complete.) */
tree
! finish_function (flags)
int flags;
{
register tree fndecl = current_function_decl;
*************** finish_function (lineno, flags)
*** 13951,13956 ****
--- 13950,13956 ----
int inclass_inline = (flags & 2) != 0;
int expand_p;
int nested;
+ int current_line = lineno;
/* When we get some parse errors, we can end up without a
current_function_decl, so cope. */
*************** finish_function (lineno, flags)
*** 14065,14071 ****
DECL_CONTEXT (no_return_label) = fndecl;
DECL_INITIAL (no_return_label) = error_mark_node;
DECL_SOURCE_FILE (no_return_label) = input_filename;
! DECL_SOURCE_LINE (no_return_label) = lineno;
expand_goto (no_return_label);
}
--- 14065,14071 ----
DECL_CONTEXT (no_return_label) = fndecl;
DECL_INITIAL (no_return_label) = error_mark_node;
DECL_SOURCE_FILE (no_return_label) = input_filename;
! DECL_SOURCE_LINE (no_return_label) = current_line;
expand_goto (no_return_label);
}
*************** finish_function (lineno, flags)
*** 14104,14110 ****
immediate_size_expand = 1;
/* Generate rtl for function exit. */
! expand_function_end (input_filename, lineno, 1);
}
/* We have to save this value here in case
--- 14104,14110 ----
immediate_size_expand = 1;
/* Generate rtl for function exit. */
! expand_function_end (input_filename, current_line, 1);
}
/* We have to save this value here in case
Index: decl2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl2.c,v
retrieving revision 1.330
diff -c -p -r1.330 decl2.c
*** decl2.c 2000/04/11 00:38:37 1.330
--- decl2.c 2000/04/11 07:47:12
*************** finish_objects (method_type, initp, body
*** 2861,2867 ****
/* Finish up. */
finish_compound_stmt(/*has_no_scope=*/0, body);
! fn = finish_function (lineno, 0);
expand_body (fn);
/* When only doing semantic analysis, and no RTL generation, we
--- 2861,2867 ----
/* Finish up. */
finish_compound_stmt(/*has_no_scope=*/0, body);
! fn = finish_function (0);
expand_body (fn);
/* When only doing semantic analysis, and no RTL generation, we
*************** finish_static_storage_duration_function
*** 3045,3051 ****
{
/* Close out the function. */
finish_compound_stmt (/*has_no_scope=*/0, body);
! expand_body (finish_function (lineno, 0));
}
/* Return the information about the indicated PRIORITY level. If no
--- 3045,3051 ----
{
/* Close out the function. */
finish_compound_stmt (/*has_no_scope=*/0, body);
! expand_body (finish_function (0));
}
/* Return the information about the indicated PRIORITY level. If no
Index: lex.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/lex.c,v
retrieving revision 1.191
diff -c -p -r1.191 lex.c
*** lex.c 2000/04/10 07:43:45 1.191
--- lex.c 2000/04/11 07:47:15
*************** copy_lang_decl (node)
*** 5014,5019 ****
--- 5014,5032 ----
DECL_LANG_SPECIFIC (node) = ld;
}
+ /* Copy DECL, including any language-specific parts. */
+
+ tree
+ copy_decl (decl)
+ tree decl;
+ {
+ tree copy;
+
+ copy = copy_node (decl);
+ copy_lang_decl (copy);
+ return copy;
+ }
+
tree
cp_make_lang_type (code)
enum tree_code code;
Index: method.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/method.c,v
retrieving revision 1.145
diff -c -p -r1.145 method.c
*** method.c 2000/04/09 06:44:20 1.145
--- method.c 2000/04/11 07:47:16
*************** emit_thunk (thunk_fndecl)
*** 2157,2163 ****
t = build_call (function, t);
finish_return_stmt (t);
! expand_body (finish_function (lineno, 0));
/* Don't let the backend defer this function. */
if (DECL_DEFER_OUTPUT (thunk_fndecl))
--- 2157,2163 ----
t = build_call (function, t);
finish_return_stmt (t);
! expand_body (finish_function (0));
/* Don't let the backend defer this function. */
if (DECL_DEFER_OUTPUT (thunk_fndecl))
*************** synthesize_method (fndecl)
*** 2405,2411 ****
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
! expand_body (finish_function (lineno, 0));
extract_interface_info ();
if (! context)
--- 2405,2411 ----
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
}
! expand_body (finish_function (0));
extract_interface_info ();
if (! context)
Index: parse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.c,v
retrieving revision 1.163
diff -c -p -r1.163 parse.c
*** parse.c 2000/04/11 00:38:37 1.163
--- parse.c 2000/04/11 07:47:21
*************** case 85:
*** 4908,4918 ****
break;}
case 91:
#line 735 "parse.y"
! { expand_body (finish_function (lineno, (int)yyvsp[-1].itype)); ;
break;}
case 92:
#line 737 "parse.y"
! { expand_body (finish_function (lineno, (int)yyvsp[0].itype)); ;
break;}
case 93:
#line 739 "parse.y"
--- 4908,4918 ----
break;}
case 91:
#line 735 "parse.y"
! { expand_body (finish_function ((int)yyvsp[-1].itype)); ;
break;}
case 92:
#line 737 "parse.y"
! { expand_body (finish_function ((int)yyvsp[0].itype)); ;
break;}
case 93:
#line 739 "parse.y"
*************** case 458:
*** 6419,6439 ****
case 459:
#line 2104 "parse.y"
{
! expand_body (finish_function (lineno, (int)yyvsp[-1].itype | 2));
process_next_inline (yyvsp[-3].pi);
;
break;}
case 460:
#line 2109 "parse.y"
{
! expand_body (finish_function (lineno, (int)yyvsp[0].itype | 2));
process_next_inline (yyvsp[-2].pi);
;
break;}
case 461:
#line 2114 "parse.y"
{
! finish_function (lineno, 2);
process_next_inline (yyvsp[-2].pi); ;
break;}
case 464:
--- 6419,6439 ----
case 459:
#line 2104 "parse.y"
{
! expand_body (finish_function ((int)yyvsp[-1].itype | 2));
process_next_inline (yyvsp[-3].pi);
;
break;}
case 460:
#line 2109 "parse.y"
{
! expand_body (finish_function ((int)yyvsp[0].itype | 2));
process_next_inline (yyvsp[-2].pi);
;
break;}
case 461:
#line 2114 "parse.y"
{
! finish_function (2);
process_next_inline (yyvsp[-2].pi); ;
break;}
case 464:
Index: parse.y
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/parse.y,v
retrieving revision 1.172
diff -c -p -r1.172 parse.y
*** parse.y 2000/04/11 00:38:39 1.172
--- parse.y 2000/04/11 07:47:23
*************** eat_saved_input:
*** 732,740 ****
fndef:
fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
! { expand_body (finish_function (lineno, (int)$3)); }
| fn.def1 maybe_return_init function_try_block
! { expand_body (finish_function (lineno, (int)$3)); }
| fn.def1 maybe_return_init error
{ }
;
--- 732,740 ----
fndef:
fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
! { expand_body (finish_function ((int)$3)); }
| fn.def1 maybe_return_init function_try_block
! { expand_body (finish_function ((int)$3)); }
| fn.def1 maybe_return_init error
{ }
;
*************** fn.defpen:
*** 2102,2118 ****
pending_inline:
fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
{
! expand_body (finish_function (lineno, (int)$3 | 2));
process_next_inline ($1);
}
| fn.defpen maybe_return_init function_try_block
{
! expand_body (finish_function (lineno, (int)$3 | 2));
process_next_inline ($1);
}
| fn.defpen maybe_return_init error
{
! finish_function (lineno, 2);
process_next_inline ($1); }
;
--- 2102,2118 ----
pending_inline:
fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
{
! expand_body (finish_function ((int)$3 | 2));
process_next_inline ($1);
}
| fn.defpen maybe_return_init function_try_block
{
! expand_body (finish_function ((int)$3 | 2));
process_next_inline ($1);
}
| fn.defpen maybe_return_init error
{
! finish_function (2);
process_next_inline ($1); }
;
Index: pt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/pt.c,v
retrieving revision 1.417
diff -c -p -r1.417 pt.c
*** pt.c 2000/04/10 06:53:57 1.417
--- pt.c 2000/04/11 07:47:28
*************** tsubst_decl (t, args, type, in_decl)
*** 5440,5447 ****
We also create a new function declaration, which is just
like the old one, but points to this new template, rather
than the old one. */
! r = copy_node (t);
! copy_lang_decl (r);
my_friendly_assert (DECL_LANG_SPECIFIC (r) != 0, 0);
TREE_CHAIN (r) = NULL_TREE;
--- 5440,5446 ----
We also create a new function declaration, which is just
like the old one, but points to this new template, rather
than the old one. */
! r = copy_decl (t);
my_friendly_assert (DECL_LANG_SPECIFIC (r) != 0, 0);
TREE_CHAIN (r) = NULL_TREE;
*************** tsubst_decl (t, args, type, in_decl)
*** 5681,5689 ****
point, as they may not represent instantiations of this
template, and in any case are considered separate under the
discrete model. Instead, see add_maybe_template. */
!
! r = copy_node (t);
! copy_lang_decl (r);
DECL_USE_TEMPLATE (r) = 0;
TREE_TYPE (r) = type;
--- 5680,5686 ----
point, as they may not represent instantiations of this
template, and in any case are considered separate under the
discrete model. Instead, see add_maybe_template. */
! r = copy_decl (t);
DECL_USE_TEMPLATE (r) = 0;
TREE_TYPE (r) = type;
*************** tsubst_decl (t, args, type, in_decl)
*** 5819,5826 ****
case FIELD_DECL:
{
! r = copy_node (t);
! copy_lang_decl (r);
TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
--- 5816,5822 ----
case FIELD_DECL:
{
! r = copy_decl (t);
TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
*************** tsubst_decl (t, args, type, in_decl)
*** 5899,5908 ****
break;
}
! /* This declaration is going to have to be around for a while,
! so me make sure it is on a saveable obstack. */
! r = copy_node (t);
!
TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
DECL_CONTEXT (r) = ctx;
--- 5895,5901 ----
break;
}
! r = copy_decl (t);
TREE_TYPE (r) = type;
c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
DECL_CONTEXT (r) = ctx;
*************** tsubst_decl (t, args, type, in_decl)
*** 5912,5918 ****
DECL_INITIAL (r) = NULL_TREE;
DECL_RTL (r) = 0;
DECL_SIZE (r) = DECL_SIZE_UNIT (r) = 0;
- copy_lang_decl (r);
/* For __PRETTY_FUNCTION__ we have to adjust the initializer. */
if (DECL_PRETTY_FUNCTION_P (r))
--- 5905,5910 ----
*************** instantiate_decl (d, defer_ok)
*** 9585,9591 ****
/*complain=*/1, tmpl);
/* Finish the function. */
! expand_body (finish_function (lineno, 0));
}
/* We're not deferring instantiation any more. */
--- 9577,9583 ----
/*complain=*/1, tmpl);
/* Finish the function. */
! expand_body (finish_function (0));
}
/* We're not deferring instantiation any more. */
Index: rtti.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/rtti.c,v
retrieving revision 1.85
diff -c -p -r1.85 rtti.c
*** rtti.c 2000/04/11 00:38:39 1.85
--- rtti.c 2000/04/11 07:47:29
*************** synthesize_tinfo_fn (fndecl)
*** 1274,1280 ****
finish_return_stmt (tmp);
/* Finish the function body. */
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
! expand_body (finish_function (lineno, 0));
}
/* Return the runtime bit mask encoding the qualifiers of TYPE. */
--- 1274,1280 ----
finish_return_stmt (tmp);
/* Finish the function body. */
finish_compound_stmt (/*has_no_scope=*/0, compound_stmt);
! expand_body (finish_function (0));
}
/* Return the runtime bit mask encoding the qualifiers of TYPE. */
Index: semantics.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/semantics.c,v
retrieving revision 1.136
diff -c -p -r1.136 semantics.c
*** semantics.c 2000/04/11 00:38:39 1.136
--- semantics.c 2000/04/11 07:47:31
*************** begin_class_definition (t)
*** 1957,1967 ****
|| ! CLASSTYPE_INTERFACE_ONLY (t))
CLASSTYPE_VTABLE_NEEDS_WRITING (t) = 1;
}
- #if 0
- tmp = TYPE_IDENTIFIER ($<ttype>0);
- if (tmp && IDENTIFIER_TEMPLATE (tmp))
- overload_template_name (tmp, 1);
- #endif
reset_specialization();
/* Make a declaration for this class in its own scope. */
--- 1957,1962 ----
*************** expand_body (fn)
*** 2788,2794 ****
lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
/* Generate code for the function. */
! finish_function (lineno, 0);
/* If possible, obliterate the body of the function so that it can
be garbage collected. */
--- 2783,2789 ----
lineno = STMT_LINENO (DECL_SAVED_TREE (fn));
/* Generate code for the function. */
! finish_function (0);
/* If possible, obliterate the body of the function so that it can
be garbage collected. */
Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/tree.c,v
retrieving revision 1.190
diff -c -p -r1.190 tree.c
*** tree.c 2000/04/04 18:13:21 1.190
--- tree.c 2000/04/11 07:47:32
*************** copy_template_template_parm (t)
*** 1181,1188 ****
tree t2;
t2 = make_aggr_type (TEMPLATE_TEMPLATE_PARM);
! template = copy_node (template);
! copy_lang_decl (template);
TREE_TYPE (template) = t2;
TYPE_NAME (t2) = template;
--- 1181,1187 ----
tree t2;
t2 = make_aggr_type (TEMPLATE_TEMPLATE_PARM);
! template = copy_decl (template);
TREE_TYPE (template) = t2;
TYPE_NAME (t2) = template;
More information about the Gcc-patches
mailing list