diff options
author | Jacques Pienaar <jpienaar@google.com> | 2014-12-16 20:12:38 +0000 |
---|---|---|
committer | Jacques Pienaar <jpienaar@google.com> | 2014-12-16 20:12:38 +0000 |
commit | 5bdd67778f63b23d055324f9adc45b85a8cfb8c5 (patch) | |
tree | a93aa3d46d22b4eacbe7055693d5c90981c4f4e6 /clang/lib/Sema/SemaCUDA.cpp | |
parent | 545e7276a870c60d4d289b72b38e1529dae2acd7 (diff) | |
download | llvm-5bdd67778f63b23d055324f9adc45b85a8cfb8c5.zip llvm-5bdd67778f63b23d055324f9adc45b85a8cfb8c5.tar.gz llvm-5bdd67778f63b23d055324f9adc45b85a8cfb8c5.tar.bz2 |
Consider calls from implict host device functions as valid in SemaCUDA.
In SemaCUDA all implicit functions were considered host device, this led to
errors such as the following code snippet failing to compile:
struct Copyable {
const Copyable& operator=(const Copyable& x) { return *this; }
};
struct Simple {
Copyable b;
};
void foo() {
Simple a, b;
a = b;
}
Above the implicit copy assignment operator was inferred as host device but
there was only a host assignment copy defined which is an error in device
compilation mode.
Differential Revision: http://reviews.llvm.org/D6565
llvm-svn: 224358
Diffstat (limited to 'clang/lib/Sema/SemaCUDA.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCUDA.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaCUDA.cpp b/clang/lib/Sema/SemaCUDA.cpp index 46a8317..64222fb 100644 --- a/clang/lib/Sema/SemaCUDA.cpp +++ b/clang/lib/Sema/SemaCUDA.cpp @@ -62,12 +62,9 @@ Sema::CUDAFunctionTarget Sema::IdentifyCUDATarget(const FunctionDecl *D) { bool Sema::CheckCUDATarget(const FunctionDecl *Caller, const FunctionDecl *Callee) { - return CheckCUDATarget(IdentifyCUDATarget(Caller), - IdentifyCUDATarget(Callee)); -} + CUDAFunctionTarget CallerTarget = IdentifyCUDATarget(Caller), + CalleeTarget = IdentifyCUDATarget(Callee); -bool Sema::CheckCUDATarget(CUDAFunctionTarget CallerTarget, - CUDAFunctionTarget CalleeTarget) { // If one of the targets is invalid, the check always fails, no matter what // the other target is. if (CallerTarget == CFT_InvalidTarget || CalleeTarget == CFT_InvalidTarget) @@ -90,8 +87,11 @@ bool Sema::CheckCUDATarget(CUDAFunctionTarget CallerTarget, // however, in which case the function is compiled for both the host and the // device. The __CUDA_ARCH__ macro [...] can be used to differentiate code // paths between host and device." - bool InDeviceMode = getLangOpts().CUDAIsDevice; if (CallerTarget == CFT_HostDevice && CalleeTarget != CFT_HostDevice) { + // If the caller is implicit then the check always passes. + if (Caller->isImplicit()) return false; + + bool InDeviceMode = getLangOpts().CUDAIsDevice; if ((InDeviceMode && CalleeTarget != CFT_Device) || (!InDeviceMode && CalleeTarget != CFT_Host)) return true; |