]> git.ipfire.org Git - thirdparty/gcc.git/commit
Improve error message for excess elements in array initializer from {"a"}
authorAndrew Pinski <apinski@marvell.com>
Wed, 30 Nov 2022 04:02:07 +0000 (04:02 +0000)
committerAndrew Pinski <apinski@marvell.com>
Sun, 30 Apr 2023 21:48:59 +0000 (21:48 +0000)
commitd56af02fb1fd6eb50beb8a1689cf646bc567dbfc
tree664601021ccd04050c25e90b1388f743b0789a91
parenta6b810ae783acf8cec2d2272a46bd6de0976f496
Improve error message for excess elements in array initializer from {"a"}

So char arrays are not the only type that be initialized from {"a"}.
We can have wchar_t (L"") and char16_t (u"") types too. So let's
print out the type of the array instead of just saying char.

Note in the testsuite I used regex . to match '[' and ']' as
I could not figure out how many '\' I needed.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/c/ChangeLog:

* c-typeck.cc (process_init_element): Print out array type
for excessive elements.

gcc/testsuite/ChangeLog:

* gcc.dg/init-bad-1.c: Update error message.
* gcc.dg/init-bad-2.c: Likewise.
* gcc.dg/init-bad-3.c: Likewise.
* gcc.dg/init-excess-3.c: Likewise.
* gcc.dg/pr61096-1.c: Likewise.
gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/init-bad-1.c
gcc/testsuite/gcc.dg/init-bad-2.c
gcc/testsuite/gcc.dg/init-bad-3.c
gcc/testsuite/gcc.dg/init-excess-3.c
gcc/testsuite/gcc.dg/pr61096-1.c