From 6655e06ec851e3541f2f47187f95956e5003c7b8 Mon Sep 17 00:00:00 2001 From: Romain Francoise Date: Sat, 13 Mar 2010 18:07:57 +0100 Subject: [PATCH] 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 who did all the work. --- tccgen.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tccgen.c b/tccgen.c index 87c9f0d2..1253d1e8 100644 --- a/tccgen.c +++ b/tccgen.c @@ -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; }