From 42ce457bba06bd3607fc04700a919b6c395f22c3 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 14 Mar 2026 17:27:37 +0100 Subject: c: static eval refactoring Explicit node for static symbol (addresses). Should not break with edge cases like the previous ad-hoc approach. And some other bugfixes --- test/17-misc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/17-misc.c b/test/17-misc.c index 521b948..ffd2470 100644 --- a/test/17-misc.c +++ b/test/17-misc.c @@ -26,7 +26,21 @@ _Static_assert(__is_constexpr(5 &&(1<<3) || 0/0), ""); _Static_assert(!__is_constexpr(5/0), ""); _Static_assert(!__is_constexpr(fn1(0)), ""); +#include +#include +struct foo { int *a, b[2]; }; +static intptr_t offst[] = { + (long)((struct foo *)0)->b, + (long)&((struct foo *)0)->a, + (long)&((struct foo *)0)->b[1], + (intptr_t)("12" - 5) +}; + extern int printf(const char *, ...); +#include int main() { printf("%d\n", fn1(-77ull)); + assert(offst[0] == offsetof(struct foo, b)); + assert(offst[1] == offsetof(struct foo, a)); + assert(offst[2] == offsetof(struct foo, b[1])); } -- cgit v1.2.3