scc

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

commit d6c6483728fa4ad0577f51fd26d7ef29ea91e7b3
parent fdbaed739f4eb78f65514764b87fb87834b76ed3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 18 Mar 2014 08:07:13 +0100

Unify errors in fielddcl

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

diff --git a/decl.c b/decl.c @@ -312,17 +312,17 @@ fielddcl(struct ctype *base, uint8_t ns) { struct ctype *tp; struct symbol *sym; + char *err; switch (yytoken) { case SCLASS: - error("storage class '%s' in struct/union field", yytext); + goto bad_storage; case IDEN: case TYPE: case TQUALIFIER: tp = specifier(NULL); - break; case ';': break; default: - error("declaration expected"); + goto dcl_expected; } if (yytoken != ';') { @@ -333,6 +333,14 @@ fielddcl(struct ctype *base, uint8_t ns) } expect(';'); + return; + +bad_storage: + err = "storage class '%s' in struct/union field"; + goto error; +dcl_expected: + err = "declaration expected"; +error: error(err, yytext); } static struct ctype *