re PR c++/33194 (ICE: canonical types differ for identical types void ()(const char...
authorDouglas Gregor <doug.gregor@gmail.com>
Wed, 29 Aug 2007 12:25:01 +0000 (12:25 +0000)
committerDoug Gregor <dgregor@gcc.gnu.org>
Wed, 29 Aug 2007 12:25:01 +0000 (12:25 +0000)
2007-08-29  Douglas Gregor  <doug.gregor@gmail.com>

PR c++/33194
* tree.c (build_type_attribute_qual_variant): Set canonical types
on the final, unqualified attribute variant before building the
qualified version.

2007-08-29  Douglas Gregor  <doug.gregor@gmail.com>

PR c++/33194
* g++.dg/other/canon-33194.C: New.

From-SVN: r127896

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/other/canon-33194.C [new file with mode: 0644]
gcc/tree.c

index 6e32adea1c4e19cccc330c7efb17c6dd4f9b771b..5300252823f912071ea2595b9a1ddcc04aad9c7e 100644 (file)
@@ -1,3 +1,10 @@
+2007-08-29  Douglas Gregor  <doug.gregor@gmail.com>
+
+       PR c++/33194
+       * tree.c (build_type_attribute_qual_variant): Set canonical types
+       on the final, unqualified attribute variant before building the
+       qualified version.
+
 2007-08-29  Jie Zhang  <jie.zhang@analog.com>
 
        * config/bfin/bfin.c (bfin_expand_builtin): Fix the argument
index 213b073c9db056460b378f806a6db9e9d5535e8b..eb9c329684ac41a4a2fe331ad46ddee240ab0389 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-29  Douglas Gregor  <doug.gregor@gmail.com>
+
+       PR c++/33194
+       * g++.dg/other/canon-33194.C: New.
+
 2007-08-29  Rask Ingemann Lambertsen  <rask@sygehus.dk>
 
        * gcc.c-torture/execute/simd-1.c: Use SImode vector elements.
diff --git a/gcc/testsuite/g++.dg/other/canon-33194.C b/gcc/testsuite/g++.dg/other/canon-33194.C
new file mode 100644 (file)
index 0000000..496aafe
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/33194
+void c_translate_location (
+           void (*fail) (
+           const char *fmt, ...)
+           __attribute__ ((noreturn,
+             format (printf, 1, 2)))
+           );
+
+
+struct dwflpp
+{
+  static void loc2c_error (const char *fmt, ...)
+  {
+  }
+
+  void
+  translate_location()
+  {
+    return c_translate_location (&loc2c_error);
+  }
+};
index 759c06aea90d760a83afe3f30407a6b8e3e2652b..fc5c8246cccd652f2b5b3e053daf6fda7ed1c4c2 100644 (file)
@@ -3678,12 +3678,6 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals)
       TYPE_REFERENCE_TO (ntype) = 0;
       TYPE_ATTRIBUTES (ntype) = attribute;
 
-      if (TYPE_STRUCTURAL_EQUALITY_P (ttype))
-       SET_TYPE_STRUCTURAL_EQUALITY (ntype);
-      else
-       TYPE_CANONICAL (ntype)
-         = build_qualified_type (TYPE_CANONICAL (ttype), quals);
-
       /* Create a new main variant of TYPE.  */
       TYPE_MAIN_VARIANT (ntype) = ntype;
       TYPE_NEXT_VARIANT (ntype) = 0;
@@ -3726,8 +3720,12 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals)
       /* If the target-dependent attributes make NTYPE different from
         its canonical type, we will need to use structural equality
         checks for this qualified type. */
-      if (!targetm.comp_type_attributes (ntype, ttype))
+      ttype = build_qualified_type (ttype, TYPE_UNQUALIFIED);
+      if (TYPE_STRUCTURAL_EQUALITY_P (ttype)
+          || !targetm.comp_type_attributes (ntype, ttype))
        SET_TYPE_STRUCTURAL_EQUALITY (ntype);
+      else
+       TYPE_CANONICAL (ntype) = TYPE_CANONICAL (ttype);
 
       ttype = build_qualified_type (ntype, quals);
     }