From 6f1b4c42790b1a8083ae217facb58eb3f0cfa819 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 9 Jul 1999 07:05:23 -0400 Subject: pt.c (do_decl_instantiation): Downgrade duplicate instantiation errors to pedwarn. * pt.c (do_decl_instantiation): Downgrade duplicate instantiation errors to pedwarn. * typeck.c (comptypes): Simplify C code in look_hard. * xref.c (PALLOC): Use xcalloc, not calloc. (SALLOC): Use xmalloc, not malloc. * rtti.c (synthesize_tinfo_fn): Add missing call to pop_momentary. * search.c (note_debug_info_needed): Don't search if WRITE_SYMBOLS is NO_DEBUG. * decl.c (duplicate_decls): If a redeclaration doesn't match the initial declaration, then don't save the inline info and by all means don't mark the function as a builtin function. * decl.c (lookup_name_real): Set NONCLASS to 1 if CURRENT_CLASS_TYPE is 0. * class.c (duplicate_tag_error): Set TYPE_NONCOPIED_PARTS to NULL_TREE. From-SVN: r28044 --- gcc/cp/ChangeLog | 27 +++++++++++++++++++++++++++ gcc/cp/class.c | 3 ++- gcc/cp/decl.c | 10 ++++++++-- gcc/cp/init.c | 3 ++- gcc/cp/pt.c | 6 +++--- gcc/cp/ptree.c | 2 ++ gcc/cp/rtti.c | 1 + gcc/cp/search.c | 3 ++- gcc/cp/typeck.c | 12 +++--------- gcc/cp/xref.c | 4 ++-- 10 files changed, 52 insertions(+), 19 deletions(-) (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 50c3858..442e853 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,30 @@ +1999-07-09 Jason Merrill + + * pt.c (do_decl_instantiation): Downgrade duplicate instantiation + errors to pedwarn. + +1999-07-09 Michael Tiemann + + * typeck.c (comptypes): Simplify C code in look_hard. + + * xref.c (PALLOC): Use xcalloc, not calloc. + (SALLOC): Use xmalloc, not malloc. + + * rtti.c (synthesize_tinfo_fn): Add missing call to pop_momentary. + + * search.c (note_debug_info_needed): Don't search if WRITE_SYMBOLS + is NO_DEBUG. + + * decl.c (duplicate_decls): If a redeclaration doesn't match the + initial declaration, then don't save the inline info and by all + means don't mark the function as a builtin function. + + * decl.c (lookup_name_real): Set NONCLASS to 1 if + CURRENT_CLASS_TYPE is 0. + + * class.c (duplicate_tag_error): Set TYPE_NONCOPIED_PARTS to + NULL_TREE. + Wed Jul 7 01:26:47 1999 Alexandre Oliva * decl2.c (mark_vtable_entries): Fix check for rtti offset. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a04d2a0..4fcb2fd 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2146,6 +2146,7 @@ duplicate_tag_error (t) TYPE_METHODS (t) = NULL_TREE; TYPE_VFIELD (t) = NULL_TREE; TYPE_CONTEXT (t) = NULL_TREE; + TYPE_NONCOPIED_PARTS (t) = NULL_TREE; } /* finish up all new vtables. */ @@ -4186,7 +4187,7 @@ finish_struct (t, attributes, warn_anon) { finish_struct_methods (t); TYPE_SIZE (t) = integer_zero_node; - } + } else finish_struct_1 (t, warn_anon); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index cad878a..597a2ea 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3698,7 +3698,9 @@ duplicate_decls (newdecl, olddecl) } if (! types_match || new_defines_function) { - /* These need to be copied so that the names are available. */ + /* These need to be copied so that the names are available. + Note that if the types do match, we'll preserve inline + info and other bits, but if not, we won't. */ DECL_ARGUMENTS (olddecl) = DECL_ARGUMENTS (newdecl); DECL_RESULT (olddecl) = DECL_RESULT (newdecl); } @@ -3706,7 +3708,7 @@ duplicate_decls (newdecl, olddecl) /* If defining a function declared with other language linkage, use the previously declared language linkage. */ DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl); - else + else if (types_match) { /* If redeclaring a builtin function, and not a definition, it stays built in. */ @@ -5858,6 +5860,10 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only) } /* First, look in non-namespace scopes. */ + + if (current_class_type == NULL_TREE) + nonclass = 1; + for (t = IDENTIFIER_BINDING (name); t; t = TREE_CHAIN (t)) { tree binding; diff --git a/gcc/cp/init.c b/gcc/cp/init.c index cba2842..de3491a 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -696,7 +696,8 @@ emit_base_init (t, immediately) } /* Check that all fields are properly initialized after - an assignment to `this'. */ + an assignment to `this'. Called only when such an assignment + is actually noted. */ void check_base_init (t) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 712ad6c..d591c46 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8952,8 +8952,8 @@ do_decl_instantiation (declspecs, declarator, storage) No program shall both explicitly instantiate and explicitly specialize a template. */ - cp_error ("explicit instantiation of `%#D' after", result); - cp_error_at ("explicit specialization here", result); + cp_pedwarn ("explicit instantiation of `%#D' after", result); + cp_pedwarn_at ("explicit specialization here", result); return; } else if (DECL_EXPLICIT_INSTANTIATION (result)) @@ -8967,7 +8967,7 @@ do_decl_instantiation (declspecs, declarator, storage) first instantiation was `extern' and the second is not, and EXTERN_P for the opposite case. */ if (DECL_INTERFACE_KNOWN (result) && !extern_p) - cp_error ("duplicate explicit instantiation of `%#D'", result); + cp_pedwarn ("duplicate explicit instantiation of `%#D'", result); /* If we've already instantiated the template, just return now. */ if (DECL_INTERFACE_KNOWN (result)) diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c index 502c1f0..4008e39 100644 --- a/gcc/cp/ptree.c +++ b/gcc/cp/ptree.c @@ -128,6 +128,8 @@ print_lang_type (file, node, indent) fprintf (file, " interface-only"); if (CLASSTYPE_INTERFACE_UNKNOWN (node)) fprintf (file, " interface-unknown"); + if (CLASSTYPE_VTABLE_NEEDS_WRITING (node)) + fprintf (file, " vtable-needs-writing"); print_node (file, "member-functions", CLASSTYPE_METHOD_VEC (node), indent + 4); } diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index e0ce5cd..4dec4cb 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1178,5 +1178,6 @@ synthesize_tinfo_fn (fndecl) tmp = cp_convert (build_pointer_type (type_info_type_node), addr); tmp = build_indirect_ref (tmp, 0); c_expand_return (tmp); + pop_momentary (); finish_function (lineno, 0, 0); } diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 75a1ac2..f2e9aa7 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -2799,7 +2799,8 @@ note_debug_info_needed (type) could, but that would mean putting global labels in the debug output before each exported type and each of its functions and static data members. */ - if (write_symbols == DWARF_DEBUG || write_symbols == DWARF2_DEBUG) + if (write_symbols == DWARF_DEBUG || write_symbols == DWARF2_DEBUG + || write_symbols == NO_DEBUG) return; dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp, 0); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 8829d9d..fa54e37 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -906,15 +906,9 @@ comptypes (type1, type2, strict) TYPE_TI_ARGS (t2)); look_hard: if ((strict & COMPARE_BASE) && DERIVED_FROM_P (t1, t2)) - { - val = 1; - break; - } - if ((strict & COMPARE_RELAXED) && DERIVED_FROM_P (t2, t1)) - { - val = 1; - break; - } + val = 1; + else if ((strict & COMPARE_RELAXED) && DERIVED_FROM_P (t2, t1)) + val = 1; break; case OFFSET_TYPE: diff --git a/gcc/cp/xref.c b/gcc/cp/xref.c index 6e06eda..003910c 100644 --- a/gcc/cp/xref.c +++ b/gcc/cp/xref.c @@ -58,13 +58,13 @@ int flag_gnu_xref; #define FALSE 0 #endif -#define PALLOC(typ) ((typ *) calloc(1,sizeof(typ))) +#define PALLOC(typ) ((typ *) xcalloc(1,sizeof(typ))) /* Return a malloc'd copy of STR. */ #define SALLOC(str) \ ((char *) ((str) == NULL ? NULL \ - : (char *) strcpy ((char *) malloc (strlen ((str)) + 1), (str)))) + : (char *) strcpy ((char *) xmalloc (strlen ((str)) + 1), (str)))) #define SFREE(str) (str != NULL && (free(str),0)) #define STREQL(s1,s2) (strcmp((s1),(s2)) == 0) -- cgit v1.1