ref: 6a8265d1262a3c63665f78a29d59d84387e8f68a
parent: 3e8227a60580f6542a8fccc18fd8716c887ba1b7
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Aug 8 08:06:11 EDT 2015
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!!!!
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
@@ -114,7 +114,7 @@
/* namespaces */
enum {
- NS_IDEN,
+ NS_IDEN = 1,
NS_TAG,
NS_LABEL,
NS_CPP,
--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -84,7 +84,6 @@
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 @@
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
@@ -564,4 +554,10 @@
if (yytoken != ';')
dodcl(1, field, tp->ns, tp);
expect(';');
+}
+
+Type *
+typename(void)
+{
+ return dodcl(0, type, 0, NULL)->type;
}