r362409 - [PR41567][Sema] Fixed cast kind in addr space conversions
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 3 08:42:36 PDT 2019
Author: stulova
Date: Mon Jun 3 08:42:36 2019
New Revision: 362409
URL: http://llvm.org/viewvc/llvm-project?rev=362409&view=rev
Log:
[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
Added:
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-conversion.cl
Modified:
cfe/trunk/lib/Sema/SemaCast.cpp
Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=362409&r1=362408&r2=362409&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Mon Jun 3 08:42:36 2019
@@ -2450,6 +2450,10 @@ void CastOperation::CheckCXXCStyleCast(b
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,
Added: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-conversion.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-conversion.cl?rev=362409&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-conversion.cl (added)
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-conversion.cl Mon Jun 3 08:42:36 2019
@@ -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;
+}
More information about the cfe-commits
mailing list