r351546 - [OpenCL] Fix overloading ranking rules for addrspace conversions.
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 18 03:38:16 PST 2019
Author: stulova
Date: Fri Jan 18 03:38:16 2019
New Revision: 351546
URL: http://llvm.org/viewvc/llvm-project?rev=351546&view=rev
Log:
[OpenCL] Fix overloading ranking rules for addrspace conversions.
Extend ranking to work with address spaces correctly when
resolving overloads.
Differential Revision: https://reviews.llvm.org/D56735
Added:
cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=351546&r1=351545&r2=351546&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Jan 18 03:38:16 2019
@@ -4019,9 +4019,12 @@ CompareQualificationConversions(Sema &S,
// to unwrap. This essentially mimics what
// IsQualificationConversion does, but here we're checking for a
// strict subset of qualifiers.
- if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
+ if (T1.getQualifiers().withoutObjCLifetime() ==
+ T2.getQualifiers().withoutObjCLifetime())
// The qualifiers are the same, so this doesn't tell us anything
// about how the sequences rank.
+ // ObjC ownership quals are omitted above as they interfere with
+ // the ARC overload rule.
;
else if (T2.isMoreQualifiedThan(T1)) {
// T1 has fewer qualifiers, so it could be the better sequence.
Added: cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl?rev=351546&view=auto
==============================================================================
--- cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl (added)
+++ cfe/trunk/test/SemaOpenCLCXX/address_space_overloading.cl Fri Jan 18 03:38:16 2019
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
+
+// expected-no-diagnostics
+
+struct RetGlob {
+ int dummy;
+};
+
+struct RetGen {
+ char dummy;
+};
+
+RetGlob foo(const __global int *);
+RetGen foo(const __generic int *);
+
+void kernel k() {
+ __global int *ArgGlob;
+ __generic int *ArgGen;
+ __local int *ArgLoc;
+ RetGlob TestGlob = foo(ArgGlob);
+ RetGen TestGen = foo(ArgGen);
+ TestGen = foo(ArgLoc);
+}
More information about the cfe-commits
mailing list