summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Antognini <marco.antognini@arm.com>2019-07-09 15:04:27 +0000
committerMarco Antognini <marco.antognini@arm.com>2019-07-09 15:04:27 +0000
commitd36e130a86d15715d8f1e4097333216f7f27ca5d (patch)
tree873a610f0f0a91025d465274c0e066c336b1b17a
parentb00d5f732cd3f6f8bd86d2c5f7ddb2ce5bca8740 (diff)
downloadbcm5719-llvm-d36e130a86d15715d8f1e4097333216f7f27ca5d.tar.gz
bcm5719-llvm-d36e130a86d15715d8f1e4097333216f7f27ca5d.zip
[OpenCL][Sema] Improve address space support for blocks
Summary: This patch ensures that the following code is compiled identically with -cl-std=CL2.0 and -fblocks -cl-std=c++. kernel void test(void) { void (^const block_A)(void) = ^{ return; }; } A new test is not added because cl20-device-side-enqueue.cl will cover this once blocks are further improved for C++ for OpenCL. The changes to Sema::PerformImplicitConversion are based on the parts of Sema::CheckAssignmentConstraints on block pointer conversions. Reviewers: rjmccall, Anastasia Subscribers: yaxunl, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64083 llvm-svn: 365500
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 32b35ba7c32..3029861f230 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -4216,7 +4216,20 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
break;
case ICK_Block_Pointer_Conversion: {
- From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
+ QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
+ QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
+
+ // Assumptions based on Sema::IsBlockPointerConversion.
+ assert(isa<BlockPointerType>(LHSType) && "BlockPointerType expected");
+ assert(isa<BlockPointerType>(RHSType) && "BlockPointerType expected");
+
+ LangAS AddrSpaceL =
+ LHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ LangAS AddrSpaceR =
+ RHSType->getAs<BlockPointerType>()->getPointeeType().getAddressSpace();
+ CastKind Kind =
+ AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
+ From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
VK_RValue, /*BasePath=*/nullptr, CCK).get();
break;
}
OpenPOWER on IntegriCloud