shithub: scc

Download patch

ref: bb770ea4099cb504ed4a500659d330802fb44d9d
parent: d9761479797a5050a523ab97e887de5fb7a2344a
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Feb 18 07:18:01 EST 2017

[tests] Update scc-tests.lst after cd855

--- a/cc1/decl.c
+++ b/cc1/decl.c
@@ -17,7 +17,7 @@
 
 
 struct declarators {
-	unsigned char nr;
+	unsigned char nr, ns;
 	struct declarator {
 		unsigned char op;
 		TINT  nelem;
@@ -272,10 +272,13 @@
 fundcl(struct declarators *dp)
 {
 	Type *types[NR_FUNPARAM], type;
-	Symbol *syms[NR_FUNPARAM+1], **pars;
+	Symbol *sym, *syms[NR_FUNPARAM+1], **pars;
 	int k_r, ntypes, nsyms;
 	size_t size;
 
+	sym = dp->d[0].sym;
+	if ((sym->flags&SDECLARED) == 0)
+		install(dp->ns, sym);
 	pushctx();
 	expect('(');
 	type.n.elem = 0;
@@ -748,8 +751,9 @@
 		errorp("declared variable '%s' of incomplete type", name);
 	}
 
-	sym = install(NS_IDEN, sym);
-	if (tp->op == FTN) {
+	if (tp->op != FTN) {
+		sym = install(NS_IDEN, sym);
+	} else {
 		if (sclass == NOSCLASS)
 			sclass = EXTERN;
 		if (!strcmp(name, "main") && tp->type != inttype) {
@@ -756,6 +760,14 @@
 			errorp("main shall be defined with a return type of int");
 			errorp("please contact __20h__ on irc.freenode.net (#bitreich-en) via IRC");
 		}
+		/*
+		 * function identifiers are installed in fundcl() because
+		 * we have to add a context for the parameters, and if we
+		 * delay the install until here then we will install the
+		 * symbol of the function after the parameters.
+		 */
+		if ((sym->flags&SEMITTED) != 0)
+			sym = NULL;
 	}
 
 	if (sym == NULL) {
@@ -817,6 +829,7 @@
 
 	do {
 		stack.nr = 0;
+		stack.ns = ns;
 		dcl.pars = NULL;
 		dcl.type = base;
 
@@ -852,7 +865,8 @@
 	 * against GLOBALCTX+1
 	 */
 	if (curctx != GLOBALCTX+1 || yytoken == ';') {
-		emit(ODECL, sym);
+		if (!(sym->flags & SEMITTED))
+			emit(ODECL, sym);
 		/*
 		 * avoid non used warnings in prototypes
 		 */
--- a/tests/execute/scc-tests.lst
+++ b/tests/execute/scc-tests.lst
@@ -94,7 +94,7 @@
 0099-tentative.c
 0102-bug.c
 0103-voidparm.c
-0104-voidparm.c
+0104-qbebug.c
 0105-shl.c
 0106-ppcast.c
 0107-bnot.c