diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index b7089ef35e8..25d567fc3af 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -5977,6 +5977,15 @@ Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl, } } + // (CUDA B.1): Check for invalid calls between targets. + if (getLangOpts().CUDA) + if (const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext)) + if (CheckCUDATarget(Caller, Method)) { + Candidate.Viable = false; + Candidate.FailureKind = ovl_fail_bad_target; + return; + } + // Determine the implicit conversion sequences for each of the // arguments. for (unsigned ArgIdx = 0; ArgIdx < Args.size(); ++ArgIdx) { @@ -11598,6 +11607,18 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, new (Context) CXXMemberCallExpr(Context, MemExprE, Args, ResultType, VK, RParenLoc); + // (CUDA B.1): Check for invalid calls between targets. + if (getLangOpts().CUDA) { + if (const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext)) { + if (CheckCUDATarget(Caller, Method)) { + Diag(MemExpr->getMemberLoc(), diag::err_ref_bad_target) + << IdentifyCUDATarget(Method) << Method->getIdentifier() + << IdentifyCUDATarget(Caller); + return ExprError(); + } + } + } + // Check for a valid return type. if (CheckCallReturnType(Method->getReturnType(), MemExpr->getMemberLoc(), TheCall, Method)) |