shithub: front

Download patch

ref: 051804186780ef7f3b2f4cb548be1dd0685de5fe
parent: 7d13427ccf1f9bcf934a13d3bc9633c07f2ce6e3
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) {
--