From c795750b29c923b3bb08eb8b93a44f1bc7646e98 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 24 Apr 2010 22:02:54 +0000 Subject: [PATCH] When building implicit base initializers, add a derived-to-base cast that points to the exact base specifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102277 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 6d1d1070fd..d7cbc17a7a 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1502,6 +1502,13 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, DeclRefExpr::Create(SemaRef.Context, 0, SourceRange(), Param, SourceLocation(), ParamType, 0); + // Cast to the base class to avoid ambiguities. + CXXBaseSpecifierArray BasePath; + BasePath.push_back(BaseSpec); + SemaRef.ImpCastExprToType(CopyCtorArg, BaseSpec->getType(), + CastExpr::CK_UncheckedDerivedToBase, + /*isLvalue=*/true, BasePath); + InitializationKind InitKind = InitializationKind::CreateDirect(Constructor->getLocation(), SourceLocation(), SourceLocation()); -- 2.50.0