[hackers] [scc] Convert typename() to dodcl() function || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 8 Aug 2015 12:10:22 +0200 (CEST)

commit 6a8265d1262a3c63665f78a29d59d84387e8f68a
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Aug 8 12:06:11 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Aug 8 12:06:11 2015 +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!!!!

diff --git a/cc1/cc1.h b/cc1/cc1.h
index 3fbda77..e42b59b 100644
--- a/cc1/cc1.h
+++ b/cc1/cc1.h
_AT_@ -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
index 6fdad29..9a12fa1 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -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)
 {
_AT_@ -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
_AT_@ -565,3 +555,9 @@ fieldlist(Type *tp)
                 dodcl(1, field, tp->ns, tp);
         expect(';');
 }
+
+Type *
+typename(void)
+{
+ return dodcl(0, type, 0, NULL)->type;
+}
Received on Sat Aug 08 2015 - 12:10:22 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 08 2015 - 12:12:11 CEST