aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck2.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2021-05-19 21:13:43 -0400
committerJason Merrill <jason@redhat.com>2021-05-20 16:59:17 -0400
commit885035eacb36b5bf1aa3b0d05f675ab89665d7be (patch)
treeff4cd9403ff68ee97e53d5ac5d48d23502412479 /gcc/cp/typeck2.c
parent84fd1b5dff70cd74aee7e8b18f66959d8b8e1ce7 (diff)
downloadgcc-885035eacb36b5bf1aa3b0d05f675ab89665d7be.zip
gcc-885035eacb36b5bf1aa3b0d05f675ab89665d7be.tar.gz
gcc-885035eacb36b5bf1aa3b0d05f675ab89665d7be.tar.bz2
c++: designators in single-element init lists
While looking at PR100489, it occurred to me that places that currently use an initializer-list with a single element to initialize an object of the same type shouldn't do that if the element has a designator. gcc/cp/ChangeLog: * call.c (reference_binding): Check for designator. (implicit_conversion_1, build_special_member_call): Likewise. * decl.c (reshape_init_r): Likewise. * pt.c (do_class_deduction): Likewise. * typeck2.c (digest_init_r): Likewise. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/desig19.C: New test.
Diffstat (limited to 'gcc/cp/typeck2.c')
-rw-r--r--gcc/cp/typeck2.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 5a7219d..6679e24 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1183,6 +1183,7 @@ digest_init_r (tree type, tree init, int nested, int flags,
the object is initialized from that element." */
if (cxx_dialect >= cxx11
&& BRACE_ENCLOSED_INITIALIZER_P (stripped_init)
+ && !CONSTRUCTOR_IS_DESIGNATED_INIT (stripped_init)
&& CONSTRUCTOR_NELTS (stripped_init) == 1
&& ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type))
|| VECTOR_TYPE_P (type)))