commit 9ef7864a898be6b779d7ff1981227999c213f9e6
Author:     FRIGN <[email protected]>
AuthorDate: Tue May 17 17:06:13 2016 +0200
Commit:     FRIGN <[email protected]>
CommitDate: Tue May 17 17:09:18 2016 +0200

    Re-add rtype-field to Symbol-type
    
    The global rtype worked previously, but now we have not only one return
    type. So we move that one back into the Symbol-type.
    
    "Hay un cierto placer en la locura, que solo el loco conoce."
       - Pablo Neruda

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 99624fc..5c88ce1 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -303,7 +303,7 @@ writeout(void)
 
        if (curfun->kind == SGLOB)
                fputs("export ", stdout);
-       printf("function %s %s(", size2asm(&rtype), symname(curfun));
+       printf("function %s %s(", size2asm(&curfun->rtype), symname(curfun));
 
        /* declare formal parameters */
        for (sep = "", p = locals; p; p = p->next, sep = ",") {
diff --git a/cc2/cc2.h b/cc2/cc2.h
index 4dbbd45..b73a6da 100644
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -133,6 +133,7 @@ struct type {
 
 struct symbol {
        Type type;
+       Type rtype;
        unsigned short id;
        unsigned short numid;
        char *name;
@@ -223,7 +224,6 @@ extern void pushctx(void);
 extern void freesym(Symbol *sym);
 
 /* globals */
-extern Type rtype;
 extern Symbol *curfun;
 extern Symbol *locals;
 extern Inst *pc, *prog;
diff --git a/cc2/node.c b/cc2/node.c
index 4120869..8c7e024 100644
--- a/cc2/node.c
+++ b/cc2/node.c
@@ -11,7 +11,6 @@
 
 Node *curstmt;
 Symbol *curfun;
-Type rtype;
 
 struct arena {
        Node *mem;
diff --git a/cc2/parser.c b/cc2/parser.c
index fdc1513..2ba511e 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -513,7 +513,7 @@ vardecl(void)
        sym->name = name;
        sym->type = *tp;
        if (tp->flags & FUNF)
-               rtype = *rp;
+               sym->rtype = *rp;
        sym->kind = sclass;
 
        if (ininit)

Reply via email to