aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2019-04-08 08:13:50 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2019-04-08 08:13:50 +0000
commit8d2318ffa323564735c39a4de251df2dfcceb346 (patch)
treeae97a7f0ad9ba0b6de268c934b2817fa5b9cf23c /gcc/cp
parent66d8ee9ce0245c8c60af96365b3072a9e25729e6 (diff)
downloadgcc-8d2318ffa323564735c39a4de251df2dfcceb346.zip
gcc-8d2318ffa323564735c39a4de251df2dfcceb346.tar.gz
gcc-8d2318ffa323564735c39a4de251df2dfcceb346.tar.bz2
re PR c++/89914 (ICE in nothrow_spec_p, at cp/except.c:1238)
/cp 2019-04-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/89914 * semantics.c (trait_expr_value): Don't use TYPE_NOTHROW_P when maybe_instantiate_noexcept fails. (classtype_has_nothrow_assign_or_copy_p): Likewise. * method.c (implicitly_declare_fn): Avoid passing error_mark_node to build_exception_variant. /testsuite 2019-04-08 Paolo Carlini <paolo.carlini@oracle.com> PR c++/89914 * g++.dg/ext/has_nothrow_constructor-3.C: New. From-SVN: r270201
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/method.c9
-rw-r--r--gcc/cp/semantics.c8
3 files changed, 21 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f766f47..74e2b7d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2019-04-08 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/89914
+ * semantics.c (trait_expr_value): Don't use TYPE_NOTHROW_P
+ when maybe_instantiate_noexcept fails.
+ (classtype_has_nothrow_assign_or_copy_p): Likewise.
+ * method.c (implicitly_declare_fn): Avoid passing error_mark_node
+ to build_exception_variant.
+
2019-04-05 Marek Polacek <polacek@redhat.com>
PR c++/87145 - bogus error converting class type in template arg list.
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index da9600c..03eea40 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -2061,7 +2061,14 @@ implicitly_declare_fn (special_function_kind kind, tree type,
/* Create the function. */
fn_type = build_method_type_directly (type, return_type, parameter_types);
if (raises)
- fn_type = build_exception_variant (fn_type, raises);
+ {
+ if (raises != error_mark_node)
+ fn_type = build_exception_variant (fn_type, raises);
+ else
+ /* Can happen, eg, in C++98 mode for an ill-formed non-static data
+ member initializer (c++/89914). */
+ gcc_assert (seen_error ());
+ }
fn = build_lang_decl (FUNCTION_DECL, name, fn_type);
if (kind != sfk_inheriting_constructor)
DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (TYPE_NAME (type));
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 408675b..3ae9cf0 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9551,8 +9551,8 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
if (copy_fn_p (fn) > 0)
{
saw_copy = true;
- maybe_instantiate_noexcept (fn);
- if (!TYPE_NOTHROW_P (TREE_TYPE (fn)))
+ if (!maybe_instantiate_noexcept (fn)
+ || !TYPE_NOTHROW_P (TREE_TYPE (fn)))
return false;
}
}
@@ -9594,8 +9594,8 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2)
return (trait_expr_value (CPTK_HAS_TRIVIAL_CONSTRUCTOR, type1, type2)
|| (CLASS_TYPE_P (type1)
&& (t = locate_ctor (type1))
- && (maybe_instantiate_noexcept (t),
- TYPE_NOTHROW_P (TREE_TYPE (t)))));
+ && maybe_instantiate_noexcept (t)
+ && TYPE_NOTHROW_P (TREE_TYPE (t))));
case CPTK_HAS_TRIVIAL_CONSTRUCTOR:
type1 = strip_array_types (type1);