diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-04-19 10:24:05 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-04-19 10:24:05 +0200 |
commit | e7178413f46ac98975bd4b83e073c931b418205d (patch) | |
tree | f491d635b20c7ce83f8fe69a7cfcd1479503d80e /gcc/c | |
parent | 1ad6b2105127d761df87840f77a4fde06f1dbf9e (diff) | |
download | gcc-e7178413f46ac98975bd4b83e073c931b418205d.zip gcc-e7178413f46ac98975bd4b83e073c931b418205d.tar.gz gcc-e7178413f46ac98975bd4b83e073c931b418205d.tar.bz2 |
re PR c++/90108 (ICE: Segmentation fault (in c_tree_chain_next))
PR c++/90108
* c-decl.c (merge_decls): If remove is main variant and
DECL_ORIGINAL_TYPE is some other type, remove a DECL_ORIGINAL_TYPE
variant that has newdecl as TYPE_NAME if any.
* decl.c (duplicate_decls): If remove is main variant and
DECL_ORIGINAL_TYPE is some other type, remove a DECL_ORIGINAL_TYPE
variant that has newdecl as TYPE_NAME if any.
* c-c++-common/pr90108.c: New test.
From-SVN: r270453
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 19 |
2 files changed, 25 insertions, 1 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index c8e5e1a..27660b9 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2019-04-19 Jakub Jelinek <jakub@redhat.com> + + PR c++/90108 + * c-decl.c (merge_decls): If remove is main variant and + DECL_ORIGINAL_TYPE is some other type, remove a DECL_ORIGINAL_TYPE + variant that has newdecl as TYPE_NAME if any. + 2019-04-12 Jakub Jelinek <jakub@redhat.com> PR c/89933 diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index ef9b874..c8e7cd0 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -2513,7 +2513,24 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) { tree remove = TREE_TYPE (newdecl); if (TYPE_MAIN_VARIANT (remove) == remove) - gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE); + { + gcc_assert (TYPE_NEXT_VARIANT (remove) == NULL_TREE); + /* If remove is the main variant, no need to remove that + from the list. One of the DECL_ORIGINAL_TYPE + variants, e.g. created for aligned attribute, might still + refer to the newdecl TYPE_DECL though, so remove that one + in that case. */ + if (DECL_ORIGINAL_TYPE (newdecl) + && DECL_ORIGINAL_TYPE (newdecl) != remove) + for (tree t = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (newdecl)); + t; t = TYPE_MAIN_VARIANT (t)) + if (TYPE_NAME (TYPE_NEXT_VARIANT (t)) == newdecl) + { + TYPE_NEXT_VARIANT (t) + = TYPE_NEXT_VARIANT (TYPE_NEXT_VARIANT (t)); + break; + } + } else for (tree t = TYPE_MAIN_VARIANT (remove); ; t = TYPE_NEXT_VARIANT (t)) |