summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaOverload.cpp5
-rw-r--r--clang/test/SemaOpenCLCXX/address_space_overloading.cl23
2 files changed, 27 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 52be0598fbc..276226b6da3 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -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.
diff --git a/clang/test/SemaOpenCLCXX/address_space_overloading.cl b/clang/test/SemaOpenCLCXX/address_space_overloading.cl
new file mode 100644
index 00000000000..ccdd5735bb9
--- /dev/null
+++ b/clang/test/SemaOpenCLCXX/address_space_overloading.cl
@@ -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);
+}
OpenPOWER on IntegriCloud