diff options
author | John McCall <rjmccall@apple.com> | 2011-04-26 20:42:42 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-04-26 20:42:42 +0000 |
commit | 864c041e118155c2b1ce0ba36942a3da5a4a055e (patch) | |
tree | 19f877df6230e8eb683deb156e16b51f25dabcf2 /lib/Sema/SemaCXXCast.cpp | |
parent | eab80782f645489db299db24aa7a5886b37185b0 (diff) |
Make yet another placeholder type, this one marking that an expression is a bound
member function, i.e. something of the form 'x.f' where 'f' is a non-static
member function. Diagnose this in the general case. Some of the new diagnostics
are probably worse than the old ones, but we now get this right much more
universally, and there's certainly room for improvement in the diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130239 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCXXCast.cpp')
-rw-r--r-- | lib/Sema/SemaCXXCast.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 648011b1f0..ed54f0f544 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -160,10 +160,6 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, // FIXME: should we check this in a more fine-grained manner? bool TypeDependent = DestType->isDependentType() || Ex.get()->isTypeDependent(); - if (Ex.get()->isBoundMemberFunction(Context)) - Diag(Ex.get()->getLocStart(), diag::err_invalid_use_of_bound_member_func) - << Ex.get()->getSourceRange(); - ExprValueKind VK = VK_RValue; if (TypeDependent) VK = Expr::getValueKindForType(DestType); @@ -305,6 +301,11 @@ static bool tryDiagnoseOverloadedCast(Sema &S, CastType CT, /// Diagnose a failed cast. static void diagnoseBadCast(Sema &S, unsigned msg, CastType castType, SourceRange opRange, Expr *src, QualType destType) { + if (src->getType() == S.Context.BoundMemberTy) { + (void) S.CheckPlaceholderExpr(src); // will always fail + return; + } + if (msg == diag::err_bad_cxx_cast_generic && tryDiagnoseOverloadedCast(S, castType, opRange, src, destType)) return; @@ -1540,12 +1541,6 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK, Expr *CastExpr, CastKind &Kind, CXXCastPath &BasePath, bool FunctionalStyle) { - if (CastExpr->isBoundMemberFunction(Context)) { - Diag(CastExpr->getLocStart(), diag::err_invalid_use_of_bound_member_func) - << CastExpr->getSourceRange(); - return ExprError(); - } - // This test is outside everything else because it's the only case where // a non-lvalue-reference target type does not lead to decay. // C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void". @@ -1557,6 +1552,9 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK, return ExprError(); CastExpr = CastExprRes.take(); + if (CastExpr->getType() == Context.BoundMemberTy) + return CheckPlaceholderExpr(CastExpr); // will always fail + if (CastExpr->getType() == Context.OverloadTy) { ExprResult SingleFunctionExpr = ResolveAndFixSingleFunctionTemplateSpecialization( |