Skip to content

Commit

Permalink
Revert "[CUDA][HIP] ignore implicit host/device attr for override (#7…
Browse files Browse the repository at this point in the history
…2815)"

This reverts commit a1e2c65.

Revert this patch due to regression. A testcase is:

`template <typename T>
class C {
    explicit C() {};
};

template <> C<int>::C() {};
`
  • Loading branch information
yxsamliu committed Nov 23, 2023
1 parent b14f651 commit 22078bd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
6 changes: 2 additions & 4 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1491,10 +1491,8 @@ 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<CXXDestructorDecl>(New)) {
Sema::CUDAFunctionTarget NewTarget = SemaRef.IdentifyCUDATarget(
New, isa<CXXConstructorDecl>(New)),
OldTarget = SemaRef.IdentifyCUDATarget(
Old, isa<CXXConstructorDecl>(New));
Sema::CUDAFunctionTarget NewTarget = SemaRef.IdentifyCUDATarget(New),
OldTarget = SemaRef.IdentifyCUDATarget(Old);
if (NewTarget != Sema::CFT_InvalidTarget) {
assert((OldTarget != Sema::CFT_InvalidTarget) &&
"Unexpected invalid target.");
Expand Down
1 change: 0 additions & 1 deletion clang/test/SemaCUDA/implicit-member-target-inherited.cu
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ 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;
Expand Down
16 changes: 0 additions & 16 deletions clang/test/SemaCUDA/trivial-ctor-dtor.cu
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,3 @@ struct TC : TB<T> {
};

__device__ TC<int> tc; //expected-error {{dynamic initialization is not supported for __device__, __constant__, __shared__, and __managed__ variables}}

// Check trivial ctor specialization
template <typename T>
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<int>::C() {};
__device__ C<int> ci_d;
C<int> ci_h;

// Check non-trivial ctor specialization
template <> C<float>::C() { static int nontrivial_ctor = 1; } //expected-note {{candidate constructor not viable: call to __host__ function from __device__ function}}
__device__ C<float> cf_d; //expected-error {{no matching constructor for initialization of 'C<float>'}}
C<float> cf_h;

0 comments on commit 22078bd

Please sign in to comment.