diff options
| author | 2026-03-14 17:27:37 +0100 | |
|---|---|---|
| committer | 2026-03-14 17:46:54 +0100 | |
| commit | 42ce457bba06bd3607fc04700a919b6c395f22c3 (patch) | |
| tree | 77a3f2230324248055a69a41d12b18471d56fe4f /test | |
| parent | 1f3ebe69478f245f69cd6f77db946226557085d2 (diff) | |
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
Diffstat (limited to 'test')
| -rw-r--r-- | test/17-misc.c | 14 |
1 files changed, 14 insertions, 0 deletions
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 <stddef.h> +#include <stdint.h> +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 <assert.h> 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])); } |