]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (build_ptrmemfunc_type): Keep variant chain intact.
authorRichard Guenther <rguenther@suse.de>
Mon, 17 Aug 2009 11:03:59 +0000 (11:03 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 17 Aug 2009 11:03:59 +0000 (11:03 +0000)
2009-08-16  Richard Guenther  <rguenther@suse.de>

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

From-SVN: r150839

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/tree.c

index b98842ee34d35768ab39e5634ecc4302a183ba12..52625db383670640074fd29f21be7202e170162e 100644 (file)
@@ -1,3 +1,10 @@
+2009-08-17  Richard Guenther  <rguenther@suse.de>
+
+       * 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  <jason@redhat.com>
 
        Make TREE_USED match the [basic.def.odr] concept for FUNCTION_DECL
index 898542f16194081b89dd9b8636d865d2dc359fbd..0746b828e7e70a0cd2318f20687bd9cd15f3e1b4 100644 (file)
@@ -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);
     }
index 9e194fca44402faa0541a8909ea47aedb35c01ba..1a406a306904cc2bfc8022983ca7f3324d63208e 100644 (file)
@@ -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);