diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-04-12 23:45:54 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-04-12 23:45:54 +0200 |
commit | 60a2c64519087972b16d94f6cca209fa6a3f0940 (patch) | |
tree | 8b402ce47953b06b0ba0f3744ac961fa763a6ce3 /gcc/c/c-decl.c | |
parent | bb50312e027994bb5260163a9c021b5444f86257 (diff) | |
download | gcc-60a2c64519087972b16d94f6cca209fa6a3f0940.zip gcc-60a2c64519087972b16d94f6cca209fa6a3f0940.tar.gz gcc-60a2c64519087972b16d94f6cca209fa6a3f0940.tar.bz2 |
re PR c/89933 (ICE in merge_decls, at c/c-decl.c:2517)
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
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 8d5c35a..ef9b874 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -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; + } } } |