This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
(C++) various minor tweaks
- To: egcs-patches at egcs dot cygnus dot com
- Subject: (C++) various minor tweaks
- From: Jason Merrill <jason at cygnus dot com>
- Date: Fri, 9 Jul 1999 11:04:26 -0700
1999-07-09 Jason Merrill <jason@yorick.cygnus.com>
* pt.c (do_decl_instantiation): Downgrade duplicate instantiation
errors to pedwarn.
1999-07-09 Michael Tiemann <tiemann@happy.cygnus.com>
* 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.
Index: class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.162
diff -c -p -r1.162 class.c
*** class.c 1999/06/15 16:42:41 1.162
--- class.c 1999/07/09 17:51:28
*************** duplicate_tag_error (t)
*** 2146,2151 ****
--- 2146,2152 ----
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. */
*************** finish_struct (t, attributes, warn_anon)
*** 4186,4192 ****
{
finish_struct_methods (t);
TYPE_SIZE (t) = integer_zero_node;
! }
else
finish_struct_1 (t, warn_anon);
--- 4187,4193 ----
{
finish_struct_methods (t);
TYPE_SIZE (t) = integer_zero_node;
! }
else
finish_struct_1 (t, warn_anon);
Index: decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.378
diff -c -p -r1.378 decl.c
*** decl.c 1999/07/05 14:04:46 1.378
--- decl.c 1999/07/09 17:51:29
*************** duplicate_decls (newdecl, olddecl)
*** 3698,3704 ****
}
if (! types_match || new_defines_function)
{
! /* These need to be copied so that the names are available. */
DECL_ARGUMENTS (olddecl) = DECL_ARGUMENTS (newdecl);
DECL_RESULT (olddecl) = DECL_RESULT (newdecl);
}
--- 3698,3706 ----
}
if (! types_match || new_defines_function)
{
! /* 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);
}
*************** duplicate_decls (newdecl, olddecl)
*** 3706,3712 ****
/* If defining a function declared with other language
linkage, use the previously declared language linkage. */
DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
! else
{
/* If redeclaring a builtin function, and not a definition,
it stays built in. */
--- 3708,3714 ----
/* If defining a function declared with other language
linkage, use the previously declared language linkage. */
DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
! else if (types_match)
{
/* If redeclaring a builtin function, and not a definition,
it stays built in. */
*************** lookup_name_real (name, prefer_type, non
*** 5858,5863 ****
--- 5860,5869 ----
}
/* 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;
Index: init.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/init.c,v
retrieving revision 1.111
diff -c -p -r1.111 init.c
*** init.c 1999/06/22 07:21:50 1.111
--- init.c 1999/07/09 17:51:29
*************** emit_base_init (t, immediately)
*** 696,702 ****
}
/* Check that all fields are properly initialized after
! an assignment to `this'. */
void
check_base_init (t)
--- 696,703 ----
}
/* Check that all fields are properly initialized after
! an assignment to `this'. Called only when such an assignment
! is actually noted. */
void
check_base_init (t)
Index: pt.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/pt.c,v
retrieving revision 1.307
diff -c -p -r1.307 pt.c
*** pt.c 1999/06/14 15:56:12 1.307
--- pt.c 1999/07/09 17:51:30
*************** do_decl_instantiation (declspecs, declar
*** 8952,8959 ****
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);
return;
}
else if (DECL_EXPLICIT_INSTANTIATION (result))
--- 8952,8959 ----
No program shall both explicitly instantiate and explicitly
specialize a template. */
! cp_pedwarn ("explicit instantiation of `%#D' after", result);
! cp_pedwarn_at ("explicit specialization here", result);
return;
}
else if (DECL_EXPLICIT_INSTANTIATION (result))
*************** do_decl_instantiation (declspecs, declar
*** 8967,8973 ****
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);
/* If we've already instantiated the template, just return now. */
if (DECL_INTERFACE_KNOWN (result))
--- 8967,8973 ----
first instantiation was `extern' and the second is not, and
EXTERN_P for the opposite case. */
if (DECL_INTERFACE_KNOWN (result) && !extern_p)
! cp_pedwarn ("duplicate explicit instantiation of `%#D'", result);
/* If we've already instantiated the template, just return now. */
if (DECL_INTERFACE_KNOWN (result))
Index: ptree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/ptree.c,v
retrieving revision 1.17
diff -c -p -r1.17 ptree.c
*** ptree.c 1999/05/19 00:48:07 1.17
--- ptree.c 1999/07/09 17:51:30
*************** print_lang_type (file, node, indent)
*** 128,133 ****
--- 128,135 ----
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);
}
Index: rtti.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/rtti.c,v
retrieving revision 1.32
diff -c -p -r1.32 rtti.c
*** rtti.c 1999/04/27 09:41:31 1.32
--- rtti.c 1999/07/09 17:51:30
*************** synthesize_tinfo_fn (fndecl)
*** 1178,1182 ****
--- 1178,1183 ----
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);
}
Index: search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.107
diff -c -p -r1.107 search.c
*** search.c 1999/06/15 16:42:46 1.107
--- search.c 1999/07/09 17:51:30
*************** note_debug_info_needed (type)
*** 2799,2805 ****
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)
return;
dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp, 0);
--- 2799,2806 ----
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
! || write_symbols == NO_DEBUG)
return;
dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp, 0);
Index: typeck.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/typeck.c,v
retrieving revision 1.172
diff -c -p -r1.172 typeck.c
*** typeck.c 1999/07/06 12:34:50 1.172
--- typeck.c 1999/07/09 17:51:31
*************** comptypes (type1, type2, strict)
*** 906,920 ****
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;
! }
break;
case OFFSET_TYPE:
--- 906,914 ----
TYPE_TI_ARGS (t2));
look_hard:
if ((strict & COMPARE_BASE) && DERIVED_FROM_P (t1, t2))
! val = 1;
! else if ((strict & COMPARE_RELAXED) && DERIVED_FROM_P (t2, t1))
! val = 1;
break;
case OFFSET_TYPE:
Index: xref.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/xref.c,v
retrieving revision 1.17
diff -c -p -r1.17 xref.c
*** xref.c 1999/03/26 07:45:00 1.17
--- xref.c 1999/07/09 17:51:31
*************** int flag_gnu_xref;
*** 58,70 ****
#define FALSE 0
#endif
! #define PALLOC(typ) ((typ *) calloc(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))))
#define SFREE(str) (str != NULL && (free(str),0))
#define STREQL(s1,s2) (strcmp((s1),(s2)) == 0)
--- 58,70 ----
#define FALSE 0
#endif
! #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 *) xmalloc (strlen ((str)) + 1), (str))))
#define SFREE(str) (str != NULL && (free(str),0))
#define STREQL(s1,s2) (strcmp((s1),(s2)) == 0)