summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJustin Lebar <jlebar@google.com>2016-01-20 00:27:00 +0000
committerJustin Lebar <jlebar@google.com>2016-01-20 00:27:00 +0000
commit6644e366b01e88afd6264945151b0dde764cdd9b (patch)
treea1951f86e84825b967c5af3a86eae6409d18cdbd /clang/lib/Sema/SemaExpr.cpp
parentc66a10652a9404d1d196864fc1b2e9aa413307b8 (diff)
downloadbcm5719-llvm-6644e366b01e88afd6264945151b0dde764cdd9b.tar.gz
bcm5719-llvm-6644e366b01e88afd6264945151b0dde764cdd9b.zip
[CUDA] Bail, rather than crash, on va_arg in device code.
Reviewers: tra Subscribers: echristo, jhen, cfe-commits Differential Revision: http://reviews.llvm.org/D16331 llvm-svn: 258264
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f8537d3692b..008a2fc4c45 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11715,9 +11715,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
return Result;
}
-ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
- Expr *E, ParsedType Ty,
- SourceLocation RPLoc) {
+ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
+ SourceLocation RPLoc) {
TypeSourceInfo *TInfo;
GetTypeFromParser(Ty, &TInfo);
return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
@@ -11729,6 +11728,15 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
Expr *OrigExpr = E;
bool IsMS = false;
+ // CUDA device code does not support varargs.
+ if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) {
+ if (const FunctionDecl *F = dyn_cast<FunctionDecl>(CurContext)) {
+ CUDAFunctionTarget T = IdentifyCUDATarget(F);
+ if (T == CFT_Global || T == CFT_Device || T == CFT_HostDevice)
+ return ExprError(Diag(E->getLocStart(), diag::err_va_arg_in_device));
+ }
+ }
+
// It might be a __builtin_ms_va_list. (But don't ever mark a va_arg()
// as Microsoft ABI on an actual Microsoft platform, where
// __builtin_ms_va_list and __builtin_va_list are the same.)
OpenPOWER on IntegriCloud