scc

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

commit a31573bf6a292f30bd578285aff5da9652931579
parent e288e44926d1cb8f0f7c3b837466698007a95c5d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 31 Oct 2013 21:02:07 +0100

Simplify the type checking in specifier

Doesn't matter if the type is int by default or if it hasn't
storage or qualifier. The important is the default type.

Diffstat:
decl.c | 17++++++-----------
types.c | 5++++-
2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/decl.c b/decl.c @@ -217,19 +217,14 @@ specifier(register struct ctype *tp, } /* it is not a type name */ default: - check_type: - /* TODO: simplify this checks */ - if (!tp->defined && !store->defined && !qlf->defined) { - /* TODO: Allow no type in structs and union */ - if (curctx != CTX_OUTER || yytoken != IDEN) + if (!tp->defined) { + if (!store->defined && + !qlf->defined && + curctx != CTX_OUTER ) { return false; - store->c_auto = false; - warn(options.implicit, - "data definition has no type or storage class"); - } else if (!tp->defined) { + } warn(options.implicit, - "type defaults to 'int' in declaration"); - tp = ctype(tp, INT); + "type defaults to 'int' in declaration"); } if (!tp->c_signed && !tp->c_unsigned) { switch (tp->type) { diff --git a/types.c b/types.c @@ -31,8 +31,11 @@ initctype(register struct ctype *tp) struct storage * initstore(register struct storage *store) { + extern unsigned char curctx; memset(store, 0, sizeof(*store)); - store->c_auto = 1; + + if (curctx != CTX_OUTER) + store->c_auto = 1; return store; }