diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 9800d7f1c9cfee..64607e28b8b35e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1491,8 +1491,10 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New, // Don't allow overloading of destructors. (In theory we could, but it // would be a giant change to clang.) if (!isa(New)) { - Sema::CUDAFunctionTarget NewTarget = SemaRef.IdentifyCUDATarget(New), - OldTarget = SemaRef.IdentifyCUDATarget(Old); + Sema::CUDAFunctionTarget NewTarget = SemaRef.IdentifyCUDATarget( + New, isa(New)), + OldTarget = SemaRef.IdentifyCUDATarget( + Old, isa(New)); if (NewTarget != Sema::CFT_InvalidTarget) { assert((OldTarget != Sema::CFT_InvalidTarget) && "Unexpected invalid target."); diff --git a/clang/test/SemaCUDA/implicit-member-target-inherited.cu b/clang/test/SemaCUDA/implicit-member-target-inherited.cu index 781199bba6b5a1..ceca0891fc9b03 100644 --- a/clang/test/SemaCUDA/implicit-member-target-inherited.cu +++ b/clang/test/SemaCUDA/implicit-member-target-inherited.cu @@ -39,6 +39,7 @@ struct A2_with_device_ctor { }; // expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable}} // expected-note@-4 {{candidate constructor (the implicit move constructor) not viable}} +// expected-note@-4 {{candidate inherited constructor not viable: call to __device__ function from __host__ function}} struct B2_with_implicit_default_ctor : A2_with_device_ctor { using A2_with_device_ctor::A2_with_device_ctor; diff --git a/clang/test/SemaCUDA/trivial-ctor-dtor.cu b/clang/test/SemaCUDA/trivial-ctor-dtor.cu index 1df8adc62bab59..21d698d28492ac 100644 --- a/clang/test/SemaCUDA/trivial-ctor-dtor.cu +++ b/clang/test/SemaCUDA/trivial-ctor-dtor.cu @@ -38,3 +38,19 @@ struct TC : TB { }; __device__ TC tc; //expected-error {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}} + +// Check trivial ctor specialization +template +struct C { //expected-note {{candidate constructor (the implicit copy constructor) not viable}} + //expected-note@-1 {{candidate constructor (the implicit move constructor) not viable}} + explicit C() {}; +}; + +template <> C::C() {}; +__device__ C ci_d; +C ci_h; + +// Check non-trivial ctor specialization +template <> C::C() { static int nontrivial_ctor = 1; } //expected-note {{candidate constructor not viable: call to __host__ function from __device__ function}} +__device__ C cf_d; //expected-error {{no matching constructor for initialization of 'C'}} +C cf_h;