git: 9front

Download patch

ref: e38b748d43560b0f8bd5e02e1e8ca6c43fd21777
parent: dcd241e8497b68c23dde812f9cd85f5d08f990a9
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;
 
--