diff options
author | Mike Stump <mrs@gcc.gnu.org> | 1995-03-24 22:18:53 +0000 |
---|---|---|
committer | Mike Stump <mrs@gcc.gnu.org> | 1995-03-24 22:18:53 +0000 |
commit | 7215f9a09ff3c8f973c7cb81c478ad24079dbb6e (patch) | |
tree | 2ac93d9dc0099266297ee6a1f0175f9dcebc731b | |
parent | e4a3429b5644a5ccd2239a1a29199cfbe793de79 (diff) | |
download | gcc-7215f9a09ff3c8f973c7cb81c478ad24079dbb6e.zip gcc-7215f9a09ff3c8f973c7cb81c478ad24079dbb6e.tar.gz gcc-7215f9a09ff3c8f973c7cb81c478ad24079dbb6e.tar.bz2 |
60th Cygnus<->FSF merge
From-SVN: r9230
-rw-r--r-- | gcc/cp/ChangeLog | 41 | ||||
-rw-r--r-- | gcc/cp/cvt.c | 11 | ||||
-rw-r--r-- | gcc/cp/decl.c | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 15 | ||||
-rw-r--r-- | gcc/cp/init.c | 28 | ||||
-rw-r--r-- | gcc/cp/pt.c | 22 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 46 |
7 files changed, 126 insertions, 43 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 331e139..dc5ee69 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,44 @@ +Fri Mar 24 12:11:24 1995 Jason Merrill <jason@phydeaux.cygnus.com> + + * decl.c (duplicate_decls): Propagate DECL_ABSTRACT_VIRTUAL_P. + + * pt.c (push_tinst_level): Complain if template instantiation depth + is greater than max_tinst_depth. + + * typeck.c (common_type): Assume that we can call common_type to + unify the target type of a pointer. + +Thu Mar 23 00:48:44 1995 Jason Merrill <jason@phydeaux.cygnus.com> + + * decl2.c (finish_file): Don't synthesize methods at + finish_vtable_prevardecl time. Do synthesize methods that are not + used, but are public and not external. + + * cvt.c (build_type_conversion): Only give an error if for_sure. + + * typeck.c (comp_target_types): Only support pointer conversions if + nptrs > 0. + +Wed Mar 22 19:30:15 1995 Brendan Kehoe (brendan@lisa.cygnus.com) + + * init.c (build_new): Catch use of an initializer list where it + shouldn't be. + +Wed Mar 22 16:21:07 1995 Jason Merrill <jason@phydeaux.cygnus.com> + + * init.c (build_new): Wrap alloc_expr in an RTL_EXPR if nelts is + non-constant. + + * decl2.c: temp_name_counter is now public. + + * decl.c (struct cp_function): Add temp_name_counter field. + (push_cp_function_context): Save it. + (pop_cp_function_context): Restore it. + + * typeck.c (common_type): Handle unifying function types, and unify + unmatched things to void* with a compiler_error, rather than + silently like before. + Wed Mar 22 15:10:34 1995 Mike Stump <mrs@cygnus.com> * decl2.c (finish_prevtable_vardecl, finish_vtable_vardecl): Revert diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 7e880b4..89f5914 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1560,10 +1560,13 @@ build_type_conversion (code, xtype, expr, for_sure) { if (winner) { - cp_error ("ambiguous conversion from `%T' to `%T'", basetype, - xtype); - cp_error (" candidate conversions include `%T' and `%T'", - TREE_VALUE (winner), TREE_VALUE (conv)); + if (for_sure) + { + cp_error ("ambiguous conversion from `%T' to `%T'", basetype, + xtype); + cp_error (" candidate conversions include `%T' and `%T'", + TREE_VALUE (winner), TREE_VALUE (conv)); + } return NULL_TREE; } else diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index c9865e3..15bb2e0 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2356,6 +2356,7 @@ duplicate_decls (newdecl, olddecl) DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl); DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl); DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl); + DECL_ABSTRACT_VIRTUAL_P (newdecl) |= DECL_ABSTRACT_VIRTUAL_P (olddecl); } /* Deal with C++: must preserve virtual function table size. */ @@ -12216,6 +12217,7 @@ struct cp_function int assigns_this; int just_assigned_this; int parms_stored; + int temp_name_counter; tree named_labels; tree shadowed_labels; tree ctor_label; @@ -12229,6 +12231,8 @@ struct cp_function struct cp_function *cp_function_chain; +extern int temp_name_counter; + /* Save and reinitialize the variables used during compilation of a C++ function. */ @@ -12259,6 +12263,7 @@ push_cp_function_context (context) p->result_rtx = original_result_rtx; p->base_init_insns = base_init_insns; p->protect_list = protect_list; + p->temp_name_counter = temp_name_counter; } /* Restore the variables used during compilation of a C++ function. */ @@ -12306,6 +12311,7 @@ pop_cp_function_context (context) current_function_parms_stored = p->parms_stored; original_result_rtx = p->result_rtx; base_init_insns = p->base_init_insns; + temp_name_counter = p->temp_name_counter; free (p); } diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 633fc8b..55ad97e 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -55,7 +55,7 @@ static tree saved_inlines; /* Used to help generate temporary names which are unique within a function. Reset to 0 by start_function. */ -static int temp_name_counter; +int temp_name_counter; /* Same, but not reset. Local temp variables and global temp variables can have the same name. */ @@ -2861,16 +2861,6 @@ finish_file () /* Walk to mark the inline functions we need, then output them so that we can pick up any other tdecls that those routines need. */ walk_vtables ((void (*)())0, finish_prevtable_vardecl); - for (vars = saved_inlines; vars; vars = TREE_CHAIN (vars)) - { - tree decl = TREE_VALUE (vars); - - if (DECL_ARTIFICIAL (decl) - && ! DECL_INITIAL (decl) - && (TREE_USED (decl) || ! DECL_EXTERNAL (decl))) - synthesize_method (decl); - } - walk_vtables ((void (*)())0, finish_prevtable_vardecl); if (needs_cleaning == 0) goto mess_up; @@ -3103,7 +3093,8 @@ finish_file () if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)) { - if (TREE_USED (decl)) + if (TREE_USED (decl) + || (TREE_PUBLIC (decl) && ! DECL_EXTERNAL (decl))) synthesize_method (decl); else { diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 3737613..8dfbc31 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3091,6 +3091,11 @@ build_new (placement, decl, init, use_global_new) if (TREE_CHAIN (init) != NULL_TREE) pedwarn ("initializer list being treated as compound expression"); + else if (TREE_CODE (init) == CONSTRUCTOR) + { + pedwarn ("initializer list appears where operand should be used"); + init = TREE_OPERAND (init, 1); + } init = build_compound_expr (init); init = convert_for_initialization (deref, type, init, LOOKUP_NORMAL, @@ -3150,6 +3155,29 @@ build_new (placement, decl, init, use_global_new) can't easily know the latter, just do it always. */ tree xval = make_node (RTL_EXPR); + /* If we want to check the value of the allocation expression, + and the number of elements in the array is not a constant, we + *must* expand the SAVE_EXPR for nelts in alloc_expr before we + expand it in the actual initalization. So we need to build up + an RTL_EXPR for alloc_expr. Sigh. */ + if (alloc_expr && ! TREE_CONSTANT (nelts)) + { + tree xval = make_node (RTL_EXPR); + rtx rtxval; + TREE_TYPE (xval) = TREE_TYPE (alloc_expr); + do_pending_stack_adjust (); + start_sequence_for_rtl_expr (xval); + emit_note (0, -1); + rtxval = expand_expr (alloc_expr, NULL, VOIDmode, 0); + do_pending_stack_adjust (); + TREE_SIDE_EFFECTS (xval) = 1; + RTL_EXPR_SEQUENCE (xval) = get_insns (); + end_sequence (); + RTL_EXPR_RTL (xval) = rtxval; + TREE_TYPE (xval) = TREE_TYPE (alloc_expr); + alloc_expr = xval; + } + TREE_TYPE (xval) = TREE_TYPE (rval); do_pending_stack_adjust (); start_sequence_for_rtl_expr (xval); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index e05265a..ce5e4f8 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -924,16 +924,26 @@ instantiate_member_templates (classname) } } -struct tinst_level *current_tinst_level = 0; -struct tinst_level *free_tinst_level = 0; +static struct tinst_level *current_tinst_level = 0; +static struct tinst_level *free_tinst_level = 0; +static int tinst_depth = 0; +int max_tinst_depth = 17; -void +int push_tinst_level (name) tree name; { struct tinst_level *new; tree global = IDENTIFIER_GLOBAL_VALUE (name); + if (tinst_depth >= max_tinst_depth) + { + error ("template instantiation depth exceeds maximum of %d", + max_tinst_depth); + cp_error (" instantiating `%D'", name); + return 0; + } + if (free_tinst_level) { new = free_tinst_level; @@ -955,6 +965,8 @@ push_tinst_level (name) } new->next = current_tinst_level; current_tinst_level = new; + ++tinst_depth; + return 1; } void @@ -965,6 +977,7 @@ pop_tinst_level () current_tinst_level = old->next; old->next = free_tinst_level; free_tinst_level = old; + --tinst_depth; } struct tinst_level * @@ -1040,9 +1053,8 @@ instantiate_class_template (classname, setup_parse) push_to_top_level (); template_info = DECL_TEMPLATE_INFO (t1); - if (setup_parse) + if (setup_parse && push_tinst_level (classname)) { - push_tinst_level (classname); push_template_decls (DECL_TEMPLATE_PARMS (TREE_PURPOSE (template)), TREE_VALUE (template), 0); set_current_level_tags_transparency (1); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 2467882..b8cf968 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -379,13 +379,10 @@ common_type (t1, t2) if (tt1 == tt2) target = tt1; - else if ((IS_AGGR_TYPE_CODE (TREE_CODE (tt1)) - || TREE_CODE (tt1) == OFFSET_TYPE - || TREE_CODE (tt1) == METHOD_TYPE) - && TREE_CODE (tt2) == TREE_CODE (tt1)) - target = common_type (tt1, tt2); - else + else if (tt1 == void_type_node || tt2 == void_type_node) target = void_type_node; + else + target = common_type (tt1, tt2); target = cp_build_type_variant (target, constp, volatilep); if (code1 == POINTER_TYPE) @@ -775,27 +772,32 @@ comp_target_types (ttl, ttr, nptrs) if (ttl == ttr) return 1; - if (TREE_CODE (ttl) == VOID_TYPE - && TREE_CODE (ttr) != FUNCTION_TYPE - && TREE_CODE (ttr) != METHOD_TYPE - && TREE_CODE (ttr) != OFFSET_TYPE) - return 1; - if (TREE_CODE (ttr) == VOID_TYPE - && TREE_CODE (ttl) != FUNCTION_TYPE - && TREE_CODE (ttl) != METHOD_TYPE - && TREE_CODE (ttl) != OFFSET_TYPE) - return -1; - if (TREE_CODE (ttr) != TREE_CODE (ttl)) return 0; if (TREE_CODE (ttr) == POINTER_TYPE) { - if (TREE_CODE (TREE_TYPE (ttl)) == POINTER_TYPE - || TREE_CODE (TREE_TYPE (ttl)) == ARRAY_TYPE) - return comp_ptr_ttypes (TREE_TYPE (ttl), TREE_TYPE (ttr)); - else - return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs - 1); + ttl = TREE_TYPE (ttl); + ttr = TREE_TYPE (ttr); + + if (nptrs > 0) + { + if (TREE_CODE (ttl) == POINTER_TYPE + || TREE_CODE (ttl) == ARRAY_TYPE) + return comp_ptr_ttypes (ttl, ttr); + else if (TREE_CODE (ttl) == VOID_TYPE + && TREE_CODE (ttr) != FUNCTION_TYPE + && TREE_CODE (ttr) != METHOD_TYPE + && TREE_CODE (ttr) != OFFSET_TYPE) + return 1; + else if (TREE_CODE (ttr) == VOID_TYPE + && TREE_CODE (ttl) != FUNCTION_TYPE + && TREE_CODE (ttl) != METHOD_TYPE + && TREE_CODE (ttl) != OFFSET_TYPE) + return -1; + } + + return comp_target_types (ttl, ttr, nptrs - 1); } if (TREE_CODE (ttr) == REFERENCE_TYPE) |