| 
 | 1 | +From fb4a22c92ce87e6027a5464f1411d8ade41192f8 Mon Sep 17 00:00:00 2001  | 
 | 2 | +From: Anastasia Stulova < [email protected]>  | 
 | 3 | +Date: Fri, 18 Jan 2019 11:38:16 +0000  | 
 | 4 | +Subject: [PATCH] [OpenCL] Fix overloading ranking rules for addrspace  | 
 | 5 | + conversions.  | 
 | 6 | + | 
 | 7 | +Extend ranking to work with address spaces correctly when  | 
 | 8 | +resolving overloads.  | 
 | 9 | + | 
 | 10 | +Differential Revision: https://reviews.llvm.org/D56735  | 
 | 11 | + | 
 | 12 | + | 
 | 13 | + | 
 | 14 | +git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351546 91177308-0d34-0410-b5e6-96231b3b80d8  | 
 | 15 | +---  | 
 | 16 | + lib/Sema/SemaOverload.cpp                     |  5 +++-  | 
 | 17 | + .../address_space_overloading.cl              | 23 +++++++++++++++++++  | 
 | 18 | + 2 files changed, 27 insertions(+), 1 deletion(-)  | 
 | 19 | + create mode 100644 test/SemaOpenCLCXX/address_space_overloading.cl  | 
 | 20 | + | 
 | 21 | +diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp  | 
 | 22 | +index 52be0598fb..276226b6da 100644  | 
 | 23 | +--- a/lib/Sema/SemaOverload.cpp  | 
 | 24 | ++++ b/lib/Sema/SemaOverload.cpp  | 
 | 25 | +@@ -4019,9 +4019,12 @@ CompareQualificationConversions(Sema &S,  | 
 | 26 | +     // to unwrap. This essentially mimics what  | 
 | 27 | +     // IsQualificationConversion does, but here we're checking for a  | 
 | 28 | +     // strict subset of qualifiers.  | 
 | 29 | +-    if (T1.getCVRQualifiers() == T2.getCVRQualifiers())  | 
 | 30 | ++    if (T1.getQualifiers().withoutObjCLifetime() ==  | 
 | 31 | ++        T2.getQualifiers().withoutObjCLifetime())  | 
 | 32 | +       // The qualifiers are the same, so this doesn't tell us anything  | 
 | 33 | +       // about how the sequences rank.  | 
 | 34 | ++      // ObjC ownership quals are omitted above as they interfere with  | 
 | 35 | ++      // the ARC overload rule.  | 
 | 36 | +       ;  | 
 | 37 | +     else if (T2.isMoreQualifiedThan(T1)) {  | 
 | 38 | +       // T1 has fewer qualifiers, so it could be the better sequence.  | 
 | 39 | +diff --git a/test/SemaOpenCLCXX/address_space_overloading.cl b/test/SemaOpenCLCXX/address_space_overloading.cl  | 
 | 40 | +new file mode 100644  | 
 | 41 | +index 0000000000..ccdd5735bb  | 
 | 42 | +--- /dev/null  | 
 | 43 | ++++ b/test/SemaOpenCLCXX/address_space_overloading.cl  | 
 | 44 | +@@ -0,0 +1,23 @@  | 
 | 45 | ++// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++  | 
 | 46 | ++  | 
 | 47 | ++// expected-no-diagnostics  | 
 | 48 | ++  | 
 | 49 | ++struct RetGlob {  | 
 | 50 | ++  int dummy;  | 
 | 51 | ++};  | 
 | 52 | ++  | 
 | 53 | ++struct RetGen {  | 
 | 54 | ++  char dummy;  | 
 | 55 | ++};  | 
 | 56 | ++  | 
 | 57 | ++RetGlob foo(const __global int *);  | 
 | 58 | ++RetGen foo(const __generic int *);  | 
 | 59 | ++  | 
 | 60 | ++void kernel k() {  | 
 | 61 | ++  __global int *ArgGlob;  | 
 | 62 | ++  __generic int *ArgGen;  | 
 | 63 | ++  __local int *ArgLoc;  | 
 | 64 | ++  RetGlob TestGlob = foo(ArgGlob);  | 
 | 65 | ++  RetGen TestGen = foo(ArgGen);  | 
 | 66 | ++  TestGen = foo(ArgLoc);  | 
 | 67 | ++}  | 
 | 68 | +--   | 
 | 69 | +2.17.1  | 
 | 70 | + | 
0 commit comments