diff options
| author | seyko <seyko2@gmail.com> | 2015-04-10 06:31:58 +0300 |
|---|---|---|
| committer | seyko <seyko2@gmail.com> | 2015-04-10 06:31:58 +0300 |
| commit | dec959358a2d947e7bad18507394b7057a93fae3 (patch) | |
| tree | 0d1e7030f132b23435c0de7896942fc5a69f4d38 /tccgen.c | |
| parent | 9fc3d66f1b175dd712c91692c73445b65090db61 (diff) | |
| download | tinycc-dec959358a2d947e7bad18507394b7057a93fae3.tar.gz tinycc-dec959358a2d947e7bad18507394b7057a93fae3.tar.bz2 | |
fix the bug #31403: parser bug in structure
- a warning: unnamed struct/union that defines no instances
- allow a nested named struct declaration w/o identifier
only when option -fms-extensions is used
Diffstat (limited to 'tccgen.c')
| -rw-r--r-- | tccgen.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -2959,8 +2959,17 @@ static void struct_decl(CType *type, int u, int tdef) type1 = btype; if (tok != ':') { type_decl(&type1, &ad, &v, TYPE_DIRECT | TYPE_ABSTRACT); - if (v == 0 && (type1.t & VT_BTYPE) != VT_STRUCT) - expect("identifier"); + if (v == 0) { + if ((type1.t & VT_BTYPE) != VT_STRUCT) + expect("identifier"); + else { + int v = btype.ref->v; + if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) < SYM_FIRST_ANOM) { + if (tcc_state->ms_extensions == 0) + expect("identifier"); + } + } + } if (type_size(&type1, &align) < 0) { if ((a == TOK_STRUCT) && (type1.t & VT_ARRAY) && c) flexible = 1; @@ -6121,7 +6130,11 @@ static int decl0(int l, int is_for_loop_init) if (((btype.t & VT_BTYPE) == VT_ENUM || (btype.t & VT_BTYPE) == VT_STRUCT) && tok == ';') { - /* we accept no variable after */ + if ((btype.t & VT_BTYPE) == VT_STRUCT) { + int v = btype.ref->v; + if (!(v & SYM_FIELD) && (v & ~SYM_STRUCT) >= SYM_FIRST_ANOM) + tcc_warning("unnamed struct/union that defines no instances"); + } next(); continue; } |
