[hackers] [scc] Avoid emit prototype before of function definition || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 15 Aug 2015 23:27:07 +0200 (CEST)

commit 3afef127c2996c8be4c24136f105ddebdbd0a437
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Aug 15 12:33:04 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Aug 15 12:33:04 2015 +0200

    Avoid emit prototype before of function definition

diff --git a/cc1/decl.c b/cc1/decl.c
index 145d105..aa4fd86 100644
--- a/cc1/decl.c
+++ b/cc1/decl.c
_AT_@ -619,7 +619,7 @@ identifier(struct decl *dcl)
         /* TODO: disallow initializators in functions */
         /* TODO: check if typedef has initializer */
         /* TODO: check if the variable is extern and has initializer */
- if (sym->token == IDEN)
+ if (sym->token == IDEN && sym->type->op != FTN)
                 emit(ODECL, sym);
         return sym;
 
_AT_@ -684,7 +684,7 @@ decl(void)
          */
         if (sym->type->op == FTN) {
                 if (curctx != GLOBALCTX+1)
- goto remove_pars;
+ goto prototype;
 
                 switch (yytoken) {
                 case '{':
_AT_@ -710,7 +710,8 @@ decl(void)
                         curfun = NULL;
                         return;
                 default:
- remove_pars:
+ prototype:
+ emit(ODECL, sym);
                         free(sym->u.pars);
                         popctx();
                 }
diff --git a/cc1/tests/test001.c b/cc1/tests/test001.c
index ce17819..4e94677 100644
--- a/cc1/tests/test001.c
+++ b/cc1/tests/test001.c
_AT_@ -5,7 +5,6 @@ output:
 F3 P
 X1 F3 printf
 F1
-X2 F1 main
 G2 F1 main {
 -
         X1 "68656C6C6F20776F726C640A aP pP cI
diff --git a/cc1/tests/test002.c b/cc1/tests/test002.c
index e739445..f39497c 100644
--- a/cc1/tests/test002.c
+++ b/cc1/tests/test002.c
_AT_@ -4,7 +4,6 @@ description: Test forward references before definition of types
 output:
 G4 P x
 F1
-X6 F1 main
 G6 F1 main {
 -
 S2 S (
diff --git a/cc1/tests/test003.c b/cc1/tests/test003.c
index f2c547d..d1fad25 100644
--- a/cc1/tests/test003.c
+++ b/cc1/tests/test003.c
_AT_@ -3,17 +3,14 @@ name: TEST003
 description: Select function to call inside ternary operator
 output:
 F1
-X1 F1 foo
 G1 F1 foo {
 -
         yI #I2A
 }
-X2 F1 bar
 G2 F1 bar {
 -
         yI #I18
 }
-X3 F1 main
 G3 F1 main {
 -
         yI G1 cI
diff --git a/cc1/tests/test004.c b/cc1/tests/test004.c
index 292b71a..de4583d 100644
--- a/cc1/tests/test004.c
+++ b/cc1/tests/test004.c
_AT_@ -3,7 +3,6 @@ name: TEST004
 description: Test integer operations
 output:
 F1
-X1 F1 main
 G1 F1 main {
 -
 A2 I x
diff --git a/cc1/tests/test005.c b/cc1/tests/test005.c
index f90e65a..eb80573 100644
--- a/cc1/tests/test005.c
+++ b/cc1/tests/test005.c
_AT_@ -3,7 +3,6 @@ name: TEST005
 description: Test unary integer operations
 output:
 F1
-X1 F1 main
 G1 F1 main {
 -
 A2 I x
diff --git a/cc1/tests/test006.c b/cc1/tests/test006.c
index 529f135..b1fa74d 100644
--- a/cc1/tests/test006.c
+++ b/cc1/tests/test006.c
_AT_@ -2,12 +2,11 @@
 name: TEST006
 description: Basic test for if
 output:
-test006.c:42: warning: conditional expression is constant
-test006.c:44: warning: conditional expression is constant
-test006.c:47: warning: conditional expression is constant
+test006.c:41: warning: conditional expression is constant
+test006.c:43: warning: conditional expression is constant
+test006.c:46: warning: conditional expression is constant
 G1 M c
 F1
-X2 F1 main
 G2 F1 main {
 -
         j L2 #I0
Received on Sat Aug 15 2015 - 23:27:07 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 15 2015 - 23:36:17 CEST