shithub: riscv

Download patch

ref: cfebef4330c5197ea1f91747c570aa2788eaae53
parent: 613fd6b4294ad3277a91c9a2e58b2b2d4f22ab1c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Mar 17 18:10:42 EDT 2023

cc: fndecls: use current fn node directly

--- a/sys/src/cmd/cc/cc.h
+++ b/sys/src/cmd/cc/cc.h
@@ -463,6 +463,7 @@
 EXTERN	int	thechar;
 EXTERN	char*	thestring;
 EXTERN	Type*	thisfn;
+EXTERN	Node*	thisfnnode;
 EXTERN	Type*	types[NTYPE];
 EXTERN	Type*	fntypes[NTYPE];
 EXTERN	Node*	initlist;
@@ -583,7 +584,7 @@
 void	edecl(int, Type*, Sym*);
 Type*	fnproto(Node*);
 Type*	fnproto1(Node*);
-void	fndecls(Node*, int);
+void	fndecls(int);
 void	markdcl(void);
 Type*	paramconv(Type*, int);
 void	pdecl(int, Type*, Sym*);
--- a/sys/src/cmd/cc/cc.y
+++ b/sys/src/cmd/cc/cc.y
@@ -82,7 +82,7 @@
 	{
 		lastdcl = T;
 		firstarg = S;
-		dodecl(xdecl, lastclass, lasttype, $2);
+		thisfnnode = dodecl(xdecl, lastclass, lasttype, $2);
 		if(lastdcl == T || lastdcl->etype != TFUNC) {
 			diag($2, "not a function");
 			lastdcl = types[TFUNC];
@@ -95,13 +95,13 @@
 	pdecl
 	{
 		argmark($2, 1);
-		fndecls($2, 0);
+		fndecls(0);
 	}
 	block
 	{
 		Node *n;
 
-		fndecls($2, 1);
+		fndecls(1);
 		n = revertdcl();
 		if(n)
 			$6 = new(OLIST, n, $6);
--- a/sys/src/cmd/cc/dcl.c
+++ b/sys/src/cmd/cc/dcl.c
@@ -732,7 +732,7 @@
 }
 
 void
-fndecls(Node *f, int pass)
+fndecls(int pass)
 {
 	static Sym *funcsym;
 	Node *n;
@@ -746,7 +746,7 @@
 		funcsym = dodecl(adecl, CLOCAL, n->type, n)->sym;
 	}else if(funcsym->aused){
 		n = new(OSTRING, Z, Z);
-		n->cstring = f->left->sym->name;
+		n->cstring = thisfnnode->sym->name;
 		n->type = copytyp(funcsym->type);
 		n->type->width = strlen(n->cstring)+1;
 		n->etype = TARRAY;