From f694cc443ccc17a494cd195151882ab5e491bbb2 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 13:59:48 +0000 Subject: feat(codegen): accept ^x of C values as variadic arguments In a variadic EXTERN position, ^x now passes the address of x as a plain pointer when x has a C type or is a C struct, like C's f(n, &x). The address of a pseudocode-typed value keeps the "must be a C value" error. Co-Authored-By: Claude Opus 5.5 --- tests/iii/extern-variadic-type/case.json | 4 ++++ tests/iii/extern-variadic-type/notes.md | 4 ++-- tests/iii/extern-variadic-type/program.cps | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/iii') diff --git a/tests/iii/extern-variadic-type/case.json b/tests/iii/extern-variadic-type/case.json index 45fea44..a114299 100644 --- a/tests/iii/extern-variadic-type/case.json +++ b/tests/iii/extern-variadic-type/case.json @@ -3,6 +3,10 @@ { "reason": "Variadic\\ argument\\ 2\\ to\\ printf\\ must\\ be\\ a\\ C\\ value", "line": 5 + }, + { + "reason": "Variadic\\ argument\\ 2\\ to\\ printf\\ must\\ be\\ a\\ C\\ value", + "line": 7 } ] } diff --git a/tests/iii/extern-variadic-type/notes.md b/tests/iii/extern-variadic-type/notes.md index 3de1d69..73456b5 100644 --- a/tests/iii/extern-variadic-type/notes.md +++ b/tests/iii/extern-variadic-type/notes.md @@ -1,5 +1,5 @@ # extern-variadic-type -Compiler extension: variadic EXTERN arguments must be C values; the INTEGER literal 1 is not cast. +Compiler extension: variadic EXTERN arguments must be C values; the INTEGER literal 1 is not cast, and ^I points to an INTEGER rather than a C value. -Require exit 1 and the cause on the call line. +Require exit 1 and each cause on its call line. diff --git a/tests/iii/extern-variadic-type/program.cps b/tests/iii/extern-variadic-type/program.cps index 23f1fe9..0a967f3 100644 --- a/tests/iii/extern-variadic-type/program.cps +++ b/tests/iii/extern-variadic-type/program.cps @@ -3,3 +3,5 @@ INCLUDE_OBJ "__libc" EXTERN "C" EXTERN_FUNCTION printf(C_STRING, ...) RETURNS C_INT DECLARE N : C_INT N <- printf((C_STRING)"%d", 1) +DECLARE I : INTEGER +N <- printf((C_STRING)"%p", ^I) -- cgit v1.3.1-4-g156e