mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-15 05:20:06 +08:00
Error out on bad char array initialization
Error out with an explicit message when trying to initialize a character array with something that's not a literal (optionally enclosed in braces) as per C99 6.7.8:14; thanks to Antti-Juhani Kaijanaho <ajk@debian.org> who did all the work.
This commit is contained in:
parent
d2cf970a41
commit
6655e06ec8
3
tccgen.c
3
tccgen.c
@ -4690,6 +4690,9 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
|
|||||||
no_oblock = 1;
|
no_oblock = 1;
|
||||||
if ((first && tok != TOK_LSTR && tok != TOK_STR) ||
|
if ((first && tok != TOK_LSTR && tok != TOK_STR) ||
|
||||||
tok == '{') {
|
tok == '{') {
|
||||||
|
if (tok != '{')
|
||||||
|
error("character array initializer must be a literal,"
|
||||||
|
" optionally enclosed in braces");
|
||||||
skip('{');
|
skip('{');
|
||||||
no_oblock = 0;
|
no_oblock = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user