aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-09-08 18:39:17 -0400
committerJason Merrill <jason@gcc.gnu.org>2017-09-08 18:39:17 -0400
commit27c825c5cca3243f293aee29a4abeb22242d4d2b (patch)
treed4c20252428e4348fc569284133594067d73b3c8 /gcc/cp
parentb2c5d6f1d2a71374bcd8277a0697490582bc03a8 (diff)
downloadgcc-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/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/cp-objcp-common.h2
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/tree.c15
4 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6c4a31d..730a2da 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2017-09-08 Jason Merrill <jason@redhat.com>
+
+ PR c++/70029 - ICE with ref-qualifier and -flto
+ * tree.c (cxx_copy_lang_qualifiers): New.
+ * cp-tree.h: Declare it.
+ * cp-objcp-common.h: Define LANG_HOOKS_COPY_LANG_QUALIFIERS.
+
2017-09-06 Jason Merrill <jason@redhat.com>
PR c++/82053 - ICE with default argument in lambda in template
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 10fcdf3..3e4cc9c 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -99,6 +99,8 @@ extern void cp_register_dumps (gcc::dump_manager *);
#define LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE cxx_builtin_function_ext_scope
#undef LANG_HOOKS_TYPE_HASH_EQ
#define LANG_HOOKS_TYPE_HASH_EQ cxx_type_hash_eq
+#undef LANG_HOOKS_COPY_LANG_QUALIFIERS
+#define LANG_HOOKS_COPY_LANG_QUALIFIERS cxx_copy_lang_qualifiers
#undef LANG_HOOKS_MISSING_NORETURN_OK_P
#define LANG_HOOKS_MISSING_NORETURN_OK_P cp_missing_noreturn_ok_p
#undef LANG_HOOKS_BLOCK_MAY_FALLTHRU
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index a0e31d3..a57de33 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6963,6 +6963,7 @@ extern tree convert_bitfield_to_declared_type (tree);
extern tree cp_save_expr (tree);
extern bool cast_valid_in_integral_constant_expression_p (tree);
extern bool cxx_type_hash_eq (const_tree, const_tree);
+extern tree cxx_copy_lang_qualifiers (const_tree, const_tree);
extern void cxx_print_statistics (void);
extern bool maybe_warn_zero_as_null_pointer_constant (tree, location_t);
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 12c31fb..f387f38 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4626,6 +4626,21 @@ cxx_type_hash_eq (const_tree typea, const_tree typeb)
TYPE_RAISES_EXCEPTIONS (typeb), ce_exact);
}
+/* Copy the language-specific type variant modifiers from TYPEB to TYPEA. For
+ C++, these are the exception-specifier and ref-qualifier. */
+
+tree
+cxx_copy_lang_qualifiers (const_tree typea, const_tree typeb)
+{
+ tree type = CONST_CAST_TREE (typea);
+ if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)
+ {
+ type = build_exception_variant (type, TYPE_RAISES_EXCEPTIONS (typeb));
+ type = build_ref_qualified_type (type, type_memfn_rqual (typeb));
+ }
+ return type;
+}
+
/* Apply FUNC to all language-specific sub-trees of TP in a pre-order
traversal. Called from walk_tree. */