[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 26 16:23:29 PDT 2020
yaxunl updated this revision to Diff 266366.
yaxunl added a comment.
Fix test.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80450/new/
https://reviews.llvm.org/D80450
Files:
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu
Index: clang/test/SemaCUDA/function-overload.cu
===================================================================
--- clang/test/SemaCUDA/function-overload.cu
+++ clang/test/SemaCUDA/function-overload.cu
@@ -541,3 +541,51 @@
}
};
}
+
+// Implicit HD candidate competes with device candidate.
+// a and b have implicit HD copy ctor. In copy ctor of b, ctor of a is resolved.
+// copy ctor of a should win over a(short), otherwise there will be ambiguity
+// due to conversion operator.
+namespace TestImplicitHDWithD {
+ struct a {
+ __device__ a(short);
+ __device__ operator unsigned() const;
+ __device__ operator int() const;
+ };
+ struct b {
+ a d;
+ };
+ void f(b g) { b e = g; }
+}
+
+// Implicit HD candidate competes with host candidate.
+// a and b have implicit HD copy ctor. In copy ctor of b, ctor of a is resolved.
+// copy ctor of a should win over a(short), otherwise there will be ambiguity
+// due to conversion operator.
+namespace TestImplicitHDWithH {
+ struct a {
+ a(short);
+ __device__ operator unsigned() const;
+ __device__ operator int() const;
+ };
+ struct b {
+ a d;
+ };
+ void f(b g) { b e = g; }
+}
+
+// Implicit HD candidate comptes with HD candidate.
+// a and b have implicit HD copy ctor. In copy ctor of b, ctor of a is resolved.
+// copy ctor of a should win over a(short), otherwise there will be ambiguity
+// due to conversion operator.
+namespace TestImplicitHDWithHD {
+ struct a {
+ __host__ __device__ a(short);
+ __device__ operator unsigned() const;
+ __device__ operator int() const;
+ };
+ struct b {
+ a d;
+ };
+ void f(b g) { b e = g; }
+}
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9534,7 +9534,7 @@
auto EmitThreshold =
(S.getLangOpts().CUDAIsDevice && IsCallerImplicitHD &&
(IsCand1ImplicitHD || IsCand2ImplicitHD))
- ? Sema::CFP_HostDevice
+ ? Sema::CFP_Never
: Sema::CFP_WrongSide;
auto Cand1Emittable = P1 > EmitThreshold;
auto Cand2Emittable = P2 > EmitThreshold;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80450.266366.patch
Type: text/x-patch
Size: 2209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200526/13d2c82a/attachment.bin>
More information about the cfe-commits
mailing list