shithub: riscv

Download patch

ref: 069fd98950440119fef047c09e8816e1e1601319
parent: caec06be08d80ed5c6d99367604dbba006d6013f
author: cinap_lenrek <[email protected]>
date: Fri Dec 29 11:38:04 EST 2023

?c: fix nodret check

we used to compare the symbol to nodret->s to see if
we got the return pointer, but this is wrong as
nodret is a OIND, pointing to a ONAME and therefore
sym would be nil.

instead, just compare the symbol string to ".ret".

--- a/sys/src/cmd/2c/reg.c
+++ b/sys/src/cmd/2c/reg.c
@@ -617,7 +617,7 @@
 		v++;
 	}
 	if(s)
-		if(s->name[0] == '.' && s != nodret->sym)
+		if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 			goto none;
 	if(nvar >= NVAR) {
 		if(debug['w'] > 1 && s)
--- a/sys/src/cmd/5c/reg.c
+++ b/sys/src/cmd/5c/reg.c
@@ -585,7 +585,7 @@
 		v++;
 	}
 	if(s)
-		if(s->name[0] == '.' && s != nodret->sym)
+		if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 			goto none;
 	if(nvar >= NVAR) {
 		if(debug['w'] > 1 && s)
--- a/sys/src/cmd/6c/reg.c
+++ b/sys/src/cmd/6c/reg.c
@@ -752,7 +752,7 @@
 	s = a->sym;
 	if(s == S)
 		goto none;
-	if(s->name[0] == '.' && s != nodret->sym)
+	if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 		goto none;
 	et = a->etype;
 	o = a->offset;
--- a/sys/src/cmd/7c/reg.c
+++ b/sys/src/cmd/7c/reg.c
@@ -584,7 +584,7 @@
 		v++;
 	}
 	if(s)
-		if(s->name[0] == '.' && s != nodret->sym)
+		if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 			goto none;
 	if(nvar >= NVAR) {
 		if(debug['w'] > 1 && s)
--- a/sys/src/cmd/8c/reg.c
+++ b/sys/src/cmd/8c/reg.c
@@ -682,7 +682,7 @@
 	s = a->sym;
 	if(s == S)
 		goto none;
-	if(s->name[0] == '.' && s != nodret->sym)
+	if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 		goto none;
 	o = a->offset;
 	v = var;
--- a/sys/src/cmd/cc/pgen.c
+++ b/sys/src/cmd/cc/pgen.c
@@ -27,7 +27,7 @@
 	sp = p;
 
 	if(typecmplx[thisfn->link->etype]) {
-		if(nodret == nil) {
+		if(nodret == Z) {
 			nodret = new(ONAME, Z, Z);
 			nodret->sym = slookup(".ret");
 			nodret->class = CPARAM;
--- a/sys/src/cmd/qc/gc.h
+++ b/sys/src/cmd/qc/gc.h
@@ -150,7 +150,6 @@
 EXTERN	Node*	nodrat;
 EXTERN	Node*	nodret;
 EXTERN	Node*	nodsafe;
-EXTERN	Node*	nodretv;
 EXTERN	long	nrathole;
 EXTERN	long	nstring;
 EXTERN	Prog*	p;
--- a/sys/src/cmd/qc/reg.c
+++ b/sys/src/cmd/qc/reg.c
@@ -545,7 +545,7 @@
 		v++;
 	}
 	if(s)
-		if(s->name[0] == '.')
+		if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 			goto none;
 	if(nvar >= NVAR) {
 		if(debug['w'] > 1 && s)
--- a/sys/src/cmd/qc/txt.c
+++ b/sys/src/cmd/qc/txt.c
@@ -65,6 +65,14 @@
 	nodsafe->class = CAUTO;
 	complex(nodsafe);
 
+	nodret = new(ONAME, Z, Z);
+	nodret->sym = slookup(".ret");
+	nodret->type = types[TIND];
+	nodret->etype = TIND;
+	nodret->class = CPARAM;
+	nodret = new(OIND, nodret, Z);
+	complex(nodret);
+
 	t = typ(TARRAY, types[TCHAR]);
 	symrathole = slookup(".rathole");
 	symrathole->class = CGLOBL;
--- a/sys/src/cmd/vc/reg.c
+++ b/sys/src/cmd/vc/reg.c
@@ -575,7 +575,7 @@
 		v++;
 	}
 	if(s)
-		if(s->name[0] == '.' && s != nodret->sym)
+		if(s->name[0] == '.' && strcmp(s->name, ".ret") != 0)
 			goto none;
 	if(nvar >= NVAR) {
 		if(debug['w'] > 1 && s)