aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2022-11-30 04:02:07 +0000
committerAndrew Pinski <apinski@marvell.com>2023-04-30 21:48:59 +0000
commitd56af02fb1fd6eb50beb8a1689cf646bc567dbfc (patch)
tree664601021ccd04050c25e90b1388f743b0789a91 /gcc/c
parenta6b810ae783acf8cec2d2272a46bd6de0976f496 (diff)
downloadgcc-d56af02fb1fd6eb50beb8a1689cf646bc567dbfc.zip
gcc-d56af02fb1fd6eb50beb8a1689cf646bc567dbfc.tar.gz
gcc-d56af02fb1fd6eb50beb8a1689cf646bc567dbfc.tar.bz2
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.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/c-typeck.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 9cc7e01..f619e2a 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -10647,7 +10647,7 @@ process_init_element (location_t loc, struct c_expr value, bool implicit,
{
if (constructor_stack->replacement_value.value)
{
- error_init (loc, "excess elements in %<char%> array initializer");
+ error_init (loc, "excess elements in %qT initializer", constructor_type);
return;
}
else if (string_flag)