shithub: riscv

Download patch

ref: 0ab44a0062e93be29ad2bff0c3243bc0d7b45845
parent: bac935c71ff62c18a44b4268e787284a1b205462
author: Jacob Moody <moody@posixcafe.org>
date: Mon Apr 29 17:31:05 EDT 2024

9c: copy warning from other compilers regarding pointer -> int truncation

--- a/sys/src/cmd/9c/cgen.c
+++ b/sys/src/cmd/9c/cgen.c
@@ -476,6 +476,10 @@
 			cgen(l, nn);
 			break;
 		}
+		if(ewidth[n->type->etype] < ewidth[l->type->etype]){
+			if(l->type->etype == TIND && typechlp[n->type->etype])
+				warn(n, "conversion of pointer to shorter integer");
+		}
 		regalloc(&nod, l, nn);
 		cgen(l, &nod);
 		regalloc(&nod1, n, &nod);