scc

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

commit fb4ba8fbc3b6a16658a37b59b2f227ccf1781983
parent e997cb43bb38636bd3df72ec96e066879dec7852
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Tue, 31 Mar 2026 10:29:24 +0200

cc1: Don't change signess of decimal constants

The commit 24bd7b7d tried to fix an issue with the test for limits.h
where a decimal constant could not be represented using a normal decimal
constant. While the change did something right, because it moved from
long long to unsigned long long it did it for any kind of constant,
but that movement should be done only for octal or hexadecimal
constants.

Diffstat:
Msrc/cmd/scc-cc/cc1/lex.c | 2+-
Mtests/cc/execute/0253-maxconst.c | 7++++++-
Mtests/libc/execute/0006-limits.c | 4++--
3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/cmd/scc-cc/cc1/lex.c b/src/cmd/scc-cc/cc1/lex.c @@ -374,7 +374,7 @@ 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) + else if (tp == llongtype && base != 10) tp = ullongtype; else goto overflow; diff --git a/tests/cc/execute/0253-maxconst.c b/tests/cc/execute/0253-maxconst.c @@ -3,5 +3,10 @@ main(void) { unsigned long long u = 18446744073709551615ull; - return !(u == 18446744073709551615u); + if (u != 18446744073709551615u) + return 1; + if (u != 0xFFFFFFFFFFFFFFFF) + return 2; + + return 0; } diff --git a/tests/libc/execute/0006-limits.c b/tests/libc/execute/0006-limits.c @@ -57,7 +57,7 @@ test1() if (LONG_MAX < 9223372036854775807 || LONG_MIN > -9223372036854775807 || - ULONG_MAX < 18446744073709551615 || ULONG_MAX <= 0 || + ULONG_MAX < 18446744073709551615u || ULONG_MAX <= 0 || LONG_MAX < SCHAR_MAX || LONG_MIN > SCHAR_MIN || ULONG_MAX < UCHAR_MAX || LONG_MAX < SHRT_MAX || LONG_MIN > SHRT_MIN || @@ -68,7 +68,7 @@ test1() if (LLONG_MAX < 9223372036854775807 || LLONG_MIN > -9223372036854775807 || - ULLONG_MAX < 18446744073709551615 || ULLONG_MAX <= 0 || + ULLONG_MAX < 18446744073709551615u || ULLONG_MAX <= 0 || LLONG_MAX < SCHAR_MAX || LLONG_MIN > SCHAR_MIN || ULLONG_MAX < UCHAR_MAX || LLONG_MAX < SHRT_MAX || LLONG_MIN > SHRT_MIN ||