ICE 20000430
Mark Mitchell
mark@codesourcery.com
Mon May 1 09:52:00 GMT 2000
>>>>> "Martin" == Martin v Loewis <martin@loewis.home.cs.tu-berlin.de> writes:
Martin> Hi Mark,
Martin> Your new assertion 20000430 is triggered in libstdc++ v3,
Martin> on i586-pc-linux-gnu:
Thanks. Fixed thusly. Also introduced a new macro to compare types
ignoring their top-level qualifiers, since this is done a lot,
following the idea that the C++ front-end should use terminology used
in the C++ standard.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-05-01 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (same_type_ignoring_top_level_qualifiers_p): New
macro.
* call.c (standard_conversion): Use it.
(direct_reference_binding): Likewise.
(build_over_call): Likewise.
(is_properly_derived_from): Likewise.
(compare_ics): Likewise.
* class.c (resolves_to_fixed_type_p): Likewise.
* optimize.c (declare_return_variable): Likewise.
* pt.c (is_specialization_of): Likewise.
(unify): Likewise.
* typeck.c (comp_target_parms): Likeiwse.
(build_static_cast): Likewise.
(build_reinterpret_cast): Likewise.
(build_const_cast): Likewise.
(comp_ptr_ttypes_real): Likewise.
(comp_ptr_ttypes_const): Likewise.
* typeck2.c (process_init_constructor): Likewise.
Index: testsuite/g++.old-deja/g++.other/inline10.C
===================================================================
RCS file: inline10.C
diff -N inline10.C
*** /dev/null Tue May 5 13:32:27 1998
--- inline10.C Mon May 1 09:46:36 2000
***************
*** 0 ****
--- 1,18 ----
+ // Build don't link:
+ // Special g++ Options: -O2
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+
+ struct S
+ {
+ };
+
+ inline const S f ()
+ {
+ return S ();
+ }
+
+ void g ()
+ {
+ S s;
+ f ();
+ }
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/call.c,v
retrieving revision 1.213
diff -c -p -r1.213 call.c
*** call.c 2000/04/26 15:43:46 1.213
--- call.c 2000/05/01 16:46:39
*************** standard_conversion (to, from, expr)
*** 712,719 ****
enum tree_code ufcode = TREE_CODE (TREE_TYPE (from));
enum tree_code utcode = TREE_CODE (TREE_TYPE (to));
! if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (from)),
! TYPE_MAIN_VARIANT (TREE_TYPE (to))))
;
else if (utcode == VOID_TYPE && ufcode != OFFSET_TYPE
&& ufcode != FUNCTION_TYPE)
--- 712,719 ----
enum tree_code ufcode = TREE_CODE (TREE_TYPE (from));
enum tree_code utcode = TREE_CODE (TREE_TYPE (to));
! if (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (from),
! TREE_TYPE (to)))
;
else if (utcode == VOID_TYPE && ufcode != OFFSET_TYPE
&& ufcode != FUNCTION_TYPE)
*************** standard_conversion (to, from, expr)
*** 729,737 ****
tree tbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (to));
if (DERIVED_FROM_P (fbase, tbase)
! && (same_type_p
! (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (from))),
! TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (to))))))
{
from = build_offset_type (tbase, TREE_TYPE (TREE_TYPE (from)));
from = build_pointer_type (from);
--- 729,737 ----
tree tbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (to));
if (DERIVED_FROM_P (fbase, tbase)
! && (same_type_ignoring_top_level_qualifiers_p
! (TREE_TYPE (TREE_TYPE (from)),
! TREE_TYPE (TREE_TYPE (to)))))
{
from = build_offset_type (tbase, TREE_TYPE (TREE_TYPE (from)));
from = build_pointer_type (from);
*************** direct_reference_binding (type, conv)
*** 1007,1014 ****
either an identity conversion or, if the conversion function
returns an entity of a type that is a derived class of the
parameter type, a derived-to-base conversion. */
! if (!same_type_p (TYPE_MAIN_VARIANT (t),
! TYPE_MAIN_VARIANT (TREE_TYPE (conv))))
{
/* Represent the derived-to-base conversion. */
conv = build_conv (BASE_CONV, t, conv);
--- 1007,1013 ----
either an identity conversion or, if the conversion function
returns an entity of a type that is a derived class of the
parameter type, a derived-to-base conversion. */
! if (!same_type_ignoring_top_level_qualifiers_p (t, TREE_TYPE (conv)))
{
/* Represent the derived-to-base conversion. */
conv = build_conv (BASE_CONV, t, conv);
*************** build_over_call (cand, args, flags)
*** 4076,4083 ****
if (TREE_CODE (targ) == ADDR_EXPR)
{
targ = TREE_OPERAND (targ, 0);
! if (!same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (arg))),
! TYPE_MAIN_VARIANT (TREE_TYPE (targ))))
targ = NULL_TREE;
}
else
--- 4075,4082 ----
if (TREE_CODE (targ) == ADDR_EXPR)
{
targ = TREE_OPERAND (targ, 0);
! if (!same_type_ignoring_top_level_qualifiers_p
! (TREE_TYPE (TREE_TYPE (arg)), TREE_TYPE (targ)))
targ = NULL_TREE;
}
else
*************** is_properly_derived_from (derived, base)
*** 4480,4487 ****
/* We only allow proper derivation here. The DERIVED_FROM_P macro
considers every class derived from itself. */
! return (!same_type_p (TYPE_MAIN_VARIANT (derived),
! TYPE_MAIN_VARIANT (base))
&& DERIVED_FROM_P (base, derived));
}
--- 4479,4485 ----
/* We only allow proper derivation here. The DERIVED_FROM_P macro
considers every class derived from itself. */
! return (!same_type_ignoring_top_level_qualifiers_p (derived, base)
&& DERIVED_FROM_P (base, derived));
}
*************** compare_ics (ics1, ics2)
*** 4870,4877 ****
which the reference initialized by S1 refers */
if (ref_binding1 && ref_binding2
! && same_type_p (TYPE_MAIN_VARIANT (to_type1),
! TYPE_MAIN_VARIANT (to_type2)))
return comp_cv_qualification (target_type2, target_type1);
/* Neither conversion sequence is better than the other. */
--- 4868,4874 ----
which the reference initialized by S1 refers */
0
if (ref_binding1 && ref_binding2
! && same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))
return comp_cv_qualification (target_type2, target_type1);
/* Neither conversion sequence is better than the other. */
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/class.c,v
retrieving revision 1.296
diff -c -p -r1.296 class.c
*** class.c 2000/04/26 15:43:47 1.296
--- class.c 2000/05/01 16:46:43
*************** resolves_to_fixed_type_p (instance, nonn
*** 5215,5221 ****
return 0;
if (POINTER_TYPE_P (t))
t = TREE_TYPE (t);
! return same_type_p (TYPE_MAIN_VARIANT (t), TYPE_MAIN_VARIANT (fixed));
}
--- 5215,5221 ----
return 0;
if (POINTER_TYPE_P (t))
t = TREE_TYPE (t);
! return same_type_ignoring_top_level_qualifiers_p (t, fixed);
}
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.447
diff -c -p -r1.447 cp-tree.h
*** cp-tree.h 2000/04/26 15:43:47 1.447
--- cp-tree.h 2000/05/01 16:46:47
*************** enum overload_flags { NO_SPECIAL = 0, DT
*** 3670,3675 ****
--- 3670,3680 ----
#define same_type_p(type1, type2) \
comptypes ((type1), (type2), COMPARE_STRICT)
+ /* Returns nonzero iff TYPE1 and TYPE2 are the same type, ignoring
+ top-level qualifiers. */
+ #define same_type_ignoring_top_level_qualifiers_p(type1, type2) \
+ same_type_p (TYPE_MAIN_VARIANT (type1), TYPE_MAIN_VARIANT (type2))
+
/* Returns nonzero iff TYPE1 and TYPE2 are the same type, or if TYPE2
is derived from TYPE1, or if TYPE2 is a pointer (reference) to a
class derived from the type pointed to (referred to) by TYPE1. */
Index: cp/optimize.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/optimize.c,v
retrieving revision 1.30
diff -c -p -r1.30 optimize.c
*** optimize.c 2000/05/01 05:50:40 1.30
--- optimize.c 2000/05/01 16:46:47
*************** declare_return_variable (id, use_stmt)
*** 490,498 ****
my_friendly_assert (id->target_exprs->elements_used != 0,
20000430);
var = TREE_OPERAND (VARRAY_TOP_TREE (id->target_exprs), 0);
! my_friendly_assert (same_type_p (TREE_TYPE (var),
! TREE_TYPE (result)),
! 20000430);
}
/* Otherwise, make an appropriate copy. */
else
--- 490,499 ----
my_friendly_assert (id->target_exprs->elements_used != 0,
20000430);
var = TREE_OPERAND (VARRAY_TOP_TREE (id->target_exprs), 0);
! my_friendly_assert
! (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (var),
! TREE_TYPE (result)),
! 20000430);
}
/* Otherwise, make an appropriate copy. */
else
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/pt.c,v
retrieving revision 1.423
diff -c -p -r1.423 pt.c
*** pt.c 2000/04/26 15:43:49 1.423
--- pt.c 2000/05/01 16:46:53
*************** is_specialization_of (decl, tmpl)
*** 749,756 ****
t != NULL_TREE;
t = CLASSTYPE_USE_TEMPLATE (t)
? TREE_TYPE (CLASSTYPE_TI_TEMPLATE (t)) : NULL_TREE)
! if (same_type_p (TYPE_MAIN_VARIANT (t),
! TYPE_MAIN_VARIANT (TREE_TYPE (tmpl))))
return 1;
}
--- 749,755 ----
t != NULL_TREE;
t = CLASSTYPE_USE_TEMPLATE (t)
? TREE_TYPE (CLASSTYPE_TI_TEMPLATE (t)) : NULL_TREE)
! if (same_type_ignoring_top_level_qualifiers_p (t, TREE_TYPE (tmpl)))
return 1;
}
*************** unify (tparms, targs, parm, arg, strict)
*** 8528,8538 ****
TYPE_MAX_VALUE (arg), UNIFY_ALLOW_INTEGER))
return 1;
}
! /* We use the TYPE_MAIN_VARIANT since we have already
! checked cv-qualification at the top of the
function. */
! else if (!same_type_p (TYPE_MAIN_VARIANT (arg),
! TYPE_MAIN_VARIANT (parm)))
return 1;
/* As far as unification is concerned, this wins. Later checks
--- 8527,8535 ----
TYPE_MAX_VALUE (arg), UNIFY_ALLOW_INTEGER))
return 1;
}
! /* We have already checked cv-qualification at the top of the
function. */
! else if (!same_type_ignoring_top_level_qualifiers_p (arg, parm))
return 1;
/* As far as unification is concerned, this wins. Later checks
*************** unify (tparms, targs, parm, arg, strict)
*** 8621,8628 ****
return unify (tparms, targs, CLASSTYPE_TI_ARGS (parm),
CLASSTYPE_TI_ARGS (t), UNIFY_ALLOW_NONE);
}
! else if (!same_type_p (TYPE_MAIN_VARIANT (parm),
! TYPE_MAIN_VARIANT (arg)))
return 1;
return 0;
--- 8618,8624 ----
return unify (tparms, targs, CLASSTYPE_TI_ARGS (parm),
CLASSTYPE_TI_ARGS (t), UNIFY_ALLOW_NONE);
}
! else if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
return 1;
return 0;
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck.c,v
retrieving revision 1.281
diff -c -p -r1.281 typeck.c
*** typeck.c 2000/04/26 15:43:50 1.281
--- typeck.c 2000/05/01 16:46:57
*************** comp_target_parms (parms1, parms2, stric
*** 1516,1523 ****
continue;
}
if (IS_AGGR_TYPE (TREE_TYPE (p1))
! && !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (p1)),
! TYPE_MAIN_VARIANT (TREE_TYPE (p2))))
return 0;
}
/* Note backwards order due to contravariance. */
--- 1516,1523 ----
continue;
}
if (IS_AGGR_TYPE (TREE_TYPE (p1))
! && !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (p1),
! TREE_TYPE (p2)))
return 0;
}
/* Note backwards order due to contravariance. */
*************** build_static_cast (type, expr)
*** 5178,5185 ****
}
else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
{
! if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))),
! TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (intype))))
&& (binfo = get_binfo (TYPE_OFFSET_BASETYPE (TREE_TYPE (type)),
TYPE_OFFSET_BASETYPE (TREE_TYPE (intype)), 0))
&& ! TREE_VIA_VIRTUAL (binfo))
--- 5178,5186 ----
}
else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
{
! if (same_type_ignoring_top_level_qualifiers_p
! (TREE_TYPE (TREE_TYPE (type)),
! TREE_TYPE (TREE_TYPE (intype)))
&& (binfo = get_binfo (TYPE_OFFSET_BASETYPE (TREE_TYPE (type)),
TYPE_OFFSET_BASETYPE (TREE_TYPE (intype)), 0))
&& ! TREE_VIA_VIRTUAL (binfo))
*************** build_reinterpret_cast (type, expr)
*** 5255,5262 ****
expr = build_indirect_ref (expr, 0);
return expr;
}
! else if (same_type_p (TYPE_MAIN_VARIANT (intype),
! TYPE_MAIN_VARIANT (type)))
return build_static_cast (type, expr);
if (TYPE_PTR_P (type) && (TREE_CODE (intype) == INTEGER_TYPE
--- 5256,5262 ----
expr = build_indirect_ref (expr, 0);
return expr;
}
! else if (same_type_ignoring_top_level_qualifiers_p (intype, type))
return build_static_cast (type, expr);
if (TYPE_PTR_P (type) && (TREE_CODE (intype) == INTEGER_TYPE
*************** build_const_cast (type, expr)
*** 5339,5346 ****
}
intype = TREE_TYPE (expr);
!
! if (same_type_p (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type)))
return build_static_cast (type, expr);
else if (TREE_CODE (type) == REFERENCE_TYPE)
{
--- 5339,5346 ----
}
intype = TREE_TYPE (expr);
!
! if (same_type_ignoring_top_level_qualifiers_p (intype, type))
return build_static_cast (type, expr);
else if (TREE_CODE (type) == REFERENCE_TYPE)
{
*************** comp_ptr_ttypes_real (to, from, constp)
*** 6979,6985 ****
if (TREE_CODE (to) != POINTER_TYPE)
return
! same_type_p (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from))
&& (constp >= 0 || to_more_cv_qualified);
}
}
--- 6979,6985 ----
if (TREE_CODE (to) != POINTER_TYPE)
return
! same_type_ignoring_top_level_qualifiers_p (to, from)
&& (constp >= 0 || to_more_cv_qualified);
}
}
*************** comp_ptr_ttypes_const (to, from)
*** 7037,7044 ****
continue;
if (TREE_CODE (to) != POINTER_TYPE)
! return same_type_p (TYPE_MAIN_VARIANT (to),
! TYPE_MAIN_VARIANT (from));
}
}
--- 7037,7043 ----
continue;
if (TREE_CODE (to) != POINTER_TYPE)
! return same_type_ignoring_top_level_qualifiers_p (to, from);
}
}
Index: cp/typeck2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.82
diff -c -p -r1.82 typeck2.c
*** typeck2.c 2000/04/09 06:44:20 1.82
--- typeck2.c 2000/05/01 16:46:57
*************** process_init_constructor (type, init, el
*** 765,772 ****
if (next1 == error_mark_node)
return next1;
my_friendly_assert
! (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
! TYPE_MAIN_VARIANT (TREE_TYPE (next1))),
981123);
my_friendly_assert (tail1 == 0
|| TREE_CODE (tail1) == TREE_LIST, 319);
--- 765,772 ----
if (next1 == error_mark_node)
return next1;
my_friendly_assert
! (same_type_ignoring_top_level_qualifiers_p
! (TREE_TYPE (type), TREE_TYPE (next1)),
981123);
my_friendly_assert (tail1 == 0
|| TREE_CODE (tail1) == TREE_LIST, 319);
More information about the Gcc-bugs
mailing list