73rd Cygnus<->FSF merge

From-SVN: r9826
This commit is contained in:
Mike Stump 1995-05-27 00:15:16 +00:00
parent 73b73053ff
commit 878cd28949
9 changed files with 213 additions and 78 deletions

View File

@ -17,8 +17,66 @@ Mon May 22 17:38:48 1995 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
(c++.mostlyclean, stage[1-4]): Use $(objext) in object file names.
* Makefile.in (../cc1plus): Use $(exeext) in name of executable.
Wed May 24 01:39:03 1995 Jason Merrill <jason@deneb.cygnus.com>
* call.c (build_method_call): parms can be null, duh.
Tue May 23 01:32:09 1995 Jason Merrill <jason@deneb.cygnus.com>
* call.c (build_method_call): If convert_arguments failed, just bail.
Fri May 19 10:31:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* cvt.c (convert_force): Pass LOOKUP_NORMAL to cp_convert.
* tree.c (copy_to_permanent): Oops.
Fri May 19 10:01:07 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
* cp-tree.h (break_out_target_exprs): Add decl.
Thu May 18 13:02:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* decl.c (start_function): Move *all* interface handling stuff after
the pushdecl.
* tree.c (mapcar): Renamed from make_deep_copy and generalized.
(perm_manip): Return t if permanent, otherwise 0.
(copy_to_permanent): Use them.
(bot_manip): Helper for break_out_target_exprs.
(break_out_target_exprs): New function. Uses mapcar.
* typeck.c (convert_arguments): Use it.
* method.c (hack_identifier): Use convert_from_reference to
dereference a reference.
Wed May 17 17:54:54 1995 Mike Stump <mrs@cygnus.com>
* call.c (convert_harshness): Move reference bashing before pointer
to member bashing.
Wed May 17 16:57:53 1995 Mike Stump <mrs@cygnus.com>
* cvt.c (convert_to_reference): Only complain, if complaints are
wanted.
typeck.c (build_function_call_real): Ditto. If LOOKUP_SPECULATIVELY
is set and something won't work, return NULL_TREE.
cvt.c (cp_convert): Ditto. Pass flags down to build_method_call.
(convert): Pass LOOKUP_NORMAL to cp_convert.
typeck.c (convert_for_assignment): Ditto.
(convert_force): Pass LOOKUP_COMPLAIN to cp_convert.
typeck.c (convert_arguments): Get out early if we get an
error_mark_node.
(convert_for_initialization): Use cp_convert instead of convert so
that we can pass flags down.
* cp-tree.h (LOOKUP_SPECULATIVELY): Added documentation.
Wed May 17 01:43:58 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* typeck2.c (store_init_value): Don't take the MAIN_VARIANT of the
decl type.
* class.c (finish_struct): Don't complain about a class with no
user-defined constructors but with a member that has no default
constructor, as this is OK for aggregates.

View File

@ -129,11 +129,6 @@ convert_harshness (type, parmtype, parm)
n_convert_harshness++;
#endif
if (TYPE_PTRMEMFUNC_P (type))
type = TYPE_PTRMEMFUNC_FN_TYPE (type);
if (TYPE_PTRMEMFUNC_P (parmtype))
parmtype = TYPE_PTRMEMFUNC_FN_TYPE (parmtype);
if (TREE_CODE (parmtype) == REFERENCE_TYPE)
{
if (parm)
@ -146,6 +141,11 @@ convert_harshness (type, parmtype, parm)
else
lvalue = 0;
if (TYPE_PTRMEMFUNC_P (type))
type = TYPE_PTRMEMFUNC_FN_TYPE (type);
if (TYPE_PTRMEMFUNC_P (parmtype))
parmtype = TYPE_PTRMEMFUNC_FN_TYPE (parmtype);
codel = TREE_CODE (type);
coder = TREE_CODE (parmtype);
@ -2635,6 +2635,10 @@ build_method_call (instance, name, parms, basetype_path, flags)
}
#endif
if (parms == error_mark_node
|| (parms && TREE_CHAIN (parms) == error_mark_node))
return error_mark_node;
if (need_vtbl == needed)
{
function = build_vfn_ref (&TREE_VALUE (parms), instance,

View File

@ -1825,6 +1825,9 @@ extern tree current_class_type; /* _TYPE: the type of the current class */
LOOKUP_HAS_IN_CHARGE means that the "in charge" variable is already
in the parameter list.
LOOKUP_ONLYCONVERTING means that non-conversion constructors are not tried.
LOOKUP_SPECULATIVELY means return NULL_TREE if we cannot find what we are
after. Note, LOOKUP_COMPLAIN is checked and error messages printed
before LOOKUP_SPECULATIVELY is checked.
LOOKUP_NO_CONVERSION means that user-defined conversions are not
permitted. Built-in conversions are permitted.
LOOKUP_DESTRUCTOR means explicit call to destructor. */
@ -2361,6 +2364,7 @@ extern void print_lang_statistics PROTO((void));
/* skip __eprintf */
extern tree array_type_nelts_total PROTO((tree));
extern tree array_type_nelts_top PROTO((tree));
extern tree break_out_target_exprs PROTO((tree));
/* in typeck.c */
extern tree condition_conversion PROTO((tree));

View File

@ -836,12 +836,12 @@ convert_to_reference (reftype, expr, convtype, flags, decl)
my_friendly_assert (TREE_CODE (intype) != OFFSET_TYPE, 189);
if (flags & LOOKUP_COMPLAIN)
cp_error ("cannot convert type `%T' to type `%T'", intype, reftype);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
else if (flags & LOOKUP_COMPLAIN)
cp_error ("cannot convert type `%T' to type `%T'", intype, reftype);
return error_mark_node;
}
@ -1190,6 +1190,10 @@ convert_pointer_to_vbase (binfo, expr)
return NULL_TREE;
}
/* Conversion...
FLAGS indicates how we should behave. */
tree
cp_convert (type, expr, convtype, flags)
tree type, expr;
@ -1259,7 +1263,10 @@ cp_convert (type, expr, convtype, flags)
rval = build_type_conversion (CONVERT_EXPR, type, e, 1);
if (rval)
return rval;
cp_error ("`%#T' used where a `%T' was expected", intype, type);
if (flags & LOOKUP_COMPLAIN)
cp_error ("`%#T' used where a `%T' was expected", intype, type);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
return error_mark_node;
}
if (code == BOOLEAN_TYPE)
@ -1278,8 +1285,9 @@ cp_convert (type, expr, convtype, flags)
if (rval)
return rval;
else
cp_error ("`%#T' used where a floating point value was expected",
TREE_TYPE (e));
if (flags & LOOKUP_COMPLAIN)
cp_error ("`%#T' used where a floating point value was expected",
TREE_TYPE (e));
}
return fold (convert_to_real (type, e));
}
@ -1331,7 +1339,8 @@ cp_convert (type, expr, convtype, flags)
if (conversion == error_mark_node)
{
error ("ambiguous pointer conversion");
if (flags & LOOKUP_COMPLAIN)
error ("ambiguous pointer conversion");
return conversion;
}
@ -1339,19 +1348,25 @@ cp_convert (type, expr, convtype, flags)
ctor = build_method_call (NULL_TREE, constructor_name_full (type),
build_tree_list (NULL_TREE, e),
TYPE_BINFO (type),
LOOKUP_NORMAL | LOOKUP_SPECULATIVELY
(flags & LOOKUP_NORMAL) | LOOKUP_SPECULATIVELY
| (convtype&CONV_NONCONVERTING ? 0 : LOOKUP_ONLYCONVERTING)
| (conversion ? LOOKUP_NO_CONVERSION : 0));
if (ctor == error_mark_node)
{
cp_error ("in conversion to type `%T'", type);
if (flags & LOOKUP_COMPLAIN)
cp_error ("in conversion to type `%T'", type);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
return error_mark_node;
}
if (conversion && ctor)
{
error ("both constructor and type conversion operator apply");
if (flags & LOOKUP_COMPLAIN)
error ("both constructor and type conversion operator apply");
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
return error_mark_node;
}
else if (conversion)
@ -1408,8 +1423,11 @@ cp_convert (type, expr, convtype, flags)
&& index_type_equal (TYPE_DOMAIN (TREE_TYPE (e)), TYPE_DOMAIN (type)))
return e;
cp_error ("conversion from `%T' to non-scalar type `%T' requested",
TREE_TYPE (expr), type);
if (flags & LOOKUP_COMPLAIN)
cp_error ("conversion from `%T' to non-scalar type `%T' requested",
TREE_TYPE (expr), type);
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
return error_mark_node;
}
@ -1423,7 +1441,7 @@ tree
convert (type, expr)
tree type, expr;
{
return cp_convert (type, expr, CONV_OLD_CONVERT, 0);
return cp_convert (type, expr, CONV_OLD_CONVERT, LOOKUP_NORMAL);
}
/* Like convert, except permit conversions to take place which
@ -1459,7 +1477,7 @@ convert_force (type, expr, convtype)
return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), e, 1);
}
return cp_convert (type, e, CONV_C_CAST|convtype, 0);
return cp_convert (type, e, CONV_C_CAST|convtype, LOOKUP_NORMAL);
}
/* Subroutine of build_type_conversion. */

View File

@ -11129,6 +11129,19 @@ start_function (declspecs, declarator, raises, pre_parsed_p)
(This does not mean `static' in the C sense!) */
TREE_STATIC (decl1) = 1;
/* Record the decl so that the function name is defined.
If we already have a decl for this name, and it is a FUNCTION_DECL,
use the old decl. */
if (pre_parsed_p == 0)
{
current_function_decl = decl1 = pushdecl (decl1);
DECL_MAIN_VARIANT (decl1) = decl1;
fntype = TREE_TYPE (decl1);
}
else
current_function_decl = decl1;
if (DECL_INTERFACE_KNOWN (decl1))
{
if (DECL_NOT_REALLY_EXTERN (decl1))
@ -11154,28 +11167,16 @@ start_function (declspecs, declarator, raises, pre_parsed_p)
So clear DECL_EXTERNAL. */
DECL_EXTERNAL (decl1) = 0;
if (DECL_C_STATIC (decl1))
TREE_PUBLIC (decl1) = 0;
if (DECL_THIS_INLINE (decl1) && ! DECL_INTERFACE_KNOWN (decl1))
DECL_DEFER_OUTPUT (decl1) = 1;
else
{
DECL_INTERFACE_KNOWN (decl1) = 1;
if (DECL_C_STATIC (decl1))
TREE_PUBLIC (decl1) = 0;
}
}
/* Record the decl so that the function name is defined.
If we already have a decl for this name, and it is a FUNCTION_DECL,
use the old decl. */
if (pre_parsed_p == 0)
{
current_function_decl = decl1 = pushdecl (decl1);
DECL_MAIN_VARIANT (decl1) = decl1;
fntype = TREE_TYPE (decl1);
}
else
current_function_decl = decl1;
if (DECL_THIS_INLINE (decl1) && ! DECL_INTERFACE_KNOWN (decl1))
DECL_DEFER_OUTPUT (decl1) = 1;
else
DECL_INTERFACE_KNOWN (decl1) = 1;
if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1))
{
if (TREE_CODE (fntype) == METHOD_TYPE)

View File

@ -1567,8 +1567,7 @@ hack_identifier (value, name, yychar)
my_friendly_assert (TREE_CODE (value) == VAR_DECL
|| TREE_CODE (value) == PARM_DECL
|| TREE_CODE (value) == RESULT_DECL, 252);
if (DECL_REFERENCE_SLOT (value))
return DECL_REFERENCE_SLOT (value);
return convert_from_reference (value);
}
return value;
}

View File

@ -1614,15 +1614,21 @@ build_exception_variant (ctype, type, raises)
Assuming T is a node build bottom-up, make it all exist on
permanent obstack, if it is not permanent already. */
static tree
make_deep_copy (t)
tree
mapcar (t, func)
tree t;
tree (*func)();
{
enum tree_code code;
tree tmp;
if (t == NULL_TREE || TREE_PERMANENT (t))
if (t == NULL_TREE)
return t;
if (tmp = func (t), tmp != NULL_TREE)
return tmp;
switch (code = TREE_CODE (t))
{
case ERROR_MARK:
@ -1637,10 +1643,10 @@ make_deep_copy (t)
{
tree chain = TREE_CHAIN (t);
t = copy_node (t);
TREE_CHAIN (t) = make_deep_copy (chain);
TREE_TYPE (t) = make_deep_copy (TREE_TYPE (t));
DECL_INITIAL (t) = make_deep_copy (DECL_INITIAL (t));
DECL_SIZE (t) = make_deep_copy (DECL_SIZE (t));
TREE_CHAIN (t) = mapcar (chain, func);
TREE_TYPE (t) = mapcar (TREE_TYPE (t), func);
DECL_INITIAL (t) = mapcar (DECL_INITIAL (t), func);
DECL_SIZE (t) = mapcar (DECL_SIZE (t), func);
return t;
}
@ -1648,9 +1654,9 @@ make_deep_copy (t)
{
tree chain = TREE_CHAIN (t);
t = copy_node (t);
TREE_PURPOSE (t) = make_deep_copy (TREE_PURPOSE (t));
TREE_VALUE (t) = make_deep_copy (TREE_VALUE (t));
TREE_CHAIN (t) = make_deep_copy (chain);
TREE_PURPOSE (t) = mapcar (TREE_PURPOSE (t), func);
TREE_VALUE (t) = mapcar (TREE_VALUE (t), func);
TREE_CHAIN (t) = mapcar (chain, func);
return t;
}
@ -1660,7 +1666,7 @@ make_deep_copy (t)
t = copy_node (t);
while (len--)
TREE_VEC_ELT (t, len) = make_deep_copy (TREE_VEC_ELT (t, len));
TREE_VEC_ELT (t, len) = mapcar (TREE_VEC_ELT (t, len), func);
return t;
}
@ -1673,14 +1679,14 @@ make_deep_copy (t)
case TARGET_EXPR:
case NEW_EXPR:
t = copy_node (t);
TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0));
TREE_OPERAND (t, 1) = make_deep_copy (TREE_OPERAND (t, 1));
TREE_OPERAND (t, 2) = make_deep_copy (TREE_OPERAND (t, 2));
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
TREE_OPERAND (t, 2) = mapcar (TREE_OPERAND (t, 2), func);
return t;
case SAVE_EXPR:
t = copy_node (t);
TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0));
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
return t;
case MODIFY_EXPR:
@ -1718,8 +1724,8 @@ make_deep_copy (t)
case POSTINCREMENT_EXPR:
case CALL_EXPR:
t = copy_node (t);
TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0));
TREE_OPERAND (t, 1) = make_deep_copy (TREE_OPERAND (t, 1));
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
return t;
case CONVERT_EXPR:
@ -1731,36 +1737,36 @@ make_deep_copy (t)
case NOP_EXPR:
case COMPONENT_REF:
t = copy_node (t);
TREE_OPERAND (t, 0) = make_deep_copy (TREE_OPERAND (t, 0));
TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
return t;
case POINTER_TYPE:
return build_pointer_type (make_deep_copy (TREE_TYPE (t)));
return build_pointer_type (mapcar (TREE_TYPE (t), func));
case REFERENCE_TYPE:
return build_reference_type (make_deep_copy (TREE_TYPE (t)));
return build_reference_type (mapcar (TREE_TYPE (t), func));
case FUNCTION_TYPE:
return build_function_type (make_deep_copy (TREE_TYPE (t)),
make_deep_copy (TYPE_ARG_TYPES (t)));
return build_function_type (mapcar (TREE_TYPE (t), func),
mapcar (TYPE_ARG_TYPES (t), func));
case ARRAY_TYPE:
return build_array_type (make_deep_copy (TREE_TYPE (t)),
make_deep_copy (TYPE_DOMAIN (t)));
return build_array_type (mapcar (TREE_TYPE (t), func),
mapcar (TYPE_DOMAIN (t), func));
case INTEGER_TYPE:
return build_index_type (make_deep_copy (TYPE_MAX_VALUE (t)));
return build_index_type (mapcar (TYPE_MAX_VALUE (t), func));
case OFFSET_TYPE:
return build_offset_type (make_deep_copy (TYPE_OFFSET_BASETYPE (t)),
make_deep_copy (TREE_TYPE (t)));
return build_offset_type (mapcar (TYPE_OFFSET_BASETYPE (t), func),
mapcar (TREE_TYPE (t), func));
case METHOD_TYPE:
return build_method_type
(make_deep_copy (TYPE_METHOD_BASETYPE (t)),
(mapcar (TYPE_METHOD_BASETYPE (t), func),
build_function_type
(make_deep_copy (TREE_TYPE (t)),
make_deep_copy (TREE_CHAIN (TYPE_ARG_TYPES (t)))));
(mapcar (TREE_TYPE (t), func),
mapcar (TREE_CHAIN (TYPE_ARG_TYPES (t)), func)));
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (t))
return build_ptrmemfunc_type
(make_deep_copy (TYPE_PTRMEMFUNC_FN_TYPE (t)));
(mapcar (TYPE_PTRMEMFUNC_FN_TYPE (t), func));
/* else fall through */
/* This list is incomplete, but should suffice for now.
@ -1776,6 +1782,15 @@ make_deep_copy (t)
return NULL_TREE;
}
static tree
perm_manip (t)
tree t;
{
if (TREE_PERMANENT (t))
return t;
return NULL_TREE;
}
/* Assuming T is a node built bottom-up, make it all exist on
permanent obstack, if it is not permanent already. */
tree
@ -1793,7 +1808,7 @@ copy_to_permanent (t)
current_obstack = saveable_obstack;
resume = suspend_momentary ();
t = make_deep_copy (t);
t = mapcar (t, perm_manip);
resume_momentary (resume);
current_obstack = ambient_obstack;
@ -1866,3 +1881,24 @@ array_type_nelts_total (type)
}
return sz;
}
static
tree
bot_manip (t)
tree t;
{
if (TREE_CODE (t) != TREE_LIST && ! TREE_SIDE_EFFECTS (t))
return t;
else if (TREE_CODE (t) == TARGET_EXPR)
return build_cplus_new (TREE_TYPE (t),
break_out_target_exprs (TREE_OPERAND (t, 1)), 0);
return NULL_TREE;
}
/* Actually, we'll just clean out the target exprs for the moment. */
tree
break_out_target_exprs (t)
tree t;
{
return mapcar (t, bot_manip);
}

View File

@ -2453,7 +2453,10 @@ build_function_call_real (function, params, require_complete, flags)
params, fndecl, 0);
if (coerced_params == error_mark_node)
return error_mark_node;
if (flags & LOOKUP_SPECULATIVELY)
return NULL_TREE;
else
return error_mark_node;
/* Check for errors in format strings. */
@ -2689,6 +2692,10 @@ convert_arguments (return_loc, typelist, values, fndecl, flags)
parmval = default_conversion (parmval);
#endif
}
if (parmval == error_mark_node)
return error_mark_node;
result = tree_cons (NULL_TREE, parmval, result);
}
else
@ -2736,7 +2743,7 @@ convert_arguments (return_loc, typelist, values, fndecl, flags)
for (; typetail != void_list_node; ++i)
{
tree type = TREE_VALUE (typetail);
tree val = TREE_PURPOSE (typetail);
tree val = break_out_target_exprs (TREE_PURPOSE (typetail));
tree parmval;
if (val == NULL_TREE)
@ -2763,6 +2770,9 @@ convert_arguments (return_loc, typelist, values, fndecl, flags)
#endif
}
if (parmval == error_mark_node)
return error_mark_node;
if (flag_gc
&& type_needs_gc_entry (TREE_TYPE (parmval))
&& ! value_safe_from_gc (NULL_TREE, parmval))
@ -6526,7 +6536,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
|| (coder == ENUMERAL_TYPE
&& (INTEGRAL_CODE_P (codel) || codel == REAL_TYPE)))
{
return cp_convert (type, rhs, CONV_IMPLICIT, 0);
return cp_convert (type, rhs, CONV_IMPLICIT, LOOKUP_NORMAL);
}
/* Conversions among pointers */
else if (codel == POINTER_TYPE
@ -6898,7 +6908,9 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
latter (X(X&)).
If using constructor make sure no conversion operator exists, if one does
exist, an ambiguity exists. */
exist, an ambiguity exists.
If flags doesn't include LOOKUP_COMPLAIN, don't complain about anything. */
tree
convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
tree exp, type, rhs;
@ -7069,7 +7081,7 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
return rhs;
}
return convert (type, rhs);
return cp_convert (type, rhs, CONV_OLD_CONVERT, flags);
}
if (type == TREE_TYPE (rhs))

View File

@ -537,8 +537,11 @@ store_init_value (decl, init)
if (TREE_CODE (type) == ERROR_MARK)
return NULL_TREE;
#if 0
/* This breaks arrays, and should not have any effect for other decls. */
/* Take care of C++ business up here. */
type = TYPE_MAIN_VARIANT (type);
#endif
if (IS_AGGR_TYPE (type))
{