diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-05-01 16:51:17 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-05-01 16:51:17 +0000 |
commit | 9edc3913428500c76054bf79f6253e219e95691b (patch) | |
tree | c437d2c343b5450b9585cb769c2373d98349172b /gcc | |
parent | 52e45a606ddb000436509eacf8039bb69860714f (diff) | |
download | gcc-9edc3913428500c76054bf79f6253e219e95691b.zip gcc-9edc3913428500c76054bf79f6253e219e95691b.tar.gz gcc-9edc3913428500c76054bf79f6253e219e95691b.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 21 | ||||
-rw-r--r-- | gcc/cp/call.c | 23 | ||||
-rw-r--r-- | gcc/cp/class.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 5 | ||||
-rw-r--r-- | gcc/cp/optimize.c | 7 | ||||
-rw-r--r-- | gcc/cp/pt.c | 12 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 21 | ||||
-rw-r--r-- | gcc/cp/typeck2.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.old-deja/g++.other/inline10.C | 18 |
9 files changed, 75 insertions, 38 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index df7b07e..efbd8e5 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,24 @@ +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 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 8cbdd30..05251bb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -712,8 +712,8 @@ standard_conversion (to, from, expr) 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) @@ -729,9 +729,9 @@ standard_conversion (to, from, expr) 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); @@ -1007,8 +1007,7 @@ direct_reference_binding (type, conv) 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); @@ -4076,8 +4075,8 @@ build_over_call (cand, args, flags) 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 @@ -4480,8 +4479,7 @@ is_properly_derived_from (derived, base) /* 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)); } @@ -4870,8 +4868,7 @@ compare_ics (ics1, ics2) 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. */ diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 5a95bc5..7198e54 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5215,7 +5215,7 @@ resolves_to_fixed_type_p (instance, nonnull) 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); } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index a36803e..0909d95 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3670,6 +3670,11 @@ enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG }; #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. */ diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c index a83b684..691969d 100644 --- a/gcc/cp/optimize.c +++ b/gcc/cp/optimize.c @@ -490,9 +490,10 @@ declare_return_variable (id, use_stmt) 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 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 2379a2c..ee7f90d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -749,8 +749,7 @@ is_specialization_of (decl, tmpl) 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; } @@ -8528,11 +8527,9 @@ unify (tparms, targs, parm, arg, strict) 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 @@ -8621,8 +8618,7 @@ unify (tparms, targs, parm, arg, strict) 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; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 39b47a0..12bfb99 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1516,8 +1516,8 @@ comp_target_parms (parms1, parms2, strict) 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. */ @@ -5178,8 +5178,9 @@ build_static_cast (type, expr) } 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)) @@ -5255,8 +5256,7 @@ build_reinterpret_cast (type, expr) 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 @@ -5339,8 +5339,8 @@ build_const_cast (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); else if (TREE_CODE (type) == REFERENCE_TYPE) { @@ -6979,7 +6979,7 @@ comp_ptr_ttypes_real (to, from, constp) 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); } } @@ -7037,8 +7037,7 @@ comp_ptr_ttypes_const (to, from) 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); } } diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index bcbe7ca..e6f3ef2 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -765,8 +765,8 @@ process_init_constructor (type, init, elts) 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); diff --git a/gcc/testsuite/g++.old-deja/g++.other/inline10.C b/gcc/testsuite/g++.old-deja/g++.other/inline10.C new file mode 100644 index 0000000..5bfdbae --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/inline10.C @@ -0,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 (); +} |