scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 58149ef559f52ec3e1604513f15c776f59065eca
parent c9a50478a9b995cf12d91edb32cf9e4dda528a31
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  2 Nov 2013 07:28:27 +0100

Remove wrong warnings in struct/union/enum declaration

These warning were incorrects and they were caused by an incorrect
dealing of empty declarations. This new version deals them correctly.

Diffstat:
Mdecl.c | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/decl.c b/decl.c @@ -351,7 +351,12 @@ repeat: initctype(&base); register unsigned char type = base.type; switch (type) { - case STRUCT: case UNION: case ENUM: + case STRUCT: case UNION: + if (!base.sym) { + warn(options.useless, + "unnamed struct/union that defines no instances"); + } + case ENUM: if (store.defined) { warn(options.useless, "useless storage class specifier in empty declaration"); @@ -360,14 +365,13 @@ repeat: initctype(&base); warn(options.useless, "useless type qualifier in empty declaration"); } - if (base.sym && type != ENUM) { - warn(options.useless, - "unnamed struct/union that defines no instances"); - } + break; default: warn(options.useless, "useless type name in empty declaration"); } + if (yytoken == EOFTOK) + return NULL; goto repeat; } np = listdcl(&base, &store, &qlf);