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:
Romain Francoise 2010-03-13 18:07:57 +01:00 committed by Thomas Preud'homme
parent d2cf970a41
commit 6655e06ec8

View File

@ -4690,6 +4690,9 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
no_oblock = 1;
if ((first && tok != TOK_LSTR && tok != TOK_STR) ||
tok == '{') {
if (tok != '{')
error("character array initializer must be a literal,"
" optionally enclosed in braces");
skip('{');
no_oblock = 0;
}