git: 9front

Download patch

ref: 659ea24cfbda3daae05eaeac10f494b5735320e4
parent: d238b7c348d32b72ebf1bd827364ac4b5a5c81c6
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Dec 1 17:37:14 EST 2024

cc: dont' try compiling invalid code

When we have errors in the code, passing it on to the backend
just generates cryptic or incorrect errors, and in some case,
crashes as we try to process trees with missing labels, or
which are malformed in other ways.

Instead, bail out of codgen() and don't even try.

--- a/sys/src/cmd/cc/pgen.c
+++ b/sys/src/cmd/cc/pgen.c
@@ -12,6 +12,11 @@
 	hasdoubled = 0;
 
 	/*
+	 * no point in giving invalid code to the backend.
+	 */
+	if(nerrors != 0)
+		return;
+	/*
 	 * isolate name
 	 */
 	for(n1 = nn;; n1 = n1->left) {
--