scc

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

commit cf5c3a1d54e206326de7e2a7b9e12f6c179e866e
parent 5e00eb6985f2f280a7f4edc260bd0f6d0760faec
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  5 Jul 2013 09:01:53 +0200

Move type default warning to the correct place

spec() was filling the type field in ctype structure, so was
impossible other part of the code could emit some message due to
this issue.

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

diff --git a/decl.c b/decl.c @@ -121,8 +121,11 @@ spec(void) } } default: - if (tp && !tp->type && sign) - tp->type = INT; + if (!tp || tp->type) + return tp; + warning_error(options.implicit, + "type defaults to 'int' in declaration"); + tp->type = INT; return tp; } } @@ -192,11 +195,6 @@ listdcl(struct ctype *base) declarator(tp); tp = decl_type(base); - if (!tp->type) { - warning_error(options.implicit, - "type defaults to 'int' in declaration of '%s'", - yytext); - } (cursym->ctype = tp)->refcnt++; sp = nodesym(cursym); if (tp->type == FTN && yytoken == '{') {