]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c/89933 (ICE in merge_decls, at c/c-decl.c:2517)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:36:05 +0000 (14:36 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:36:05 +0000 (14:36 +0200)
Backported from mainline
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.

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

* c-c++-common/pr89933.c: New test.

From-SVN: r275147

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 e6108f1b3b3b11a353313b803fd3006ddc2fd016..a861feeac2ee20f0431f6500f4580225bfdc6543 100644 (file)
@@ -1,6 +1,13 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-03-19  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/89734
index 8342094f35405bb2f7d12453358e24da19b5a4f9..11c63af89ed7ae941fbbc680e70e826d2dd403ac 100644 (file)
@@ -2348,13 +2348,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 300eca80f259a054779927bc322c94155e7cc3e3..742b0e428440994e6fe9bfaa6e72682a474518dd 100644 (file)
@@ -1,6 +1,13 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       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-03-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR sanitizer/89869
index 950e04a668070e5d9dde361b5878e3c2e7a3c078..1ad6ad8fae4815579dbd5800eea38cb180939c76 100644 (file)
@@ -2130,13 +2130,16 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
          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
index 57818737747470acf2f5d7572401409ac814ee5b..46097e5d5ab6127929ee298dd814f982bceeff95 100644 (file)
@@ -1,6 +1,11 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2019-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/89933
+       * c-c++-common/pr89933.c: New test.
+
        2019-04-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/89998
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__));