diff options
author | Kaelyn Uhrain <rikka@google.com> | 2013-07-12 21:43:02 +0000 |
---|---|---|
committer | Kaelyn Uhrain <rikka@google.com> | 2013-07-12 21:43:02 +0000 |
commit | 638264ea2a3d084096b10f323a2c4262cce011ac (patch) | |
tree | 8076681362f54faa4ff0d55fa0be371a608593ff /clang/lib/Parse/ParseExpr.cpp | |
parent | c037383aff81a61ed956858353ec003e970fb2ce (diff) | |
download | bcm5719-llvm-638264ea2a3d084096b10f323a2c4262cce011ac.tar.gz bcm5719-llvm-638264ea2a3d084096b10f323a2c4262cce011ac.zip |
Provide a better diagnostic and a fixit for a '.' or '->' before the left paren
of a function call.
This fixes PR5898 and means we now have a better diagnostic here than GCC.
llvm-svn: 186208
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 9521ffbc0e3..f9c7c4e3b45 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1457,7 +1457,19 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { ParsedType ObjectType; bool MayBePseudoDestructor = false; if (getLangOpts().CPlusPlus && !LHS.isInvalid()) { - LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), LHS.take(), + Expr *Base = LHS.take(); + const Type* BaseType = Base->getType().getTypePtrOrNull(); + if (BaseType && Tok.is(tok::l_paren) && + (BaseType->isFunctionType() || + BaseType->getAsPlaceholderType()->getKind() == + BuiltinType::BoundMember)) { + Diag(OpLoc, diag::err_function_is_not_record) + << (OpKind == tok::arrow) << Base->getSourceRange() + << FixItHint::CreateRemoval(OpLoc); + return ParsePostfixExpressionSuffix(Base); + } + + LHS = Actions.ActOnStartCXXMemberReference(getCurScope(), Base, OpLoc, OpKind, ObjectType, MayBePseudoDestructor); if (LHS.isInvalid()) |