diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2018-11-16 16:22:56 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2018-11-16 16:22:56 +0000 |
commit | b6508aa4110621b4c5441dd67013cee4ec0d3036 (patch) | |
tree | 1652c7db8cd5af1be6079f8972b42f7b6a526615 /lib/Sema/SemaExprCXX.cpp | |
parent | 59e40fbc67abf5f59b408d83bab2e33e1fe0eb17 (diff) |
[OpenCL] Enable address spaces for references in C++
Added references to the addr spaces deduction and enabled
CL2.0 features (program scope variables and storage class
qualifiers) to work in C++ mode too.
Fixed several address space conversion issues in CodeGen
for references.
Differential Revision: https://reviews.llvm.org/D53764
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 1349b5af6a..23bc4831b1 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -4271,10 +4271,24 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType, case ICK_Qualification: { // The qualification keeps the category of the inner expression, unless the // target type isn't a reference. - ExprValueKind VK = ToType->isReferenceType() ? - From->getValueKind() : VK_RValue; - From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context), - CK_NoOp, VK, /*BasePath=*/nullptr, CCK).get(); + ExprValueKind VK = + ToType->isReferenceType() ? From->getValueKind() : VK_RValue; + + CastKind CK = CK_NoOp; + + if (ToType->isReferenceType() && + ToType->getPointeeType().getAddressSpace() != + From->getType().getAddressSpace()) + CK = CK_AddressSpaceConversion; + + if (ToType->isPointerType() && + ToType->getPointeeType().getAddressSpace() != + From->getType()->getPointeeType().getAddressSpace()) + CK = CK_AddressSpaceConversion; + + From = ImpCastExprToType(From, ToType.getNonLValueExprType(Context), CK, VK, + /*BasePath=*/nullptr, CCK) + .get(); if (SCS.DeprecatedStringLiteralToCharPtr && !getLangOpts().WritableStrings) { |