c++: fix string literal member initializer bug [PR90926]
commite6cc142ad99ab8d28581f4ce61056c9cce74dba3
authorTom Greenslade (thomgree) <thomgree@cisco.com>
Wed, 3 Feb 2021 11:31:53 +0000 (3 11:31 +0000)
committerJason Merrill <jason@redhat.com>
Thu, 4 Feb 2021 15:46:39 +0000 (4 10:46 -0500)
tree36040f01624599a628e0439d9e441c8ee355ae9d
parentaa652fb2a083c15678f82a5cb20b7f8cbc9c1437
c++: fix string literal member initializer bug [PR90926]

build_aggr_conv did not correctly handle string literal member initializers.
Extended can_convert_array to handle this case. For the additional check of
compatibility of character types, factored out code from digest_init_r into
a new function.

gcc/cp/ChangeLog:

PR c++/90926
* call.c (can_convert_array): Extend to handle all valid aggregate
initializers of an array; including by string literals, not just by
brace-init-list.
(build_aggr_conv): Call can_convert_array more often, not just in
brace-init-list case.
* typeck2.c (array_string_literal_compatible_p): New function.
(digest_init_r): call array_string_literal_compatible_p
* cp-tree.h: (array_string_literal_compatible_p): Declare.

gcc/testsuite/ChangeLog:

PR c++/90926
* g++.dg/cpp1y/nsdmi-aggr12.C: New test.
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr12.C [new file with mode: 0644]