[clang] d96c32c - [CUDA] Enable variadic argument support in front-end (#161305)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 29 19:48:17 PDT 2025
Author: Luo, Yuanke
Date: 2025-09-29T21:48:14-05:00
New Revision: d96c32cdaf588903917a9e7db172729759e34c9d
URL: https://github.com/llvm/llvm-project/commit/d96c32cdaf588903917a9e7db172729759e34c9d
DIFF: https://github.com/llvm/llvm-project/commit/d96c32cdaf588903917a9e7db172729759e34c9d.diff
LOG: [CUDA] Enable variadic argument support in front-end (#161305)
Variadice argument for NVPTX as been support in
https://github.com/llvm/llvm-project/commit/486d00eca6b6ab470e8324b52cdf9f32023c1c9a
We can enable it in front-end.
Co-authored-by: Yuanke Luo <ykluo at birentech.com>
Added:
Modified:
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCUDA/vararg.cu
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3302bfce193a2..06b2529011c74 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16791,12 +16791,11 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
Expr *OrigExpr = E;
bool IsMS = false;
- // CUDA device code does not support varargs.
+ // CUDA device global function does not support varargs.
if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
if (const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
CUDAFunctionTarget T = CUDA().IdentifyTarget(F);
- if (T == CUDAFunctionTarget::Global || T == CUDAFunctionTarget::Device ||
- T == CUDAFunctionTarget::HostDevice)
+ if (T == CUDAFunctionTarget::Global)
return ExprError(Diag(E->getBeginLoc(), diag::err_va_arg_in_device));
}
}
diff --git a/clang/test/SemaCUDA/vararg.cu b/clang/test/SemaCUDA/vararg.cu
index 34ef367d89820..0238f42dc40a9 100644
--- a/clang/test/SemaCUDA/vararg.cu
+++ b/clang/test/SemaCUDA/vararg.cu
@@ -10,7 +10,7 @@
#include <stdarg.h>
#include "Inputs/cuda.h"
-__device__ void foo() {
+__global__ void foo() {
va_list list;
va_arg(list, int);
#ifdef EXPECT_VA_ARG_ERR
More information about the cfe-commits
mailing list