From: Anastasia Stulova Date: Mon, 3 Jun 2019 15:42:36 +0000 (+0000) Subject: [PR41567][Sema] Fixed cast kind in addr space conversions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9786367305b6884bcb6b78ee286d49cba445dd81;p=clang [PR41567][Sema] Fixed cast kind in addr space conversions This change sets missing cast kind correctly in the address space conversion case. Differential Revision: https://reviews.llvm.org/D62299 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362409 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCast.cpp b/lib/Sema/SemaCast.cpp index 0958943f9e..46d0f57dc7 100644 --- a/lib/Sema/SemaCast.cpp +++ b/lib/Sema/SemaCast.cpp @@ -2450,6 +2450,10 @@ void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle, tcr = TryAddressSpaceCast(Self, SrcExpr, DestType, /*CStyle*/ true, msg); if (SrcExpr.isInvalid()) return; + + if (isValidCast(tcr)) + Kind = CK_AddressSpaceConversion; + if (tcr == TC_NotApplicable) { // ... or if that is not possible, a static_cast, ignoring const, ... tcr = TryStaticCast(Self, SrcExpr, DestType, CCK, OpRange, msg, Kind, diff --git a/test/CodeGenOpenCLCXX/addrspace-conversion.cl b/test/CodeGenOpenCLCXX/addrspace-conversion.cl new file mode 100644 index 0000000000..38422c24e8 --- /dev/null +++ b/test/CodeGenOpenCLCXX/addrspace-conversion.cl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s + +void bar(__generic volatile unsigned int* ptr) +{ + //CHECK: addrspacecast i32 addrspace(4)* %{{.+}} to i32 addrspace(1)* + auto gptr = (__global volatile unsigned int*)ptr; +}