scc

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

commit 228c8810099047f20e7db5a1106cdca70a009890
parent 6e2151255c39198d662f840b44f6cbe74412d39e
Author: Roberto E. Vargas Caballero <k0ga@shike2.net>
Date:   Tue, 28 Apr 2026 11:02:23 +0200

tests/cc: Add 0270-union

Diffstat:
Mtests/cc/execute/.gitignore | 1+
Atests/cc/execute/0270-union.c | 45+++++++++++++++++++++++++++++++++++++++++++++
Mtests/cc/execute/scc-tests.lst | 1+
3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/tests/cc/execute/.gitignore b/tests/cc/execute/.gitignore @@ -2,3 +2,4 @@ test.log tests.h tmp_*.c a.out +0270-union diff --git a/tests/cc/execute/0270-union.c b/tests/cc/execute/0270-union.c @@ -0,0 +1,45 @@ +typedef unsigned int sigset_t ; +typedef struct siginfo siginfo_t ; + +struct sigaction { + union { + void (*__sa_handler)(int); + void (*__sa_sigaction)(int, siginfo_t *, void *) ; + } __sigaction_u ; + + sigset_t sa_mask ; + int sa_flags ; +}; + +int +_sigaction(int num, struct sigaction *sa, struct sigaction *osa) +{ + return num != 3 ? -1 : 0; +} + +void +(*signal(int signum, void (* func) (int)))(int) +{ + struct sigaction osa , sa = { + .__sigaction_u.__sa_handler = func, + }; + + if (_sigaction(signum, &sa, &osa ) < 0 ) + return ((void (*)(int)) -1) ; + + return osa.__sigaction_u.__sa_handler ; +} + +void +sighdl(int signo) +{ + return 0; +} + +int +main(void) +{ + signal(3, sighdl); + + return 0; +} diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst @@ -260,3 +260,4 @@ 0267-wchar.c 0268-string.c 0269-extern.c +0270-union.c