summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAnastasia Stulova <anastasia.stulova@arm.com>2019-06-03 15:42:36 +0000
committerAnastasia Stulova <anastasia.stulova@arm.com>2019-06-03 15:42:36 +0000
commit5099aef86964c4b845d9165b9328e6e8e30fc8a3 (patch)
treef2fc5ed0b2994b439766c7eda9029848f6368c57 /clang
parentbedcaea99a78d869b0c2763c6c2f471b5637fc35 (diff)
downloadbcm5719-llvm-5099aef86964c4b845d9165b9328e6e8e30fc8a3.tar.gz
bcm5719-llvm-5099aef86964c4b845d9165b9328e6e8e30fc8a3.zip
[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 llvm-svn: 362409
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaCast.cpp4
-rw-r--r--clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl7
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 0958943f9ef..46d0f57dc77 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/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/clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl b/clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl
new file mode 100644
index 00000000000..38422c24e85
--- /dev/null
+++ b/clang/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;
+}
OpenPOWER on IntegriCloud