diff options
| author | Jaroslav Kysela <perex@perex.cz> | 2011-02-22 10:06:20 +0100 |
|---|---|---|
| committer | Jaroslav Kysela <perex@perex.cz> | 2011-02-22 12:15:44 +0100 |
| commit | dbefae52b07ce1b93af3a0e4ecbf25ca638e97eb (patch) | |
| tree | dae38bdbd2fd4d9ce18afaec35bc636e00295192 /tccgen.c | |
| parent | a3ebdd0aeb834e3e7a644925ebb363d7b8064a52 (diff) | |
| download | tinycc-dbefae52b07ce1b93af3a0e4ecbf25ca638e97eb.tar.gz tinycc-dbefae52b07ce1b93af3a0e4ecbf25ca638e97eb.tar.bz2 | |
Fix complex static initializers (handle additional '}' and '{' brackets)
- added an example to test suite
- the "warning: assignment discards qualifiers from pointer target type"
is present but harmless
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -4768,7 +4768,7 @@ static void init_putz(CType *t, Section *sec, unsigned long c, int size) static void decl_initializer(CType *type, Section *sec, unsigned long c, int first, int size_only) { - int index, array_length, n, no_oblock, nb, parlevel, i; + int index, array_length, n, no_oblock, nb, parlevel, parlevel1, i; int size1, align1, expr_type; Sym *s, *f; CType *t1; @@ -4970,13 +4970,17 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c, skip('}'); } else if (size_only) { /* just skip expression */ - parlevel = 0; - while ((parlevel > 0 || (tok != '}' && tok != ',')) && - tok != -1) { + parlevel = parlevel1 = 0; + while ((parlevel > 0 || parlevel1 > 0 || + (tok != '}' && tok != ',')) && tok != -1) { if (tok == '(') parlevel++; else if (tok == ')') parlevel--; + else if (tok == '{') + parlevel1++; + else if (tok == '}') + parlevel1--; next(); } } else { |
