Skip to content

Commit ef19af1

Browse files
author
Anastasia Stulova
committed
[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 llvm-svn: 351546
1 parent c196488 commit ef19af1

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

clang/lib/Sema/SemaOverload.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4019,9 +4019,12 @@ CompareQualificationConversions(Sema &S,
40194019
// to unwrap. This essentially mimics what
40204020
// IsQualificationConversion does, but here we're checking for a
40214021
// strict subset of qualifiers.
4022-
if (T1.getCVRQualifiers() == T2.getCVRQualifiers())
4022+
if (T1.getQualifiers().withoutObjCLifetime() ==
4023+
T2.getQualifiers().withoutObjCLifetime())
40234024
// The qualifiers are the same, so this doesn't tell us anything
40244025
// about how the sequences rank.
4026+
// ObjC ownership quals are omitted above as they interfere with
4027+
// the ARC overload rule.
40254028
;
40264029
else if (T2.isMoreQualifiedThan(T1)) {
40274030
// T1 has fewer qualifiers, so it could be the better sequence.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
2+
3+
// expected-no-diagnostics
4+
5+
struct RetGlob {
6+
int dummy;
7+
};
8+
9+
struct RetGen {
10+
char dummy;
11+
};
12+
13+
RetGlob foo(const __global int *);
14+
RetGen foo(const __generic int *);
15+
16+
void kernel k() {
17+
__global int *ArgGlob;
18+
__generic int *ArgGen;
19+
__local int *ArgLoc;
20+
RetGlob TestGlob = foo(ArgGlob);
21+
RetGen TestGen = foo(ArgGen);
22+
TestGen = foo(ArgLoc);
23+
}

0 commit comments

Comments
 (0)