diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b98842ee34d..52625db3836 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2009-08-17 Richard Guenther + + * decl.c (build_ptrmemfunc_type): Keep variant chain intact. + Avoid useless copy. + (finish_enum): Keep variant chain intact. + * tree.c (cp_build_reference_type): Likewise. + 2009-08-16 Jason Merrill Make TREE_USED match the [basic.def.odr] concept for FUNCTION_DECL diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 898542f1619..0746b828e7e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7056,10 +7056,14 @@ build_ptrmemfunc_type (tree type) /* If this is not the unqualified form of this pointer-to-member type, set the TYPE_MAIN_VARIANT for this type to be the unqualified type. Since they are actually RECORD_TYPEs that are - not variants of each other, we must do this manually. */ + not variants of each other, we must do this manually. + As we just built a new type there is no need to do yet another copy. */ if (cp_type_quals (type) != TYPE_UNQUALIFIED) { - t = build_qualified_type (t, cp_type_quals (type)); + int type_quals = cp_type_quals (type); + TYPE_READONLY (t) = (type_quals & TYPE_QUAL_CONST) != 0; + TYPE_VOLATILE (t) = (type_quals & TYPE_QUAL_VOLATILE) != 0; + TYPE_RESTRICT (t) = (type_quals & TYPE_QUAL_RESTRICT) != 0; TYPE_MAIN_VARIANT (t) = unqualified_variant; TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (unqualified_variant); TYPE_NEXT_VARIANT (unqualified_variant) = t; @@ -11164,7 +11168,8 @@ finish_enum (tree enumtype) /* Set the underlying type of the enumeration type to the computed enumeration type, restricted to the enumerator values. */ - ENUM_UNDERLYING_TYPE (enumtype) = copy_node (underlying_type); + ENUM_UNDERLYING_TYPE (enumtype) + = build_distinct_type_copy (underlying_type); set_min_and_max_values_for_integral_type (ENUM_UNDERLYING_TYPE (enumtype), precision, unsignedp); } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9e194fca444..1a406a30690 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -700,12 +700,11 @@ cp_build_reference_type (tree to_type, bool rval) if (TYPE_REF_IS_RVALUE (t)) return t; - t = copy_node (lvalue_ref); + t = build_distinct_type_copy (lvalue_ref); TYPE_REF_IS_RVALUE (t) = true; TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (lvalue_ref); TYPE_NEXT_REF_TO (lvalue_ref) = t; - TYPE_MAIN_VARIANT (t) = t; if (TYPE_STRUCTURAL_EQUALITY_P (to_type)) SET_TYPE_STRUCTURAL_EQUALITY (t);