Commit 9edc3913 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (same_type_ignoring_top_level_qualifiers_p): New macro.

	* 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.

From-SVN: r33571
parent 52e45a60
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.
2000-04-30 Scott Snyder <snyder@fnal.gov> 2000-04-30 Scott Snyder <snyder@fnal.gov>
* decl.c (finish_destructor_body): Use the base destructor when * decl.c (finish_destructor_body): Use the base destructor when
......
...@@ -712,8 +712,8 @@ standard_conversion (to, from, expr) ...@@ -712,8 +712,8 @@ standard_conversion (to, from, expr)
enum tree_code ufcode = TREE_CODE (TREE_TYPE (from)); enum tree_code ufcode = TREE_CODE (TREE_TYPE (from));
enum tree_code utcode = TREE_CODE (TREE_TYPE (to)); enum tree_code utcode = TREE_CODE (TREE_TYPE (to));
if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (from)), if (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (from),
TYPE_MAIN_VARIANT (TREE_TYPE (to)))) TREE_TYPE (to)))
; ;
else if (utcode == VOID_TYPE && ufcode != OFFSET_TYPE else if (utcode == VOID_TYPE && ufcode != OFFSET_TYPE
&& ufcode != FUNCTION_TYPE) && ufcode != FUNCTION_TYPE)
...@@ -729,9 +729,9 @@ standard_conversion (to, from, expr) ...@@ -729,9 +729,9 @@ standard_conversion (to, from, expr)
tree tbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (to)); tree tbase = TYPE_OFFSET_BASETYPE (TREE_TYPE (to));
if (DERIVED_FROM_P (fbase, tbase) if (DERIVED_FROM_P (fbase, tbase)
&& (same_type_p && (same_type_ignoring_top_level_qualifiers_p
(TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (from))), (TREE_TYPE (TREE_TYPE (from)),
TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (to)))))) TREE_TYPE (TREE_TYPE (to)))))
{ {
from = build_offset_type (tbase, TREE_TYPE (TREE_TYPE (from))); from = build_offset_type (tbase, TREE_TYPE (TREE_TYPE (from)));
from = build_pointer_type (from); from = build_pointer_type (from);
...@@ -1007,8 +1007,7 @@ direct_reference_binding (type, conv) ...@@ -1007,8 +1007,7 @@ direct_reference_binding (type, conv)
either an identity conversion or, if the conversion function either an identity conversion or, if the conversion function
returns an entity of a type that is a derived class of the returns an entity of a type that is a derived class of the
parameter type, a derived-to-base conversion. */ parameter type, a derived-to-base conversion. */
if (!same_type_p (TYPE_MAIN_VARIANT (t), if (!same_type_ignoring_top_level_qualifiers_p (t, TREE_TYPE (conv)))
TYPE_MAIN_VARIANT (TREE_TYPE (conv))))
{ {
/* Represent the derived-to-base conversion. */ /* Represent the derived-to-base conversion. */
conv = build_conv (BASE_CONV, t, conv); conv = build_conv (BASE_CONV, t, conv);
...@@ -4076,8 +4075,8 @@ build_over_call (cand, args, flags) ...@@ -4076,8 +4075,8 @@ build_over_call (cand, args, flags)
if (TREE_CODE (targ) == ADDR_EXPR) if (TREE_CODE (targ) == ADDR_EXPR)
{ {
targ = TREE_OPERAND (targ, 0); targ = TREE_OPERAND (targ, 0);
if (!same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (arg))), if (!same_type_ignoring_top_level_qualifiers_p
TYPE_MAIN_VARIANT (TREE_TYPE (targ)))) (TREE_TYPE (TREE_TYPE (arg)), TREE_TYPE (targ)))
targ = NULL_TREE; targ = NULL_TREE;
} }
else else
...@@ -4480,8 +4479,7 @@ is_properly_derived_from (derived, base) ...@@ -4480,8 +4479,7 @@ is_properly_derived_from (derived, base)
/* We only allow proper derivation here. The DERIVED_FROM_P macro /* We only allow proper derivation here. The DERIVED_FROM_P macro
considers every class derived from itself. */ considers every class derived from itself. */
return (!same_type_p (TYPE_MAIN_VARIANT (derived), return (!same_type_ignoring_top_level_qualifiers_p (derived, base)
TYPE_MAIN_VARIANT (base))
&& DERIVED_FROM_P (base, derived)); && DERIVED_FROM_P (base, derived));
} }
...@@ -4870,8 +4868,7 @@ compare_ics (ics1, ics2) ...@@ -4870,8 +4868,7 @@ compare_ics (ics1, ics2)
which the reference initialized by S1 refers */ which the reference initialized by S1 refers */
if (ref_binding1 && ref_binding2 if (ref_binding1 && ref_binding2
&& same_type_p (TYPE_MAIN_VARIANT (to_type1), && same_type_ignoring_top_level_qualifiers_p (to_type1, to_type2))
TYPE_MAIN_VARIANT (to_type2)))
return comp_cv_qualification (target_type2, target_type1); return comp_cv_qualification (target_type2, target_type1);
/* Neither conversion sequence is better than the other. */ /* Neither conversion sequence is better than the other. */
......
...@@ -5215,7 +5215,7 @@ resolves_to_fixed_type_p (instance, nonnull) ...@@ -5215,7 +5215,7 @@ resolves_to_fixed_type_p (instance, nonnull)
return 0; return 0;
if (POINTER_TYPE_P (t)) if (POINTER_TYPE_P (t))
t = TREE_TYPE (t); t = TREE_TYPE (t);
return same_type_p (TYPE_MAIN_VARIANT (t), TYPE_MAIN_VARIANT (fixed)); return same_type_ignoring_top_level_qualifiers_p (t, fixed);
} }
......
...@@ -3670,6 +3670,11 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG }; ...@@ -3670,6 +3670,11 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
#define same_type_p(type1, type2) \ #define same_type_p(type1, type2) \
comptypes ((type1), (type2), COMPARE_STRICT) 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 /* 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 is derived from TYPE1, or if TYPE2 is a pointer (reference) to a
class derived from the type pointed to (referred to) by TYPE1. */ class derived from the type pointed to (referred to) by TYPE1. */
......
...@@ -490,9 +490,10 @@ declare_return_variable (id, use_stmt) ...@@ -490,9 +490,10 @@ declare_return_variable (id, use_stmt)
my_friendly_assert (id->target_exprs->elements_used != 0, my_friendly_assert (id->target_exprs->elements_used != 0,
20000430); 20000430);
var = TREE_OPERAND (VARRAY_TOP_TREE (id->target_exprs), 0); var = TREE_OPERAND (VARRAY_TOP_TREE (id->target_exprs), 0);
my_friendly_assert (same_type_p (TREE_TYPE (var), my_friendly_assert
TREE_TYPE (result)), (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (var),
20000430); TREE_TYPE (result)),
20000430);
} }
/* Otherwise, make an appropriate copy. */ /* Otherwise, make an appropriate copy. */
else else
......
...@@ -749,8 +749,7 @@ is_specialization_of (decl, tmpl) ...@@ -749,8 +749,7 @@ is_specialization_of (decl, tmpl)
t != NULL_TREE; t != NULL_TREE;
t = CLASSTYPE_USE_TEMPLATE (t) t = CLASSTYPE_USE_TEMPLATE (t)
? TREE_TYPE (CLASSTYPE_TI_TEMPLATE (t)) : NULL_TREE) ? TREE_TYPE (CLASSTYPE_TI_TEMPLATE (t)) : NULL_TREE)
if (same_type_p (TYPE_MAIN_VARIANT (t), if (same_type_ignoring_top_level_qualifiers_p (t, TREE_TYPE (tmpl)))
TYPE_MAIN_VARIANT (TREE_TYPE (tmpl))))
return 1; return 1;
} }
...@@ -8528,11 +8527,9 @@ unify (tparms, targs, parm, arg, strict) ...@@ -8528,11 +8527,9 @@ unify (tparms, targs, parm, arg, strict)
TYPE_MAX_VALUE (arg), UNIFY_ALLOW_INTEGER)) TYPE_MAX_VALUE (arg), UNIFY_ALLOW_INTEGER))
return 1; return 1;
} }
/* We use the TYPE_MAIN_VARIANT since we have already /* We have already checked cv-qualification at the top of the
checked cv-qualification at the top of the
function. */ function. */
else if (!same_type_p (TYPE_MAIN_VARIANT (arg), else if (!same_type_ignoring_top_level_qualifiers_p (arg, parm))
TYPE_MAIN_VARIANT (parm)))
return 1; return 1;
/* As far as unification is concerned, this wins. Later checks /* As far as unification is concerned, this wins. Later checks
...@@ -8621,8 +8618,7 @@ unify (tparms, targs, parm, arg, strict) ...@@ -8621,8 +8618,7 @@ unify (tparms, targs, parm, arg, strict)
return unify (tparms, targs, CLASSTYPE_TI_ARGS (parm), return unify (tparms, targs, CLASSTYPE_TI_ARGS (parm),
CLASSTYPE_TI_ARGS (t), UNIFY_ALLOW_NONE); CLASSTYPE_TI_ARGS (t), UNIFY_ALLOW_NONE);
} }
else if (!same_type_p (TYPE_MAIN_VARIANT (parm), else if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
TYPE_MAIN_VARIANT (arg)))
return 1; return 1;
return 0; return 0;
......
...@@ -1516,8 +1516,8 @@ comp_target_parms (parms1, parms2, strict) ...@@ -1516,8 +1516,8 @@ comp_target_parms (parms1, parms2, strict)
continue; continue;
} }
if (IS_AGGR_TYPE (TREE_TYPE (p1)) if (IS_AGGR_TYPE (TREE_TYPE (p1))
&& !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (p1)), && !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (p1),
TYPE_MAIN_VARIANT (TREE_TYPE (p2)))) TREE_TYPE (p2)))
return 0; return 0;
} }
/* Note backwards order due to contravariance. */ /* Note backwards order due to contravariance. */
...@@ -5178,8 +5178,9 @@ build_static_cast (type, expr) ...@@ -5178,8 +5178,9 @@ build_static_cast (type, expr)
} }
else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype)) else if (TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
{ {
if (same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (type))), if (same_type_ignoring_top_level_qualifiers_p
TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (intype)))) (TREE_TYPE (TREE_TYPE (type)),
TREE_TYPE (TREE_TYPE (intype)))
&& (binfo = get_binfo (TYPE_OFFSET_BASETYPE (TREE_TYPE (type)), && (binfo = get_binfo (TYPE_OFFSET_BASETYPE (TREE_TYPE (type)),
TYPE_OFFSET_BASETYPE (TREE_TYPE (intype)), 0)) TYPE_OFFSET_BASETYPE (TREE_TYPE (intype)), 0))
&& ! TREE_VIA_VIRTUAL (binfo)) && ! TREE_VIA_VIRTUAL (binfo))
...@@ -5255,8 +5256,7 @@ build_reinterpret_cast (type, expr) ...@@ -5255,8 +5256,7 @@ build_reinterpret_cast (type, expr)
expr = build_indirect_ref (expr, 0); expr = build_indirect_ref (expr, 0);
return expr; return expr;
} }
else if (same_type_p (TYPE_MAIN_VARIANT (intype), else if (same_type_ignoring_top_level_qualifiers_p (intype, type))
TYPE_MAIN_VARIANT (type)))
return build_static_cast (type, expr); return build_static_cast (type, expr);
if (TYPE_PTR_P (type) && (TREE_CODE (intype) == INTEGER_TYPE if (TYPE_PTR_P (type) && (TREE_CODE (intype) == INTEGER_TYPE
...@@ -5339,8 +5339,8 @@ build_const_cast (type, expr) ...@@ -5339,8 +5339,8 @@ build_const_cast (type, expr)
} }
intype = TREE_TYPE (expr); intype = TREE_TYPE (expr);
if (same_type_p (TYPE_MAIN_VARIANT (intype), TYPE_MAIN_VARIANT (type))) if (same_type_ignoring_top_level_qualifiers_p (intype, type))
return build_static_cast (type, expr); return build_static_cast (type, expr);
else if (TREE_CODE (type) == REFERENCE_TYPE) else if (TREE_CODE (type) == REFERENCE_TYPE)
{ {
...@@ -6979,7 +6979,7 @@ comp_ptr_ttypes_real (to, from, constp) ...@@ -6979,7 +6979,7 @@ comp_ptr_ttypes_real (to, from, constp)
if (TREE_CODE (to) != POINTER_TYPE) if (TREE_CODE (to) != POINTER_TYPE)
return return
same_type_p (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from)) same_type_ignoring_top_level_qualifiers_p (to, from)
&& (constp >= 0 || to_more_cv_qualified); && (constp >= 0 || to_more_cv_qualified);
} }
} }
...@@ -7037,8 +7037,7 @@ comp_ptr_ttypes_const (to, from) ...@@ -7037,8 +7037,7 @@ comp_ptr_ttypes_const (to, from)
continue; continue;
if (TREE_CODE (to) != POINTER_TYPE) if (TREE_CODE (to) != POINTER_TYPE)
return same_type_p (TYPE_MAIN_VARIANT (to), return same_type_ignoring_top_level_qualifiers_p (to, from);
TYPE_MAIN_VARIANT (from));
} }
} }
......
...@@ -765,8 +765,8 @@ process_init_constructor (type, init, elts) ...@@ -765,8 +765,8 @@ process_init_constructor (type, init, elts)
if (next1 == error_mark_node) if (next1 == error_mark_node)
return next1; return next1;
my_friendly_assert my_friendly_assert
(same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type)), (same_type_ignoring_top_level_qualifiers_p
TYPE_MAIN_VARIANT (TREE_TYPE (next1))), (TREE_TYPE (type), TREE_TYPE (next1)),
981123); 981123);
my_friendly_assert (tail1 == 0 my_friendly_assert (tail1 == 0
|| TREE_CODE (tail1) == TREE_LIST, 319); || TREE_CODE (tail1) == TREE_LIST, 319);
......
// 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 ();
}
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