commit 7dbb2d53125f9592cf579c0e948c56eb886a8a3c
parent 8e07fdb59f3eaca0e5e8ad160f4d2ae37270360e
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date: Thu, 29 Jan 2026 20:22:24 +0100
cc1: Use int for namespaces
The code in decl.c was protecting against overflow using INT_MAX,
but the Symbols and types were using unsigned char or char, that
made mismatching when the lookup was performed.
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/cmd/scc-cc/cc1/cc1.h b/src/cmd/scc-cc/cc1/cc1.h
@@ -312,7 +312,7 @@ struct builtin {
struct type {
unsigned char op; /* type builder operator */
- unsigned char ns; /* namespace for struct members */
+ int ns; /* namespace for struct members */
short id; /* type id, used in dcls */
char letter; /* letter of the type */
unsigned char prop; /* type properties */
@@ -335,7 +335,7 @@ struct type {
struct symbol {
unsigned char ctx;
unsigned char hide;
- char ns;
+ int ns;
unsigned short id;
unsigned short flags;
char *name;
diff --git a/src/cmd/scc-cc/cc1/decl.c b/src/cmd/scc-cc/cc1/decl.c
@@ -751,7 +751,7 @@ newtag(void)
{
Symbol *sym;
int ns, op, tag = yylval.token;
- static unsigned tpns = NS_STRUCTS;
+ static int tpns = NS_STRUCTS;
ns = namespace;
namespace = NS_TAG;