Commit 9a0e77ba by Jason Merrill Committed by Mike Stump

43rd Cygnus<->FSF merge

From-SVN: r7660
parent 2c33b8c2
Fri Jul 1 09:35:51 1994 Jason Merrill (jason@deneb.cygnus.com)
* parse.y (init): ANSI C++ does not forbid { }.
Thu Jun 30 00:35:22 1994 Jason Merrill (jason@deneb.cygnus.com)
* decl2.c (lang_decode_option): Set warn_nonvdtor along with -Wall.
warn_nonvdtor defaults to off.
* class.c (instantiate_type): Use comptypes rather than relying on
types to satisfy ==.
* decl.c (start_function): Set DECL_DEFER_OUTPUT on all inlines that
might be static.
* tree.c (build_cplus_new): Never build WITH_CLEANUP_EXPRs.
* decl.c (grok_reference_init): Deal with ADDR_EXPRs of TARGET_EXPRs.
* cvt.c (cp_convert): Pass 0 to with_cleanup_p arg of
build_cplus_new.
Wed Jun 29 22:31:09 1994 Jason Merrill (jason@deneb.cygnus.com)
* decl2.c (finish_file): Maybe consider static inlines multiple
times, in case they reference each other.
Tue Jun 28 11:58:38 1994 Gerald Baumgartner (gb@cs.purdue.edu) Tue Jun 28 11:58:38 1994 Gerald Baumgartner (gb@cs.purdue.edu)
* class.c (finish_struct): Don't `cons_up_default_function's * class.c (finish_struct): Don't `cons_up_default_function's
......
...@@ -1779,7 +1779,7 @@ build_method_call (instance, name, parms, basetype_path, flags) ...@@ -1779,7 +1779,7 @@ build_method_call (instance, name, parms, basetype_path, flags)
if ((IS_SIGNATURE (basetype) if ((IS_SIGNATURE (basetype)
&& (instance_ptr = build_optr_ref (instance))) && (instance_ptr = build_optr_ref (instance)))
|| (lvalue_p (instance) || (lvalue_p (instance)
&& (instance_ptr = build_unary_op (ADDR_EXPR, instance, 0))) && (instance_ptr = build_unary_op (ADDR_EXPR, instance, 0)))
|| (instance_ptr = unary_complex_lvalue (ADDR_EXPR, instance))) || (instance_ptr = unary_complex_lvalue (ADDR_EXPR, instance)))
{ {
if (instance_ptr == error_mark_node) if (instance_ptr == error_mark_node)
......
...@@ -4706,10 +4706,10 @@ instantiate_type (lhstype, rhs, complain) ...@@ -4706,10 +4706,10 @@ instantiate_type (lhstype, rhs, complain)
{ {
elem = TREE_VALUE (baselink); elem = TREE_VALUE (baselink);
while (elem) while (elem)
if (TREE_TYPE (elem) != lhstype) if (comptypes (lhstype, TREE_TYPE (elem), 1))
elem = TREE_CHAIN (elem);
else
return elem; return elem;
else
elem = TREE_CHAIN (elem);
} }
/* No exact match found, look for a compatible method. */ /* No exact match found, look for a compatible method. */
......
...@@ -1395,7 +1395,9 @@ cp_convert (type, expr, convtype, flags) ...@@ -1395,7 +1395,9 @@ cp_convert (type, expr, convtype, flags)
cp_error ("in conversion to type `%T'", type); cp_error ("in conversion to type `%T'", type);
return error_mark_node; return error_mark_node;
} }
rval = build_cplus_new (type, init, 1); /* We can't pass 1 to the with_cleanup_p arg here, because that
screws up passing classes by value. */
rval = build_cplus_new (type, init, 0);
return rval; return rval;
} }
} }
......
...@@ -5593,14 +5593,31 @@ grok_reference_init (decl, type, init, cleanupp) ...@@ -5593,14 +5593,31 @@ grok_reference_init (decl, type, init, cleanupp)
goto fail; goto fail;
else if (tmp != NULL_TREE) else if (tmp != NULL_TREE)
{ {
tree subtype = TREE_TYPE (type);
init = tmp; init = tmp;
if (TREE_CODE (init) == WITH_CLEANUP_EXPR) /* Associate the cleanup with the reference so that we
don't get burned by "aggressive" cleanup policy. */
if (TYPE_NEEDS_DESTRUCTOR (subtype))
{ {
/* Associate the cleanup with the reference so that we if (TREE_CODE (init) == WITH_CLEANUP_EXPR)
don't get burned by "aggressive" cleanup policy. */ {
*cleanupp = TREE_OPERAND (init, 2); *cleanupp = TREE_OPERAND (init, 2);
TREE_OPERAND (init, 2) = error_mark_node; TREE_OPERAND (init, 2) = error_mark_node;
}
else
{
if (TREE_CODE (tmp) == ADDR_EXPR)
tmp = TREE_OPERAND (tmp, 0);
if (TREE_CODE (tmp) == TARGET_EXPR)
{
*cleanupp = build_delete
(TYPE_POINTER_TO (subtype),
build_unary_op (ADDR_EXPR, TREE_OPERAND (tmp, 0), 0),
integer_two_node, LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0);
TREE_OPERAND (tmp, 2) = error_mark_node;
}
}
} }
if (TREE_SIDE_EFFECTS (init)) if (TREE_SIDE_EFFECTS (init))
...@@ -10708,9 +10725,7 @@ start_function (declspecs, declarator, raises, pre_parsed_p) ...@@ -10708,9 +10725,7 @@ start_function (declspecs, declarator, raises, pre_parsed_p)
defining how to inline. So set DECL_EXTERNAL in that case. */ defining how to inline. So set DECL_EXTERNAL in that case. */
DECL_EXTERNAL (decl1) = current_extern_inline; DECL_EXTERNAL (decl1) = current_extern_inline;
DECL_DEFER_OUTPUT (decl1) DECL_DEFER_OUTPUT (decl1) = DECL_INLINE (decl1);
= (DECL_INLINE (decl1) && (DECL_IMPLICIT_INSTANTIATION (decl1)
|| DECL_FUNCTION_MEMBER_P (decl1)));
} }
if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1)) if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1))
......
...@@ -202,7 +202,7 @@ int warn_overloaded_virtual; ...@@ -202,7 +202,7 @@ int warn_overloaded_virtual;
/* Non-zero means warn when declaring a class that has a non virtual /* Non-zero means warn when declaring a class that has a non virtual
destructor, when it really ought to have a virtual one. */ destructor, when it really ought to have a virtual one. */
int warn_nonvdtor = 1; int warn_nonvdtor;
/* Non-zero means warn when a function is declared extern and later inline. */ /* Non-zero means warn when a function is declared extern and later inline. */
int warn_extern_inline; int warn_extern_inline;
...@@ -530,6 +530,7 @@ lang_decode_option (p) ...@@ -530,6 +530,7 @@ lang_decode_option (p)
warn_format = setting; warn_format = setting;
warn_missing_braces = setting; warn_missing_braces = setting;
warn_extern_inline = setting; warn_extern_inline = setting;
warn_nonvdtor = setting;
/* We save the value of warn_uninitialized, since if they put /* We save the value of warn_uninitialized, since if they put
-Wuninitialized on the command line, we need to generate a -Wuninitialized on the command line, we need to generate a
warning about not using it without also specifying -O. */ warning about not using it without also specifying -O. */
...@@ -2760,44 +2761,81 @@ finish_file () ...@@ -2760,44 +2761,81 @@ finish_file ()
emit_thunk (vars); emit_thunk (vars);
} }
/* Now write out inline functions which had their addresses taken {
and which were not declared virtual and which were not declared int reconsider = 0; /* More may be referenced; check again */
`extern inline'. */ tree delayed = NULL_TREE; /* These might be referenced later */
while (saved_inlines)
{ /* Now write out inline functions which had their addresses taken and
tree decl = TREE_VALUE (saved_inlines); which were not declared virtual and which were not declared `extern
saved_inlines = TREE_CHAIN (saved_inlines); inline'. */
/* Redefinition of a member function can cause DECL_SAVED_INSNS to be while (saved_inlines)
0; don't crash. */ {
if (TREE_ASM_WRITTEN (decl) || DECL_SAVED_INSNS (decl) == 0) tree decl = TREE_VALUE (saved_inlines);
continue; saved_inlines = TREE_CHAIN (saved_inlines);
if (DECL_FUNCTION_MEMBER_P (decl) && !TREE_PUBLIC (decl)) /* Redefinition of a member function can cause DECL_SAVED_INSNS to be
{ 0; don't crash. */
tree ctype = DECL_CLASS_CONTEXT (decl); if (TREE_ASM_WRITTEN (decl) || DECL_SAVED_INSNS (decl) == 0)
if (CLASSTYPE_INTERFACE_KNOWN (ctype)) continue;
{ if (DECL_FUNCTION_MEMBER_P (decl) && !TREE_PUBLIC (decl))
TREE_PUBLIC (decl) = 1; {
DECL_EXTERNAL (decl) tree ctype = DECL_CLASS_CONTEXT (decl);
= (CLASSTYPE_INTERFACE_ONLY (ctype) if (CLASSTYPE_INTERFACE_KNOWN (ctype))
|| (DECL_INLINE (decl) && ! flag_implement_inlines)); {
} TREE_PUBLIC (decl) = 1;
} DECL_EXTERNAL (decl)
if (TREE_PUBLIC (decl) = (CLASSTYPE_INTERFACE_ONLY (ctype)
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) || (DECL_INLINE (decl) && ! flag_implement_inlines));
|| flag_keep_inline_functions) }
{ }
if (DECL_EXTERNAL (decl) if (TREE_PUBLIC (decl)
|| (DECL_IMPLICIT_INSTANTIATION (decl) || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
&& ! flag_implicit_templates)) || flag_keep_inline_functions)
assemble_external (decl); {
else if (DECL_EXTERNAL (decl)
{ || (DECL_IMPLICIT_INSTANTIATION (decl)
temporary_allocation (); && ! flag_implicit_templates))
output_inline_function (decl); assemble_external (decl);
permanent_allocation (1); else
} {
} reconsider = 1;
} temporary_allocation ();
output_inline_function (decl);
permanent_allocation (1);
}
}
else if (TREE_USED (decl)
|| TREE_USED (DECL_ASSEMBLER_NAME (decl)))
delayed = tree_cons (NULL_TREE, decl, delayed);
}
if (reconsider && delayed)
{
while (reconsider)
{
tree place;
reconsider = 0;
for (place = delayed; place; place = TREE_CHAIN (place))
{
tree decl = TREE_VALUE (place);
if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
&& ! TREE_ASM_WRITTEN (decl))
{
if (DECL_EXTERNAL (decl)
|| (DECL_IMPLICIT_INSTANTIATION (decl)
&& ! flag_implicit_templates))
assemble_external (decl);
else
{
reconsider = 1;
temporary_allocation ();
output_inline_function (decl);
permanent_allocation (1);
}
}
}
}
}
}
if (write_virtuals == 2) if (write_virtuals == 2)
{ {
......
...@@ -2021,9 +2021,7 @@ init: ...@@ -2021,9 +2021,7 @@ init:
expr_no_commas %prec '=' expr_no_commas %prec '='
| '{' '}' | '{' '}'
{ $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE); { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
TREE_HAS_CONSTRUCTOR ($$) = 1; TREE_HAS_CONSTRUCTOR ($$) = 1; }
if (pedantic)
pedwarn ("ANSI C++ forbids empty initializer braces"); }
| '{' initlist '}' | '{' initlist '}'
{ $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
TREE_HAS_CONSTRUCTOR ($$) = 1; } TREE_HAS_CONSTRUCTOR ($$) = 1; }
......
...@@ -138,6 +138,7 @@ build_cplus_new (type, init, with_cleanup_p) ...@@ -138,6 +138,7 @@ build_cplus_new (type, init, with_cleanup_p)
TREE_SIDE_EFFECTS (rval) = 1; TREE_SIDE_EFFECTS (rval) = 1;
TREE_ADDRESSABLE (rval) = 1; TREE_ADDRESSABLE (rval) = 1;
#if 0
if (with_cleanup_p && TYPE_NEEDS_DESTRUCTOR (type)) if (with_cleanup_p && TYPE_NEEDS_DESTRUCTOR (type))
{ {
TREE_OPERAND (rval, 2) = error_mark_node; TREE_OPERAND (rval, 2) = error_mark_node;
...@@ -149,6 +150,7 @@ build_cplus_new (type, init, with_cleanup_p) ...@@ -149,6 +150,7 @@ build_cplus_new (type, init, with_cleanup_p)
TREE_SIDE_EFFECTS (rval) = 1; TREE_SIDE_EFFECTS (rval) = 1;
TREE_ADDRESSABLE (rval) = 1; TREE_ADDRESSABLE (rval) = 1;
} }
#endif
return rval; return rval;
} }
...@@ -335,9 +337,6 @@ build_cplus_staticfn_type (basetype, rettype, argtypes) ...@@ -335,9 +337,6 @@ build_cplus_staticfn_type (basetype, rettype, argtypes)
TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype); TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
TREE_TYPE (t) = rettype; TREE_TYPE (t) = rettype;
/* The actual arglist for this function includes a "hidden" argument
which is "this". Put it into the list of argument types. */
TYPE_ARG_TYPES (t) = argtypes; TYPE_ARG_TYPES (t) = argtypes;
/* If we already have such a type, use the old one and free this one. /* If we already have such a type, use the old one and free this one.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment