scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit f6df05343dbc81b5f3f8f1fa129007b3dd4a47fc
parent a6cab76f9a90a0dbadf789b1b68aa0c05fc90ff7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 10 Aug 2015 23:28:30 +0200

Allow empty declarations in structures

Declarations, of any type, without identifier means nothing,
so they must be ignored, even in field declarations.

Diffstat:
cc1/decl.c | 8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cc1/decl.c b/cc1/decl.c @@ -450,11 +450,13 @@ field(Symbol *sym, Type *tp, unsigned ns, int sclass, Type *data) size_t n = funtp->n.elem; char *name = sym->name; + if (!name) { + sym->type = tp; + warn("empty declaration"); + return sym; + } if (sclass) error("storage class in struct/union field"); - if (!sym->name) - error("missed identifier in field declaration"); - if (tp->op == FTN) error("invalid type in struct/union"); if (!tp->defined)