scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 24bd7b7da52f8606e5c5a8086c6b731d95154412
parent 787ffacf2b35fb9a3a77c6c6053d5d96d6a3766f
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Fri, 27 Mar 2026 09:47:27 +0100

cc1: Promote constants from llong to ullong

When a constant does not fit in a long long value then it must be
promoted to unsigned long long.

Diffstat:
Msrc/cmd/scc-cc/cc1/lex.c | 2++
Atests/cc/execute/0253-maxconst.c | 7+++++++
Mtests/cc/execute/scc-tests.lst | 1+
3 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/cmd/scc-cc/cc1/lex.c b/src/cmd/scc-cc/cc1/lex.c @@ -374,6 +374,8 @@ readint(int base, int sign, Symbol *sym) tp = (base==10) ? longtype : uinttype; else if (tp == longtype) tp = (base==10) ? llongtype : ulongtype; + else if (tp == llongtype) + tp = ullongtype; else goto overflow; } else { diff --git a/tests/cc/execute/0253-maxconst.c b/tests/cc/execute/0253-maxconst.c @@ -0,0 +1,7 @@ +int +main(void) +{ + unsigned long long u = 18446744073709551615ull; + + return !(u == 18446744073709551615); +} diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst @@ -243,3 +243,4 @@ 0250-div.c 0251-mul.c 0252-literal.c +0253-maxconst.c