diff options
author | Jason Merrill <jason@redhat.com> | 2017-09-08 18:39:17 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2017-09-08 18:39:17 -0400 |
commit | 27c825c5cca3243f293aee29a4abeb22242d4d2b (patch) | |
tree | d4c20252428e4348fc569284133594067d73b3c8 /gcc/attribs.c | |
parent | b2c5d6f1d2a71374bcd8277a0697490582bc03a8 (diff) | |
download | gcc-27c825c5cca3243f293aee29a4abeb22242d4d2b.zip gcc-27c825c5cca3243f293aee29a4abeb22242d4d2b.tar.gz gcc-27c825c5cca3243f293aee29a4abeb22242d4d2b.tar.bz2 |
PR c++/70029 - ICE with ref-qualifier and -flto
PR c++/70029 - ICE with ref-qualifier and -flto
gcc/
* langhooks.h (struct lang_hooks_for_types): Add
copy_lang_qualifiers.
* attribs.c (build_type_attribute_qual_variant): Use it.
* langhooks-def.h (LANG_HOOKS_COPY_LANG_QUALIFIERS): Default to
NULL.
(LANG_HOOKS_FOR_TYPES_INITIALIZER): Use it.
* tree.c (verify_type): Re-enable TYPE_CANONICAL main variant check.
gcc/cp/
* tree.c (cxx_copy_lang_qualifiers): New.
* cp-tree.h: Declare it.
* cp-objcp-common.h: Define LANG_HOOKS_COPY_LANG_QUALIFIERS.
From-SVN: r251911
Diffstat (limited to 'gcc/attribs.c')
-rw-r--r-- | gcc/attribs.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/attribs.c b/gcc/attribs.c index faa0649..b8f58a7 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -959,8 +959,9 @@ build_decl_attribute_variant (tree ddecl, tree attribute) Record such modified types already made so we don't make duplicates. */ tree -build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) +build_type_attribute_qual_variant (tree otype, tree attribute, int quals) { + tree ttype = otype; if (! attribute_list_equal (TYPE_ATTRIBUTES (ttype), attribute)) { tree ntype; @@ -983,6 +984,11 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) } ttype = build_qualified_type (ttype, TYPE_UNQUALIFIED); + if (lang_hooks.types.copy_lang_qualifiers + && otype != TYPE_MAIN_VARIANT (otype)) + ttype = (lang_hooks.types.copy_lang_qualifiers + (ttype, TYPE_MAIN_VARIANT (otype))); + ntype = build_distinct_type_copy (ttype); TYPE_ATTRIBUTES (ntype) = attribute; @@ -1000,6 +1006,9 @@ build_type_attribute_qual_variant (tree ttype, tree attribute, int quals) TYPE_CANONICAL (ntype) = TYPE_CANONICAL (ttype); ttype = build_qualified_type (ntype, quals); + if (lang_hooks.types.copy_lang_qualifiers + && otype != TYPE_MAIN_VARIANT (otype)) + ttype = lang_hooks.types.copy_lang_qualifiers (ttype, otype); } else if (TYPE_QUALS (ttype) != quals) ttype = build_qualified_type (ttype, quals); |