From 90bf56f456e22dcd98458eca14e0b152a5efb179 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 13:30:00 +0000 Subject: feat(codegen): accept record pointers as variadic arguments Pointer types to C-struct records now pass unchanged as variadic EXTERN arguments. Pseudocode values still need a cast to a C type, and records by value stay rejected. Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/CallGen.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/CallGen.cc b/lib/CodeGen/CallGen.cc index dfe89d6..b25ca12 100644 --- a/lib/CodeGen/CallGen.cc +++ b/lib/CodeGen/CallGen.cc @@ -128,7 +128,8 @@ bool CodeGen::marshalCallArgs(const FuncSig &Signature, // C values are accepted, matching the explicit-cast rule for C/pseudocode. Value *CodeGen::emitVariadicArgument(ExprAST *Expr, const std::string &Callee, size_t Position) { const TypeInfo *Info = isWholeArrayVar(Expr) ? nullptr : getExprTypeInfo(Expr); - if (!Info || !Info->isC() || Info->isVoid()) { + // Pointers to C structs pass unchanged; records by value are not supported yet. + if (!Info || Info->isRecord() || !Types->isExternType(Info)) { reportError("Variadic argument %zu to %s must be a C value; cast it to a C type", Position, Callee.c_str()); return nullptr; } -- cgit v1.3.1-4-g156e