+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>
* decl.c (finish_destructor_body): Use the base destructor when
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))))
+ 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)
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))))))
+ && (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);
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))))
+ 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);
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))))
+ if (!same_type_ignoring_top_level_qualifiers_p
+ (TREE_TYPE (TREE_TYPE (arg)), TREE_TYPE (targ)))
targ = NULL_TREE;
}
else
/* 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))
+ return (!same_type_ignoring_top_level_qualifiers_p (derived, base)
&& DERIVED_FROM_P (base, derived));
}
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)))
+ && 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. */
return 0;
if (POINTER_TYPE_P (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);
}
\f
#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. */
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);
+ my_friendly_assert
+ (same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (var),
+ TREE_TYPE (result)),
+ 20000430);
}
/* Otherwise, make an appropriate copy. */
else
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))))
+ if (same_type_ignoring_top_level_qualifiers_p (t, TREE_TYPE (tmpl)))
return 1;
}
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
+ /* 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)))
+ else if (!same_type_ignoring_top_level_qualifiers_p (arg, parm))
return 1;
/* As far as unification is concerned, this wins. Later checks
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)))
+ else if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
return 1;
return 0;
continue;
}
if (IS_AGGR_TYPE (TREE_TYPE (p1))
- && !same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (p1)),
- TYPE_MAIN_VARIANT (TREE_TYPE (p2))))
+ && !same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (p1),
+ TREE_TYPE (p2)))
return 0;
}
/* Note backwards order due to contravariance. */
}
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))))
+ 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))
expr = build_indirect_ref (expr, 0);
return expr;
}
- else if (same_type_p (TYPE_MAIN_VARIANT (intype),
- TYPE_MAIN_VARIANT (type)))
+ 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
}
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);
else if (TREE_CODE (type) == REFERENCE_TYPE)
{
if (TREE_CODE (to) != POINTER_TYPE)
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);
}
}
continue;
if (TREE_CODE (to) != POINTER_TYPE)
- return same_type_p (TYPE_MAIN_VARIANT (to),
- TYPE_MAIN_VARIANT (from));
+ return same_type_ignoring_top_level_qualifiers_p (to, from);
}
}
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))),
+ (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);
--- /dev/null
+// 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 ();
+}