Commit 71851aaa by Mike Stump

61st Cygnus<->FSF merge

From-SVN: r9244
parent 3a011f48
...@@ -5,8 +5,50 @@ Mon Mar 27 07:14:33 1995 Warner Losh <imp@village.org> ...@@ -5,8 +5,50 @@ Mon Mar 27 07:14:33 1995 Warner Losh <imp@village.org>
declare sys_errlist and sys_nerr. declare sys_errlist and sys_nerr.
(my_strerror): New function. (my_strerror): New function.
Tue Mar 28 14:16:35 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* search.c (get_binfo): Don't try to be so clever.
* tree.c (copy_to_permanent): Also suspend_momentary().
* cvt.c (cp_convert_to_pointer): Hand off to convert_fn_pointer even
if the types are the same.
* decl.c (start_function): Handle extern inlines more like C++ says
we should.
* init.c (build_member_call): Hand constructor calls off to
build_functional_cast.
* typeck2.c (build_functional_cast): Use DECL_NESTED_TYPENAME to get
the name of the type.
Tue Mar 28 13:13:56 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
* decl.c (grokdeclarator): Check for the decl returned by
grokfndecl to be null before using build_decl_attribute_variant.
Mon Mar 27 18:04:41 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
* init.c (build_new): Use build_pointer_type instead of
TYPE_POINTER_TO.
Fri Mar 24 12:11:24 1995 Jason Merrill <jason@phydeaux.cygnus.com> Fri Mar 24 12:11:24 1995 Jason Merrill <jason@phydeaux.cygnus.com>
* typeck.c (build_conditional_expr): Handle pmfs.
(convert_for_assignment): Fix pmf support.
* cvt.c (convert_fn_ptr): Support !flag_vtable_thunks.
(cp_convert_to_pointer): Handle pmfs.
(cp_convert): Pass pmfs to cp_convert_to_pointer.
* typeck.c (common_type): Handle inheritance for pmfs.
* typeck2.c (build_m_component_ref): Do access control.
* typeck.c (comp_target_types): Check for conversion to void *
before checking trickier conversions.
* decl.c (duplicate_decls): Propagate DECL_ABSTRACT_VIRTUAL_P. * decl.c (duplicate_decls): Propagate DECL_ABSTRACT_VIRTUAL_P.
* pt.c (push_tinst_level): Complain if template instantiation depth * pt.c (push_tinst_level): Complain if template instantiation depth
......
...@@ -81,23 +81,29 @@ static tree ...@@ -81,23 +81,29 @@ static tree
convert_fn_ptr (type, expr) convert_fn_ptr (type, expr)
tree type, expr; tree type, expr;
{ {
tree binfo = get_binfo (TYPE_METHOD_BASETYPE (TREE_TYPE (TREE_TYPE (expr))), if (flag_vtable_thunks)
TYPE_METHOD_BASETYPE (TREE_TYPE (type)),
1);
if (binfo == error_mark_node)
{ {
error (" in pointer to member conversion"); tree intype = TREE_TYPE (expr);
return error_mark_node; tree binfo = get_binfo (TYPE_METHOD_BASETYPE (TREE_TYPE (intype)),
} TYPE_METHOD_BASETYPE (TREE_TYPE (type)), 1);
if (binfo == NULL_TREE) if (binfo == error_mark_node)
{ {
/* ARM 4.8 restriction. */ error (" in pointer to member conversion");
error ("invalid pointer to member conversion"); return error_mark_node;
return error_mark_node; }
if (binfo == NULL_TREE)
{
/* ARM 4.8 restriction. */
error ("invalid pointer to member conversion");
return error_mark_node;
}
if (BINFO_OFFSET_ZEROP (binfo))
return build1 (NOP_EXPR, type, expr);
return build1 (NOP_EXPR, type, build_thunk (BINFO_OFFSET (binfo), expr));
} }
if (BINFO_OFFSET_ZEROP (binfo)) else
return build1 (NOP_EXPR, type, expr); return build_ptrmemfunc (type, expr, 1);
return build1 (NOP_EXPR, type, build_thunk (BINFO_OFFSET (binfo), expr));
} }
/* if converting pointer to pointer /* if converting pointer to pointer
...@@ -111,8 +117,15 @@ cp_convert_to_pointer (type, expr) ...@@ -111,8 +117,15 @@ cp_convert_to_pointer (type, expr)
tree type, expr; tree type, expr;
{ {
register tree intype = TREE_TYPE (expr); register tree intype = TREE_TYPE (expr);
register enum tree_code form = TREE_CODE (intype); register enum tree_code form;
if (TYPE_PTRMEMFUNC_P (type))
type = TYPE_PTRMEMFUNC_FN_TYPE (type);
if (TYPE_PTRMEMFUNC_P (intype))
intype = TYPE_PTRMEMFUNC_FN_TYPE (intype);
form = TREE_CODE (intype);
if (form == POINTER_TYPE || form == REFERENCE_TYPE) if (form == POINTER_TYPE || form == REFERENCE_TYPE)
{ {
intype = TYPE_MAIN_VARIANT (intype); intype = TYPE_MAIN_VARIANT (intype);
...@@ -149,10 +162,9 @@ cp_convert_to_pointer (type, expr) ...@@ -149,10 +162,9 @@ cp_convert_to_pointer (type, expr)
} }
} }
} }
if (TYPE_MAIN_VARIANT (type) != intype if (TREE_CODE (TREE_TYPE (intype)) == METHOD_TYPE
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
&& TREE_CODE (type) == POINTER_TYPE && TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (intype)) == METHOD_TYPE) && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
return convert_fn_ptr (type, expr); return convert_fn_ptr (type, expr);
if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE
...@@ -1279,7 +1291,8 @@ cp_convert (type, expr, convtype, flags) ...@@ -1279,7 +1291,8 @@ cp_convert (type, expr, convtype, flags)
return truthvalue_conversion (e); return truthvalue_conversion (e);
return fold (convert_to_integer (type, e)); return fold (convert_to_integer (type, e));
} }
if (code == POINTER_TYPE || code == REFERENCE_TYPE) if (code == POINTER_TYPE || code == REFERENCE_TYPE
|| TYPE_PTRMEMFUNC_P (type))
return fold (cp_convert_to_pointer (type, e)); return fold (cp_convert_to_pointer (type, e));
if (code == REAL_TYPE) if (code == REAL_TYPE)
{ {
......
...@@ -9071,9 +9071,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises) ...@@ -9071,9 +9071,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
decl = grokfndecl (ctype, type, declarator, decl = grokfndecl (ctype, type, declarator,
virtualp, flags, quals, virtualp, flags, quals,
raises, friendp ? -1 : 0, publicp); raises, friendp ? -1 : 0, publicp);
decl = build_decl_attribute_variant (decl, decl_machine_attr);
if (decl == NULL_TREE) if (decl == NULL_TREE)
return NULL_TREE; return NULL_TREE;
decl = build_decl_attribute_variant (decl, decl_machine_attr);
if (explicitp == 2) if (explicitp == 2)
DECL_NONCONVERTING_P (decl) = 1; DECL_NONCONVERTING_P (decl) = 1;
...@@ -10904,13 +10904,6 @@ start_function (declspecs, declarator, raises, pre_parsed_p) ...@@ -10904,13 +10904,6 @@ start_function (declspecs, declarator, raises, pre_parsed_p)
DECL_EXTERNAL (decl1) = current_extern_inline; DECL_EXTERNAL (decl1) = current_extern_inline;
DECL_INTERFACE_KNOWN (decl1) = 1; DECL_INTERFACE_KNOWN (decl1) = 1;
} }
else if (current_extern_inline)
{
/* `extern inline' acts like a declaration except for
defining how to inline. So set DECL_EXTERNAL in that case. */
DECL_EXTERNAL (decl1) = 1;
DECL_INTERFACE_KNOWN (decl1) = 1;
}
else else
{ {
/* This is a definition, not a reference. /* This is a definition, not a reference.
...@@ -10918,7 +10911,8 @@ start_function (declspecs, declarator, raises, pre_parsed_p) ...@@ -10918,7 +10911,8 @@ start_function (declspecs, declarator, raises, pre_parsed_p)
DECL_EXTERNAL (decl1) = 0; DECL_EXTERNAL (decl1) = 0;
if (DECL_INLINE (decl1) && (DECL_FUNCTION_MEMBER_P (decl1) if (DECL_INLINE (decl1) && (DECL_FUNCTION_MEMBER_P (decl1)
|| DECL_TEMPLATE_INSTANTIATION (decl1))) || DECL_TEMPLATE_INSTANTIATION (decl1)
|| current_extern_inline))
/* We know nothing yet */; /* We know nothing yet */;
else else
{ {
......
...@@ -1785,6 +1785,9 @@ build_member_call (cname, name, parmlist) ...@@ -1785,6 +1785,9 @@ build_member_call (cname, name, parmlist)
decl = build_indirect_ref (decl, NULL_PTR); decl = build_indirect_ref (decl, NULL_PTR);
if (method_name == constructor_name (type)
|| method_name == constructor_name_full (type))
return build_functional_cast (type, parmlist);
if (t = lookup_fnfields (basetype_path, method_name, 0)) if (t = lookup_fnfields (basetype_path, method_name, 0))
return build_method_call (decl, method_name, parmlist, basetype_path, return build_method_call (decl, method_name, parmlist, basetype_path,
LOOKUP_NORMAL|LOOKUP_NONVIRTUAL); LOOKUP_NORMAL|LOOKUP_NONVIRTUAL);
...@@ -2999,7 +3002,7 @@ build_new (placement, decl, init, use_global_new) ...@@ -2999,7 +3002,7 @@ build_new (placement, decl, init, use_global_new)
{ {
rval = build_opfncall (code, LOOKUP_GLOBAL|LOOKUP_COMPLAIN, rval = build_opfncall (code, LOOKUP_GLOBAL|LOOKUP_COMPLAIN,
ptr_type_node, size, placement); ptr_type_node, size, placement);
rval = convert (TYPE_POINTER_TO (true_type), rval); rval = convert (build_pointer_type (true_type), rval);
} }
else if (! has_array && flag_this_is_variable > 0 else if (! has_array && flag_this_is_variable > 0
&& TYPE_NEEDS_CONSTRUCTING (true_type) && init != void_type_node) && TYPE_NEEDS_CONSTRUCTING (true_type) && init != void_type_node)
......
...@@ -427,18 +427,13 @@ get_binfo (parent, binfo, protect) ...@@ -427,18 +427,13 @@ get_binfo (parent, binfo, protect)
if (TREE_CODE (parent) == TREE_VEC) if (TREE_CODE (parent) == TREE_VEC)
parent = BINFO_TYPE (parent); parent = BINFO_TYPE (parent);
/* unions cannot participate in inheritance relationships */ else if (! IS_AGGR_TYPE_CODE (TREE_CODE (parent)))
else if (TREE_CODE (parent) == UNION_TYPE)
return NULL_TREE;
else if (TREE_CODE (parent) != RECORD_TYPE)
my_friendly_abort (89); my_friendly_abort (89);
if (TREE_CODE (binfo) == TREE_VEC) if (TREE_CODE (binfo) == TREE_VEC)
type = BINFO_TYPE (binfo); type = BINFO_TYPE (binfo);
else if (TREE_CODE (binfo) == RECORD_TYPE) else if (IS_AGGR_TYPE_CODE (TREE_CODE (binfo)))
type = binfo; type = binfo;
else if (TREE_CODE (binfo) == UNION_TYPE)
return NULL_TREE;
else else
my_friendly_abort (90); my_friendly_abort (90);
......
...@@ -1782,15 +1782,18 @@ copy_to_permanent (t) ...@@ -1782,15 +1782,18 @@ copy_to_permanent (t)
{ {
register struct obstack *ambient_obstack = current_obstack; register struct obstack *ambient_obstack = current_obstack;
register struct obstack *ambient_saveable_obstack = saveable_obstack; register struct obstack *ambient_saveable_obstack = saveable_obstack;
int resume;
if (t == NULL_TREE || TREE_PERMANENT (t)) if (t == NULL_TREE || TREE_PERMANENT (t))
return t; return t;
saveable_obstack = &permanent_obstack; saveable_obstack = &permanent_obstack;
current_obstack = saveable_obstack; current_obstack = saveable_obstack;
resume = suspend_momentary ();
t = make_deep_copy (t); t = make_deep_copy (t);
resume_momentary (resume);
current_obstack = ambient_obstack; current_obstack = ambient_obstack;
saveable_obstack = ambient_saveable_obstack; saveable_obstack = ambient_saveable_obstack;
......
...@@ -389,7 +389,12 @@ common_type (t1, t2) ...@@ -389,7 +389,12 @@ common_type (t1, t2)
t1 = build_pointer_type (target); t1 = build_pointer_type (target);
else else
t1 = build_reference_type (target); t1 = build_reference_type (target);
return build_type_attribute_variant (t1, attributes); t1 = build_type_attribute_variant (t1, attributes);
if (TREE_CODE (target) == METHOD_TYPE)
t1 = build_ptrmemfunc_type (t1);
return t1;
} }
#if 0 #if 0
case POINTER_TYPE: case POINTER_TYPE:
...@@ -464,14 +469,25 @@ common_type (t1, t2) ...@@ -464,14 +469,25 @@ common_type (t1, t2)
compiler_error ("common_type called with uncommon aggregate types"); compiler_error ("common_type called with uncommon aggregate types");
case METHOD_TYPE: case METHOD_TYPE:
if (comptypes (TYPE_METHOD_BASETYPE (t1), TYPE_METHOD_BASETYPE (t2), 1) if (TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2)))
&& TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2)))
{ {
/* Get this value the long way, since TYPE_METHOD_BASETYPE /* Get this value the long way, since TYPE_METHOD_BASETYPE
is just the main variant of this. */ is just the main variant of this. */
tree basetype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t1))); tree basetype;
tree raises, t3; tree raises, t3;
tree b1 = TYPE_OFFSET_BASETYPE (t1);
tree b2 = TYPE_OFFSET_BASETYPE (t2);
if (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2))
basetype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t2)));
else
{
if (binfo_or_else (b2, b1) == NULL_TREE)
compiler_error ("common_type called with uncommon method types");
basetype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t1)));
}
raises = TYPE_RAISES_EXCEPTIONS (t1); raises = TYPE_RAISES_EXCEPTIONS (t1);
/* If this was a member function type, get back to the /* If this was a member function type, get back to the
...@@ -489,16 +505,15 @@ common_type (t1, t2) ...@@ -489,16 +505,15 @@ common_type (t1, t2)
return build_type_attribute_variant (t1, attributes); return build_type_attribute_variant (t1, attributes);
case OFFSET_TYPE: case OFFSET_TYPE:
if (TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2))) if (TREE_TYPE (t1) == TREE_TYPE (t2))
{ {
tree b1 = TYPE_OFFSET_BASETYPE (t1); tree b1 = TYPE_OFFSET_BASETYPE (t1);
tree b2 = TYPE_OFFSET_BASETYPE (t2); tree b2 = TYPE_OFFSET_BASETYPE (t2);
tree base;
if (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2)) if (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2))
return build_type_attribute_variant (t1, attributes);
else if (binfo_or_else (b2, b1))
return build_type_attribute_variant (t2, attributes); return build_type_attribute_variant (t2, attributes);
else if (binfo_or_else (b2, b1))
return build_type_attribute_variant (t1, attributes);
} }
compiler_error ("common_type called with uncommon member types"); compiler_error ("common_type called with uncommon member types");
...@@ -782,10 +797,7 @@ comp_target_types (ttl, ttr, nptrs) ...@@ -782,10 +797,7 @@ comp_target_types (ttl, ttr, nptrs)
if (nptrs > 0) if (nptrs > 0)
{ {
if (TREE_CODE (ttl) == POINTER_TYPE if (TREE_CODE (ttl) == VOID_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) != FUNCTION_TYPE
&& TREE_CODE (ttr) != METHOD_TYPE && TREE_CODE (ttr) != METHOD_TYPE
&& TREE_CODE (ttr) != OFFSET_TYPE) && TREE_CODE (ttr) != OFFSET_TYPE)
...@@ -795,6 +807,9 @@ comp_target_types (ttl, ttr, nptrs) ...@@ -795,6 +807,9 @@ comp_target_types (ttl, ttr, nptrs)
&& TREE_CODE (ttl) != METHOD_TYPE && TREE_CODE (ttl) != METHOD_TYPE
&& TREE_CODE (ttl) != OFFSET_TYPE) && TREE_CODE (ttl) != OFFSET_TYPE)
return -1; return -1;
else if (TREE_CODE (ttl) == POINTER_TYPE
|| TREE_CODE (ttl) == ARRAY_TYPE)
return comp_ptr_ttypes (ttl, ttr);
} }
return comp_target_types (ttl, ttr, nptrs - 1); return comp_target_types (ttl, ttr, nptrs - 1);
...@@ -4588,7 +4603,7 @@ build_conditional_expr (ifexp, op1, op2) ...@@ -4588,7 +4603,7 @@ build_conditional_expr (ifexp, op1, op2)
{ {
if (code2 == ENUMERAL_TYPE) if (code2 == ENUMERAL_TYPE)
{ {
message_2_types (error, "enumeral mismatch in conditional expression: `%s' vs `%s'", type1, type2); cp_error ("enumeral mismatch in conditional expression: `%T' vs `%T'", type1, type2);
return error_mark_node; return error_mark_node;
} }
else if (extra_warnings && ! IS_AGGR_TYPE_CODE (code2)) else if (extra_warnings && ! IS_AGGR_TYPE_CODE (code2))
...@@ -4602,12 +4617,16 @@ build_conditional_expr (ifexp, op1, op2) ...@@ -4602,12 +4617,16 @@ build_conditional_expr (ifexp, op1, op2)
{ {
op1 = default_conversion (op1); op1 = default_conversion (op1);
type1 = TREE_TYPE (op1); type1 = TREE_TYPE (op1);
if (TYPE_PTRMEMFUNC_P (type1))
type1 = TYPE_PTRMEMFUNC_FN_TYPE (type1);
code1 = TREE_CODE (type1); code1 = TREE_CODE (type1);
} }
if (code2 != VOID_TYPE) if (code2 != VOID_TYPE)
{ {
op2 = default_conversion (op2); op2 = default_conversion (op2);
type2 = TREE_TYPE (op2); type2 = TREE_TYPE (op2);
if (TYPE_PTRMEMFUNC_P (type2))
type2 = TYPE_PTRMEMFUNC_FN_TYPE (type2);
code2 = TREE_CODE (type2); code2 = TREE_CODE (type2);
} }
...@@ -4721,7 +4740,7 @@ build_conditional_expr (ifexp, op1, op2) ...@@ -4721,7 +4740,7 @@ build_conditional_expr (ifexp, op1, op2)
an aggregate value, try converting to a scalar type. */ an aggregate value, try converting to a scalar type. */
if (code1 == RECORD_TYPE && code2 == RECORD_TYPE) if (code1 == RECORD_TYPE && code2 == RECORD_TYPE)
{ {
message_2_types (error, "aggregate mismatch in conditional expression: `%s' vs `%s'", type1, type2); cp_error ("aggregate mismatch in conditional expression: `%T' vs `%T'", type1, type2);
return error_mark_node; return error_mark_node;
} }
if (code1 == RECORD_TYPE && TYPE_HAS_CONVERSION (type1)) if (code1 == RECORD_TYPE && TYPE_HAS_CONVERSION (type1))
...@@ -6765,8 +6784,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) ...@@ -6765,8 +6784,7 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
return convert (type, rhs); return convert (type, rhs);
/* C++ */ /* C++ */
else if (((coder == POINTER_TYPE && TREE_CODE (rhs) == ADDR_EXPR else if (((coder == POINTER_TYPE
&& TREE_CODE (rhstype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (rhstype)) == METHOD_TYPE) && TREE_CODE (TREE_TYPE (rhstype)) == METHOD_TYPE)
|| integer_zerop (rhs) || integer_zerop (rhs)
|| TYPE_PTRMEMFUNC_P (rhstype)) || TYPE_PTRMEMFUNC_P (rhstype))
......
...@@ -1392,6 +1392,7 @@ build_m_component_ref (datum, component) ...@@ -1392,6 +1392,7 @@ build_m_component_ref (datum, component)
tree type; tree type;
tree objtype = TREE_TYPE (datum); tree objtype = TREE_TYPE (datum);
tree rettype; tree rettype;
tree binfo;
if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component))) if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
{ {
...@@ -1424,13 +1425,16 @@ build_m_component_ref (datum, component) ...@@ -1424,13 +1425,16 @@ build_m_component_ref (datum, component)
cp_error ("which is of non-aggregate type `%T'", objtype); cp_error ("which is of non-aggregate type `%T'", objtype);
return error_mark_node; return error_mark_node;
} }
if (! comptypes (TYPE_METHOD_BASETYPE (type), objtype, 0)) binfo = get_binfo (TYPE_METHOD_BASETYPE (type), objtype, 1);
if (binfo == NULL_TREE)
{ {
cp_error ("member type `%T::' incompatible with object type `%T'", cp_error ("member type `%T::' incompatible with object type `%T'",
TYPE_METHOD_BASETYPE (type), objtype); TYPE_METHOD_BASETYPE (type), objtype);
return error_mark_node; return error_mark_node;
} }
else if (binfo == error_mark_node)
return error_mark_node;
return build (OFFSET_REF, rettype, datum, component); return build (OFFSET_REF, rettype, datum, component);
} }
...@@ -1491,7 +1495,7 @@ build_functional_cast (exp, parms) ...@@ -1491,7 +1495,7 @@ build_functional_cast (exp, parms)
{ {
name = TYPE_NAME (type); name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL) if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name); name = DECL_NESTED_TYPENAME (name);
} }
if (! IS_AGGR_TYPE (type)) if (! IS_AGGR_TYPE (type))
......
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