From: Anders Carlsson Date: Sat, 24 Apr 2010 17:11:09 +0000 (+0000) Subject: Pass the base specifiers through to CheckDerivedToBaseConversion. No functionality... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e25a96c0629b6f928d5e8055510789817db827d0;p=clang Pass the base specifiers through to CheckDerivedToBaseConversion. No functionality change yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102250 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 48b12b5712..16c7e6c1e3 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -2596,12 +2596,14 @@ public: bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, + CXXBaseSpecifierArray *BasePath = 0, bool IgnoreAccess = false); bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, unsigned InaccessibleBaseID, unsigned AmbigiousBaseConvID, SourceLocation Loc, SourceRange Range, - DeclarationName Name); + DeclarationName Name, + CXXBaseSpecifierArray *BasePath); std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index f1b1244b9e..243d854a94 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -723,7 +723,8 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, unsigned InaccessibleBaseID, unsigned AmbigiousBaseConvID, SourceLocation Loc, SourceRange Range, - DeclarationName Name) { + DeclarationName Name, + CXXBaseSpecifierArray *BasePath) { // First, determine whether the path from Derived to Base is // ambiguous. This is slightly more expensive than checking whether // the Derived to Base conversion exists, because here we need to @@ -742,10 +743,16 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, // Check that the base class can be accessed. switch (CheckBaseClassAccess(Loc, Base, Derived, Paths.front(), InaccessibleBaseID)) { - case AR_accessible: return false; - case AR_inaccessible: return true; - case AR_dependent: return false; - case AR_delayed: return false; + case AR_inaccessible: + return true; + case AR_accessible: + case AR_dependent: + case AR_delayed: + // Build a base path if necessary. + if (BasePath) { + // FIXME: Do this! + } + return false; } } @@ -775,12 +782,14 @@ Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, bool Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, + CXXBaseSpecifierArray *BasePath, bool IgnoreAccess) { return CheckDerivedToBaseConversion(Derived, Base, IgnoreAccess ? 0 : diag::err_upcast_to_inaccessible_base, diag::err_ambiguous_derived_to_base_conv, - Loc, Range, DeclarationName()); + Loc, Range, DeclarationName(), + BasePath); } @@ -5418,10 +5427,10 @@ bool Sema::CheckOverridingFunctionReturnType(const CXXMethodDecl *New, // Check if we the conversion from derived to base is valid. if (CheckDerivedToBaseConversion(NewClassTy, OldClassTy, - diag::err_covariant_return_inaccessible_base, - diag::err_covariant_return_ambiguous_derived_to_base_conv, - // FIXME: Should this point to the return type? - New->getLocation(), SourceRange(), New->getDeclName())) { + diag::err_covariant_return_inaccessible_base, + diag::err_covariant_return_ambiguous_derived_to_base_conv, + // FIXME: Should this point to the return type? + New->getLocation(), SourceRange(), New->getDeclName(), 0)) { Diag(Old->getLocation(), diag::note_overridden_virtual_function); return true; } diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 02c41da30b..683cd39012 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1492,7 +1492,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType, FromLoc, - FromRange, + FromRange, 0, IgnoreAccess)) return true; diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 71d8914761..e3ffb24d75 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1770,7 +1770,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, if (CheckDerivedToBaseConversion(From->getType(), ToType.getNonReferenceType(), From->getLocStart(), - From->getSourceRange(), + From->getSourceRange(), 0, IgnoreBaseAccess)) return true; ImpCastExprToType(From, ToType.getNonReferenceType(), diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 90c8e3bac6..5887c5e7e4 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3461,7 +3461,7 @@ InitializationSequence::Perform(Sema &S, bool IgnoreBaseAccess = Kind.isCStyleOrFunctionalCast(); if (S.CheckDerivedToBaseConversion(SourceType, Step->Type, CurInitExpr->getLocStart(), - CurInitExpr->getSourceRange(), + CurInitExpr->getSourceRange(), 0, IgnoreBaseAccess)) return S.ExprError(); diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 50afb7e1bc..5e5f23352c 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1357,7 +1357,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, // ambiguous or inaccessible conversion. if (CheckDerivedToBaseConversion(FromPointeeType, ToPointeeType, From->getExprLoc(), - From->getSourceRange(), + From->getSourceRange(), 0, IgnoreBaseAccess)) return true;