]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/34935 (ICE with attribute may_alias)
authorDouglas Gregor <doug.gregor@gmail.com>
Thu, 31 Jan 2008 20:06:33 +0000 (20:06 +0000)
committerDoug Gregor <dgregor@gcc.gnu.org>
Thu, 31 Jan 2008 20:06:33 +0000 (20:06 +0000)
2008-01-31  Douglas Gregor  <doug.gregor@gmail.com>
           Jakub Jelinek  <jakub@redhat.com>

       PR c++/34935
       PR c++/34936
       * typeck.c (structural_comptypes): Handle comparisons of
       VOID_TYPE, BOOLEAN_TYPE, INTEGER_TYPE, FIXED_POINT_TYPE, and
       REAL_TYPE nodes.
       * mangle.c (write_builtin_type): Map down to the canonical type,
       which will be one of the predefined type nodes.

2008-01-31  Douglas Gregor  <doug.gregor@gmail.com>
           Jakub Jelinek  <jakub@redhat.com>

       PR c++/34935
       PR c++/34936
       * g++.dg/ext/alias-canon.C: New.
       * g++.dg/ext/alias-mangle.C: New.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r131984

gcc/cp/ChangeLog
gcc/cp/mangle.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/alias-canon.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/alias-mangle.C [new file with mode: 0644]

index a5d19e6bc69577b09de9cf1ca868bd2f046122c5..5b4cc3bb49b5bafda5e14609a8a7f926f1d8d022 100644 (file)
@@ -1,3 +1,14 @@
+2008-01-31  Douglas Gregor  <doug.gregor@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/34935
+       PR c++/34936
+       * typeck.c (structural_comptypes): Handle comparisons of
+       VOID_TYPE, BOOLEAN_TYPE, INTEGER_TYPE, FIXED_POINT_TYPE, and
+       REAL_TYPE nodes.
+       * mangle.c (write_builtin_type): Map down to the canonical type,
+       which will be one of the predefined type nodes.
+
 2008-01-29  Michael Meissner  <michael.meissner@amd.com>
 
        PR 35004
index 7377a3ea455c6bd952c19a968ea47abffa8c5dd4..09a34562e8d3b31cff888d1ecad8286dbc088e6f 100644 (file)
@@ -1768,6 +1768,9 @@ write_CV_qualifiers_for_type (const tree type)
 static void
 write_builtin_type (tree type)
 {
+  if (TYPE_CANONICAL (type))
+    type = TYPE_CANONICAL (type);
+
   switch (TREE_CODE (type))
     {
     case VOID_TYPE:
index fd2a3193a4739bae28e7afb834a255f79382c4dd..4d6e06b59187d497b04854f54aa6fc403b8dad25 100644 (file)
@@ -977,6 +977,30 @@ structural_comptypes (tree t1, tree t2, int strict)
   /* Compare the types.  Break out if they could be the same.  */
   switch (TREE_CODE (t1))
     {
+    case VOID_TYPE:
+    case BOOLEAN_TYPE:
+      /* All void and bool types are the same.  */
+      break;
+
+    case INTEGER_TYPE:
+    case FIXED_POINT_TYPE:
+    case REAL_TYPE:
+      /* With these nodes, we can't determine type equivalence by
+        looking at what is stored in the nodes themselves, because
+        two nodes might have different TYPE_MAIN_VARIANTs but still
+        represent the same type.  For example, wchar_t and int could
+        have the same properties (TYPE_PRECISION, TYPE_MIN_VALUE,
+        TYPE_MAX_VALUE, etc.), but have different TYPE_MAIN_VARIANTs
+        and are distinct types. On the other hand, int and the
+        following typedef
+
+           typedef int INT __attribute((may_alias));
+
+        have identical properties, different TYPE_MAIN_VARIANTs, but
+        represent the same type.  The canonical type system keeps
+        track of equivalence in this case, so we fall back on it.  */
+      return TYPE_CANONICAL (t1) == TYPE_CANONICAL (t2);
+
     case TEMPLATE_TEMPLATE_PARM:
     case BOUND_TEMPLATE_TEMPLATE_PARM:
       if (TEMPLATE_TYPE_IDX (t1) != TEMPLATE_TYPE_IDX (t2)
index 237b0567294fb680a699f53e4143c65bf8bed390..2780a74e43d931e12941359b55c4013e1dde25e5 100644 (file)
@@ -1,3 +1,11 @@
+2008-01-31  Douglas Gregor  <doug.gregor@gmail.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/34935
+       PR c++/34936
+       * g++.dg/ext/alias-canon.C: New.
+       * g++.dg/ext/alias-mangle.C: New.
+
 2008-01-30  Jan Hubicka  <jh@suse.cz>
 
        * gcc.c-torture/execute/pr34982.c: Add forgotten return 0.
diff --git a/gcc/testsuite/g++.dg/ext/alias-canon.C b/gcc/testsuite/g++.dg/ext/alias-canon.C
new file mode 100644 (file)
index 0000000..843dec0
--- /dev/null
@@ -0,0 +1,41 @@
+// PR c++/34935
+/* { dg-do compile } */
+/* { dg-final { scan-assembler "_Z1fi" } } */
+/* { dg-final { scan-assembler "_Z1fb" } } */
+/* { dg-final { scan-assembler "_Z1fd" } } */
+/* { dg-final { scan-assembler "_Z1ff" } } */
+/* { dg-final { scan-assembler "_Z1fw" } } */
+
+typedef int INT __attribute((may_alias));
+
+void f(int);
+void f(INT) { }
+
+typedef bool BOOL __attribute((may_alias));
+
+void f(bool);
+void f(BOOL) { }
+
+typedef float FLOAT __attribute((may_alias));
+
+void f(float);
+void f(FLOAT) { }
+
+typedef double DOUBLE __attribute((may_alias));
+
+void f(double);
+void f(DOUBLE) {}
+
+typedef wchar_t WCHAR_T __attribute((may_alias));
+
+void f(wchar_t);
+void f(WCHAR_T) {}
+
+void test()
+{
+  f(0);
+  f(true);
+  f(1.0f);
+  f(1.0);
+  f(L'f');
+}
diff --git a/gcc/testsuite/g++.dg/ext/alias-mangle.C b/gcc/testsuite/g++.dg/ext/alias-mangle.C
new file mode 100644 (file)
index 0000000..a7706e9
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/34936
+// { dg-do compile }
+/* { dg-final { scan-assembler "_ZN1AIdEC1Ev" } } */
+typedef double X __attribute((may_alias)) ;
+
+template<typename> struct A
+{
+  A();
+};
+
+A<X> a;