From 35388dcbbc4ce6ce7125f718b3050be33c339464 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Thu, 21 Nov 2019 10:39:33 +0000 Subject: [OpenCL] Fix address space for base method call (PR43145) Clang was creating an UncheckedDerivedToBase ImplicitCastExpr that was also casting between address spaces. Insert an ImplicitCastExpr node for doing the address space conversion. Differential Revision: https://reviews.llvm.org/D69810 --- clang/lib/Sema/SemaExpr.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'clang/lib/Sema/SemaExpr.cpp') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ea4321cdd72..3be8af1dd9e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -2711,6 +2711,20 @@ Sema::PerformObjectMemberConversion(Expr *From, FromRecordType = FromType; DestType = DestRecordType; } + + LangAS FromAS = FromRecordType.getAddressSpace(); + LangAS DestAS = DestRecordType.getAddressSpace(); + if (FromAS != DestAS) { + QualType FromRecordTypeWithoutAS = + Context.removeAddrSpaceQualType(FromRecordType); + QualType FromTypeWithDestAS = + Context.getAddrSpaceQualType(FromRecordTypeWithoutAS, DestAS); + if (PointerConversions) + FromTypeWithDestAS = Context.getPointerType(FromTypeWithDestAS); + From = ImpCastExprToType(From, FromTypeWithDestAS, + CK_AddressSpaceConversion, From->getValueKind()) + .get(); + } } else { // No conversion necessary. return From; -- cgit v1.2.3