Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCUDA/vararg.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down