re PR c/89933 (ICE in merge_decls, at c/c-decl.c:2517)
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Apr 2019 21:45:54 +0000 (23:45 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Apr 2019 21:45:54 +0000 (23:45 +0200)
PR c/89933
c/
* c-decl.c (merge_decls): When newdecl's type is its main variant,
don't try to remove it from the variant list, but instead assert
it has no variants.
cp/
* decl.c (duplicate_decls): When newdecl's type is its main variant,
don't try to remove it from the variant list, but instead assert
it has no variants.
testsuite/
* c-c++-common/pr89933.c: New test.

From-SVN: r270329

gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr89933.c [new file with mode: 0644]

index 076a9a26501c0c87645c29092473a9a881c52975..c8e5e1a6b0bee21d6d119319dfa835a7c41bab88 100644 (file)
@@ -1,3 +1,10 @@
+2019-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89933
+       * c-decl.c (merge_decls): When newdecl's type is its main variant,
+       don't try to remove it from the variant list, but instead assert
+       it has no variants.
+
 2019-04-01  Richard Biener  <rguenther@suse.de>
 
        PR c/71598
index 8d5c35ab4751154f40ec0fca97117d6d6d328d5a..ef9b874f997762cd456736c426d9281c95dc49b1 100644 (file)
@@ -2512,13 +2512,16 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
       if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
        {
          tree remove = TREE_TYPE (newdecl);
-         for (tree t = TYPE_MAIN_VARIANT (remove); ;
-              t = TYPE_NEXT_VARIANT (t))
-           if (TYPE_NEXT_VARIANT (t) == remove)
-             {
-               TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
-               break;
-             }
+         if (TYPE_MAIN_VARIANT (remove) == remove)
+           gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE);
+         else
+           for (tree t = TYPE_MAIN_VARIANT (remove); ;
+                t = TYPE_NEXT_VARIANT (t))
+             if (TYPE_NEXT_VARIANT (t) == remove)
+               {
+                 TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
+                 break;
+               }
        }
     }
 
index 212318e096638d38c716c47ed4a2ec66336a605d..67baed6672f4f527670cb85749ddbcce17b945e9 100644 (file)
@@ -1,3 +1,10 @@
+2019-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89933
+       * decl.c (duplicate_decls): When newdecl's type is its main variant,
+       don't try to remove it from the variant list, but instead assert
+       it has no variants.
+
 2019-04-12  Martin Sebor  <msebor@redhat.com>
 
        PR c/88383
index 2528a8cd670f57d9594ea25b8a8c22d80e184969..67d9244c450e3fb878064f243454461644c1ab4c 100644 (file)
@@ -2132,13 +2132,16 @@ next_arg:;
          if (TYPE_NAME (TREE_TYPE (newdecl)) == newdecl)
            {
              tree remove = TREE_TYPE (newdecl);
-             for (tree t = TYPE_MAIN_VARIANT (remove); ;
-                  t = TYPE_NEXT_VARIANT (t))
-               if (TYPE_NEXT_VARIANT (t) == remove)
-                 {
-                   TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
-                   break;
-                 }
+             if (TYPE_MAIN_VARIANT (remove) == remove)
+               gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE);
+             else
+               for (tree t = TYPE_MAIN_VARIANT (remove); ;
+                    t = TYPE_NEXT_VARIANT (t))
+                 if (TYPE_NEXT_VARIANT (t) == remove)
+                   {
+                     TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (remove);
+                     break;
+                   }
            }
        }
       else if (merge_attr)
index ed6f731b5b5e9bee2495e74a4f18beb70fb83952..2951fc821672b9e3801ff34a867c4ec94441a677 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89933
+       * c-c++-common/pr89933.c: New test.
+
 2019-04-12  Martin Sebor  <msebor@redhat.com>
 
        PR c/88383
diff --git a/gcc/testsuite/c-c++-common/pr89933.c b/gcc/testsuite/c-c++-common/pr89933.c
new file mode 100644 (file)
index 0000000..870504d
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR c/89933 */
+/* { dg-do compile } */
+
+typedef unsigned int a __attribute__ ((__aligned__(8), __may_alias__));
+typedef unsigned int a __attribute__ ((__aligned__(8), __may_alias__));