diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 13:56:44 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 13:56:44 +0000 |
| commit | 312a19c781da1c31ff1e3dc71c319663a8be9148 (patch) | |
| tree | 80d63213c0d11b1fcf3d67ef6e51289fe4b5096e /tests/i/extern-c-struct/program.cps | |
| parent | 5eccd90b47b327917ad0e5858c79ca8fab27cd74 (diff) | |
feat(codegen): accept pointer types to any C type in EXTERN
A pseudocode pointer type now counts as a C type, in EXTERN signatures
and as a C-struct field, when it finally points to a non-void C type or a
C struct, as in TYPE PInt = ^C_INT. A pointer cycle such as TYPE P = ^P
and a pointer to a pseudocode type stay rejected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/extern-c-struct/program.cps')
| -rw-r--r-- | tests/i/extern-c-struct/program.cps | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/i/extern-c-struct/program.cps b/tests/i/extern-c-struct/program.cps index bcb7af4..62370d3 100644 --- a/tests/i/extern-c-struct/program.cps +++ b/tests/i/extern-c-struct/program.cps @@ -1,4 +1,4 @@ -// Records whose fields are C types pass to C functions through pointer types. +// Records whose fields are C types, and pointer types to C types, pass to C functions. INCLUDE_OBJ "lib.o" TYPE Sample DECLARE Tag : C_CHAR @@ -6,13 +6,25 @@ TYPE Sample DECLARE Count : C_INT ENDTYPE TYPE PSample = ^Sample +TYPE PPSample = ^PSample +TYPE PInt = ^C_INT +TYPE Counter + DECLARE Target : PInt +ENDTYPE +TYPE PCounter = ^Counter EXTERN "C" EXTERN_PROCEDURE scale_sample(PSample, C_INT) EXTERN "C" EXTERN_FUNCTION shared_sample() RETURNS PSample EXTERN "C" EXTERN_FUNCTION shared_count() RETURNS C_INT EXTERN "C" EXTERN_FUNCTION sum_counts(C_INT, ...) RETURNS C_INT +EXTERN "C" EXTERN_PROCEDURE bump(PInt) +EXTERN "C" EXTERN_PROCEDURE bump_counter(PCounter) +EXTERN "C" EXTERN_PROCEDURE get_shared(PPSample) DECLARE S : Sample DECLARE P : PSample DECLARE Q : PSample +DECLARE R : PSample +DECLARE N : C_INT +DECLARE C : Counter S.Tag <- (C_CHAR)'S' S.Value <- (C_DOUBLE)1.5 S.Count <- (C_INT)5 @@ -24,3 +36,10 @@ P^.Count <- (C_INT)9 OUTPUT shared_count() Q <- ^S OUTPUT sum_counts((C_INT)2, P, Q) +N <- (C_INT)1 +CALL bump(^N) +C.Target <- ^N +CALL bump_counter(^C) +OUTPUT N +CALL get_shared(^R) +OUTPUT R^.Tag, " ", R^.Count |
