aboutsummaryrefslogtreecommitdiff
path: root/tests/i/extern-c-struct-value/program.cps
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-22 13:51:44 +0000
committer_ov4 <ov4@ov4.org>2026-10-22 13:51:44 +0000
commit5eccd90b47b327917ad0e5858c79ca8fab27cd74 (patch)
tree56e5c4110560679047e8813ab221742a0ab739f6 /tests/i/extern-c-struct-value/program.cps
parente3cc6c585a15fe4478dd2312bf5d390896729a31 (diff)
feat(codegen): pass C-struct records by value as variadic arguments
A variadic EXTERN call is now arranged by clang per call, from the fixed parameter count and the promoted argument types. C-struct records pass unchanged in variadic positions, as C11 6.5.2.2p6-7 and 7.16.1.1p2 allow; a record that is not a C struct names the offending field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/extern-c-struct-value/program.cps')
-rw-r--r--tests/i/extern-c-struct-value/program.cps9
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/i/extern-c-struct-value/program.cps b/tests/i/extern-c-struct-value/program.cps
index 6b2cb8e..c8b3a1f 100644
--- a/tests/i/extern-c-struct-value/program.cps
+++ b/tests/i/extern-c-struct-value/program.cps
@@ -1,4 +1,5 @@
-// Records whose fields are C types pass to and return from C functions by value.
+// Records whose fields are C types pass to and return from C functions by
+// value, also as variadic arguments.
INCLUDE_OBJ "lib.o"
TYPE CShort = C_TYPE("short")
TYPE CFloat = C_TYPE("float")
@@ -34,10 +35,13 @@ EXTERN "C" EXTERN_FUNCTION make_pair(C_INT, C_INT) RETURNS Pair
EXTERN "C" EXTERN_FUNCTION make_vec2(C_DOUBLE, C_DOUBLE) RETURNS Vec2
EXTERN "C" EXTERN_FUNCTION make_mixed(C_CHAR, C_DOUBLE, C_INT) RETURNS Mixed
EXTERN "C" EXTERN_FUNCTION make_vec3f(CFloat, CFloat, CFloat) RETURNS Vec3f
+EXTERN "C" EXTERN_FUNCTION sum_vec2(C_INT, ...) RETURNS C_DOUBLE
+EXTERN "C" EXTERN_FUNCTION mixed_counts(C_INT, ...) RETURNS C_INT
DECLARE P : Pair
DECLARE U : Vec2
DECLARE V : Vec2
DECLARE M : Mixed
+DECLARE N : Mixed
DECLARE F : Vec3f
DECLARE W : Wide
P.A <- (C_INT)3
@@ -68,3 +72,6 @@ M <- make_mixed((C_CHAR)'Q', (C_DOUBLE)0.25, (C_INT)9)
OUTPUT M.Tag, " ", M.Value, " ", M.Count
F <- make_vec3f((CFloat)0.5, (CFloat)1.25, (CFloat)2)
OUTPUT F.X, " ", F.Y, " ", F.Z
+OUTPUT sum_vec2((C_INT)2, U, V)
+N <- make_mixed((C_CHAR)'R', (C_DOUBLE)1, (C_INT)5)
+OUTPUT mixed_counts((C_INT)2, M, N)