c++: dependent array bounds completion [PR104302]
commit501c4ee9fad68716497db4d96b63b801cc57b4a1
authorJason Merrill <jason@redhat.com>
Wed, 2 Feb 2022 22:49:02 +0000 (2 17:49 -0500)
committerJason Merrill <jason@redhat.com>
Thu, 3 Feb 2022 02:14:10 +0000 (2 21:14 -0500)
tree31103d3c37e0e0e071bcd536a55890e206565dca
parentdc898b2ba5c50a7311bc3137f0987a7831362ed8
c++: dependent array bounds completion [PR104302]

The patch for PR55227 changed the minimal init-list handling in
cp_complete_array_type to a call to reshape_init, which broke on the
dependent initializer.  It occurred to me that trying to deduce the array
size from a dependent init-list is wrong in general, so let's just not.  I
also limited the reshape_init call to the case of a char array, as before
the patch for 55227; that's the only case where we want to strip a level of
braces from an array.

PR c++/104302

gcc/cp/ChangeLog:

* decl.cc (maybe_deduce_size_from_array_init): Give up
on type-dependent init.
(cp_complete_array_type): Only call reshape_init for character
array.

gcc/testsuite/ChangeLog:

* g++.dg/template/array35.C: New test.
* g++.dg/template/array36.C: New test.
gcc/cp/decl.cc
gcc/testsuite/g++.dg/template/array35.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/array36.C [new file with mode: 0644]