shithub: scc

Download patch

ref: e7de88b1568b84cdd7c18b3149d7e17f8686763b
parent: 65a354524234ab1bc797faadd25dc30fc02b6a9a
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Oct 30 10:03:31 EDT 2021

cc1: Fix initialization of type for 0 and 1

The constants 0 and 1 are defined to have integer type,
but the integer type was not tet initialized at that
moment, making that the type of these constants was
a null pointer.

--- a/src/cmd/cc/cc1/amd64-sysv.c
+++ b/src/cmd/cc/cc1/amd64-sysv.c
@@ -200,8 +200,6 @@
 	arch.va_list_type = *mktype(&arch.va_type, ARY, 1, NULL);
 	arch.pvoidtype.type = &arch.chartype;
 	arch.valid_va_list = local_valid_va_list;
-	arch.zero.type = inttype;
-	arch.one.type = inttype;
 
 	return &arch;
 }
--- a/src/cmd/cc/cc1/arch.c
+++ b/src/cmd/cc/cc1/arch.c
@@ -80,4 +80,7 @@
 	va_type = &arch->va_type;
 	zero = &arch->zero;
 	one = &arch->one;
+
+	zero->type = inttype;
+	one->type = inttype;
 }
--- a/src/cmd/cc/cc1/z80-scc.c
+++ b/src/cmd/cc/cc1/z80-scc.c
@@ -205,8 +205,6 @@
 	arch.valid_va_list = local_valid_va_list;
 	arch.pvoidtype.type = &arch.chartype;
 	arch.va_type.type = &arch.inttype;
-	arch.zero.type = inttype;
-	arch.one.type = inttype;
 
 	return &arch;
 }