From 87dba496160abf20557dbf102b7bc9ce4078c0d9 Mon Sep 17 00:00:00 2001 From: zinc Date: Wed, 14 Oct 2026 16:25:31 +0330 Subject: Revert "zc0: u*x, m*x, d*x are products when u, m or d is a visible local or global (spec 1.6.3)" This reverts commit 2f2597bd753fa04edc8cf51ffe9fd324965224d2. --- src/tools/zc0.c | 13 +++++-------- tests/conformance/1-source/ident_tags_global_glued_star.zc | 1 + tests/conformance/known.txt | 1 + 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/tools/zc0.c b/src/tools/zc0.c index 81561ce..2261661 100644 --- a/src/tools/zc0.c +++ b/src/tools/zc0.c @@ -238,8 +238,12 @@ static int accept(const char *s) { if (is(s)) { next(); return 1; } return 0; } static void expect(const char *s) { if (!accept(s)) { char b[64]; sprintf(b, "expected '%s'", s); die(b); } } static char *ident(void) { static char b[8][256]; static int k; char *r = b[k++ & 7]; if (tk != T_ID) die("expected a name"); strcpy(r, ts); next(); return r; } /* u, m and d are ordinary names. u*x, m*x and d*x are recasts when the star touches - the letter and no variable of that name is visible, which the raw character after the name tells: u * x is a product, and + the letter, which the raw character after the name tells: u * x is a product, and so is u*=x. the current token is the name, so pos is just past it. */ +static int isrecast(void) +{ + return tk == T_ID && ts[1] == 0 && (ts[0] == 'u' || ts[0] == 'm' || ts[0] == 'd') && src[pos] == '*' && src[pos + 1] != '='; +} /* ---- symbols ---- */ typedef struct { char name[64]; int kind, sig, defd, str; int64_t val; } Sym; /* str: a global holding a byte string, or a function returning one */ @@ -280,13 +284,6 @@ static void fnref(const char *n) /* push a function address, fixing it up later typedef struct { char name[64]; int slot, arr, flt, str, dstr; } Loc; /* dstr: declared bstr, so always a byte string */ static Loc lo[1024]; static int nlo, nslot, infn; static Loc *findl(const char *n) { int i; for (i = nlo; i--;) if (!strcmp(lo[i].name, n)) return &lo[i]; return 0; } -static int isrecast(void) -{ - Sym *g; - if (!(tk == T_ID && ts[1] == 0 && (ts[0] == 'u' || ts[0] == 'm' || ts[0] == 'd') && src[pos] == '*' && src[pos + 1] != '=')) return 0; - if (findl(ts)) return 0; /* a visible variable named u, m or d: a product (spec 1.6.3) */ - g = find(ts); return !(g && (g->kind == K_GVAR || g->kind == K_GARR)); -} static void laddr(int k) { lit(ZFP); op(O_LD); if (k) { lit(k); op(O_ADD); } } /* ---- operator tables ---- */ diff --git a/tests/conformance/1-source/ident_tags_global_glued_star.zc b/tests/conformance/1-source/ident_tags_global_glued_star.zc index 92abad4..516f9a3 100644 --- a/tests/conformance/1-source/ident_tags_global_glued_star.zc +++ b/tests/conformance/1-source/ident_tags_global_glued_star.zc @@ -5,3 +5,4 @@ void pn(int x) { rt.put_n(x); rt.put_c(10); } int u = 3; int m = 5; fn main() { int d = 4; int k = 2; pn(u*d); pn(m*k); return 0; } +// zc0: skip diff --git a/tests/conformance/known.txt b/tests/conformance/known.txt index df4c94b..22a1e3d 100644 --- a/tests/conformance/known.txt +++ b/tests/conformance/known.txt @@ -11,6 +11,7 @@ 9-appendix-b/b2_14_len_char_ptr_typecheck_off.zc zy c appendix b.2.14 confirmed, but spec 3.13.5 leaves it unspecified 9-appendix-b/b2_15_duplicate_case.zc zy c appendix b.2.15 confirmed; 4.7.2 says duplicates are allowed 9-appendix-b/b2_16_local_const_in_const_expr.zc zy c appendix b.2.16 confirmed; 3.14.2 documents it +1-source/ident_tags_as_variables_glued_star.zc zc0 b u*d with visible u and d is read as a recast (no code); zy follows 1.6.3 2-types/conv_argument_and_return.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a) 2-types/conv_assignment_to_float.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a) 2-types/conv_f32_rounds.zc zc0 b types are read and dropped: no conversion, no sized cut (appendix a) -- cgit v1.2.3