Skip to content

Commit 22078bd

Browse files
committed
Revert "[CUDA][HIP] ignore implicit host/device attr for override (#72815)"
This reverts commit a1e2c65. Revert this patch due to regression. A testcase is: `template <typename T> class C { explicit C() {}; }; template <> C<int>::C() {}; `
1 parent b14f651 commit 22078bd

File tree

3 files changed

+2
-21
lines changed

3 files changed

+2
-21
lines changed

clang/lib/Sema/SemaOverload.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,10 +1491,8 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New,
14911491
// Don't allow overloading of destructors. (In theory we could, but it
14921492
// would be a giant change to clang.)
14931493
if (!isa<CXXDestructorDecl>(New)) {
1494-
Sema::CUDAFunctionTarget NewTarget = SemaRef.IdentifyCUDATarget(
1495-
New, isa<CXXConstructorDecl>(New)),
1496-
OldTarget = SemaRef.IdentifyCUDATarget(
1497-
Old, isa<CXXConstructorDecl>(New));
1494+
Sema::CUDAFunctionTarget NewTarget = SemaRef.IdentifyCUDATarget(New),
1495+
OldTarget = SemaRef.IdentifyCUDATarget(Old);
14981496
if (NewTarget != Sema::CFT_InvalidTarget) {
14991497
assert((OldTarget != Sema::CFT_InvalidTarget) &&
15001498
"Unexpected invalid target.");

clang/test/SemaCUDA/implicit-member-target-inherited.cu

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct A2_with_device_ctor {
3939
};
4040
// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
4141
// expected-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
42-
// expected-note@-4 {{candidate inherited constructor not viable: call to __device__ function from __host__ function}}
4342

4443
struct B2_with_implicit_default_ctor : A2_with_device_ctor {
4544
using A2_with_device_ctor::A2_with_device_ctor;

clang/test/SemaCUDA/trivial-ctor-dtor.cu

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,3 @@ struct TC : TB<T> {
3838
};
3939

4040
__device__ TC<int> tc; //expected-error {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}
41-
42-
// Check trivial ctor specialization
43-
template <typename T>
44-
struct C { //expected-note {{candidate constructor (the implicit copy constructor) not viable}}
45-
//expected-note@-1 {{candidate constructor (the implicit move constructor) not viable}}
46-
explicit C() {};
47-
};
48-
49-
template <> C<int>::C() {};
50-
__device__ C<int> ci_d;
51-
C<int> ci_h;
52-
53-
// Check non-trivial ctor specialization
54-
template <> C<float>::C() { static int nontrivial_ctor = 1; } //expected-note {{candidate constructor not viable: call to __host__ function from __device__ function}}
55-
__device__ C<float> cf_d; //expected-error {{no matching constructor for initialization of 'C<float>'}}
56-
C<float> cf_h;

0 commit comments

Comments
 (0)