diff options
author | Marek Polacek <polacek@redhat.com> | 2020-02-07 14:44:25 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2020-02-07 16:59:09 -0500 |
commit | ac6eaa55a5199196ea0a25763114ce05333a14d3 (patch) | |
tree | 26e3cee974415a5d8695ad18be4519f3824a0522 /gcc/cp | |
parent | 8496e135b111424e3c84f3f44c74f2cbe48eed90 (diff) | |
download | gcc-ac6eaa55a5199196ea0a25763114ce05333a14d3.zip gcc-ac6eaa55a5199196ea0a25763114ce05333a14d3.tar.gz gcc-ac6eaa55a5199196ea0a25763114ce05333a14d3.tar.bz2 |
c++: Fix paren init of aggregates in unevaluated context [PR92947]
When I implemented C++20 parenthesized initialization of aggregates
I introduced this bogus cp_unevaluated_operand check, thus disabling
this feature in unevaluated context. Oop.
Removing the check turned up another bug: I wasn't checking the
return value of digest_init. So when constructible_expr called
build_new_method_call_1 to see if we can construct one type from
another, it got back a bogus INIT_EXPR that looked something like
*(struct T &) 1 = <<< error >>>. But that isn't the error_mark_node,
so constructible_expr thought we had been successful in creating the
ctor call, and it gave the wrong answer. Covered by paren-init17.C.
PR c++/92947 - Paren init of aggregates in unevaluated context.
* call.c (build_new_method_call_1): Don't check
cp_unevaluated_operand. Check the return value of digest_init.
* g++.dg/cpp2a/paren-init21.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 580b766..f1fe774 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-02-07 Marek Polacek <polacek@redhat.com> + + PR c++/92947 - Paren init of aggregates in unevaluated context. + * call.c (build_new_method_call_1): Don't check + cp_unevaluated_operand. Check the return value of digest_init. + 2020-02-06 Jason Merrill <jason@redhat.com> PR c++/92654 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index fde29f8..51621b7 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -10179,7 +10179,6 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, the two. */ if (DECL_CONSTRUCTOR_P (fn) && !(flags & LOOKUP_ONLYCONVERTING) - && !cp_unevaluated_operand && cxx_dialect >= cxx2a && CP_AGGREGATE_TYPE_P (basetype) && !user_args->is_empty ()) @@ -10194,6 +10193,8 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, else { ctor = digest_init (basetype, ctor, complain); + if (ctor == error_mark_node) + return error_mark_node; ctor = build2 (INIT_EXPR, TREE_TYPE (instance), instance, ctor); TREE_SIDE_EFFECTS (ctor) = true; return ctor; |