shithub: riscv

Download patch

ref: ee93b99842546dc501a383e06fd0ba4af904e150
parent: 38ea1ac105f4484f02bba3bfbc790ebe4f18f016
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Aug 16 21:28:05 EDT 2023

6c: fix embedded struct conversion codegen

With code like:

	struct Foo{ int x; }
	struct Aggr{ int a; Foo; }

it's possible to assign to the Foo in the Aggr:

	Foo x = someaggr();

when removing the rathole, the code to adjust
the offset in this case was lost; bring it
back.

--- a/sys/src/cmd/6c/cgen.c
+++ b/sys/src/cmd/6c/cgen.c
@@ -1024,6 +1024,8 @@
 			diag(n, "DOT and no offset");
 			break;
 		}
+		nod1.xoffset += (long)r->vconst;
+		nod1.type = n->type;
 		cgen(&nod, nn);
 		break;
 
@@ -1430,6 +1432,8 @@
 			diag(n, "DOT and no offset");
 			break;
 		}
+		nod1.xoffset += (long)r->vconst;
+		nod1.type = n->type;
 		sugen(&nod1, nn, w);
 		break;