scc

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

commit 6a8265d1262a3c63665f78a29d59d84387e8f68a
parent 3e8227a60580f6542a8fccc18fd8716c887ba1b7
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat,  8 Aug 2015 12:06:11 +0200

Convert typename() to dodcl() function

Al the functions which need a declaration are used dodcl(),
except typename(). This patch makes the code more orthogonal
and remove 3 lines!!!!

Diffstat:
Mcc1/cc1.h | 2+-
Mcc1/decl.c | 20++++++++------------
2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/cc1/cc1.h b/cc1/cc1.h @@ -114,7 +114,7 @@ enum { /* namespaces */ enum { - NS_IDEN, + NS_IDEN = 1, NS_TAG, NS_LABEL, NS_CPP, diff --git a/cc1/decl.c b/cc1/decl.c @@ -84,7 +84,6 @@ static Symbol *dodcl(int rep, void (*fun)(Symbol *, int, Type *), uint8_t ns, Type *type); -/* FIXME: what happens with the context in int (*f)(int)[];? */ static struct dcldata * fundcl(struct dcldata *dp) { @@ -421,22 +420,13 @@ enumdcl(void) return tp; } -Type * -typename(void) +static void +type(Symbol *sym, int sclass, Type *data) { - unsigned sclass; - Type *tp; - Symbol *sym; - - tp = specifier(&sclass); if (sclass) error("class storage in type name"); - sym = declarator(tp, NS_IDEN); - if (!sym->name) error("unexpected identifier in type name"); - - return sym->type; } static void @@ -565,3 +555,9 @@ fieldlist(Type *tp) dodcl(1, field, tp->ns, tp); expect(';'); } + +Type * +typename(void) +{ + return dodcl(0, type, 0, NULL)->type; +}