Diagnose TypoExprs in a couple of error cases in ParsePostfixExpressionSuffix.

Also have CorrectDelayedTyposInExpr check that the Expr* isn't null
before trying to access its members. Fixes PR21679.

llvm-svn: 223162
This commit is contained in:
Kaelyn Takata 2014-12-02 22:05:35 +00:00
parent bbdee93638
commit c71dda2c38
2 changed files with 7 additions and 3 deletions

View File

@ -1364,8 +1364,10 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (!LHS.isInvalid() && !Idx.isInvalid() && Tok.is(tok::r_square)) {
LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
Idx.get(), RLoc);
} else
} else {
(void)Actions.CorrectDelayedTyposInExpr(LHS);
LHS = ExprError();
}
// Match the ']'.
T.consumeClose();
@ -1536,8 +1538,10 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
/*AllowDestructorName=*/true,
/*AllowConstructorName=*/
getLangOpts().MicrosoftExt,
ObjectType, TemplateKWLoc, Name))
ObjectType, TemplateKWLoc, Name)) {
(void)Actions.CorrectDelayedTyposInExpr(LHS);
LHS = ExprError();
}
if (!LHS.isInvalid())
LHS = Actions.ActOnMemberAccessExpr(getCurScope(), LHS.get(), OpLoc,

View File

@ -6196,7 +6196,7 @@ ExprResult Sema::CorrectDelayedTyposInExpr(
// If the current evaluation context indicates there are uncorrected typos
// and the current expression isn't guaranteed to not have typos, try to
// resolve any TypoExpr nodes that might be in the expression.
if (!ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
if (E && !ExprEvalContexts.empty() && ExprEvalContexts.back().NumTypos &&
(E->isTypeDependent() || E->isValueDependent() ||
E->isInstantiationDependent())) {
auto TyposResolved = DelayedTypos.size();