diff --git a/gen/functions.cpp b/gen/functions.cpp index a96a49cd508..fdc54582b6b 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -1046,6 +1046,8 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) { } if (fd->ir->isDefined()) { + if (fd->llvmInternal == LLVMva_arg) + return; llvm::Function *func = getIrFunc(fd)->getLLVMFunc(); assert(func); if (!linkageAvailableExternally && diff --git a/tests/compilable/va_arg.d b/tests/compilable/va_arg.d new file mode 100644 index 00000000000..1d43be44585 --- /dev/null +++ b/tests/compilable/va_arg.d @@ -0,0 +1,10 @@ +// RUN: %ldc -mtriple=aarch64-none-elf -c %s +// RUN: %ldc -mtriple=riscv64-unknown-elf -c %s + +alias va_list = void*; + +pragma(LDC_va_arg) T va_arg(T)(va_list ap); + +int foo(va_list ap) { + return va_arg!(int)(ap); +}