Correct typos after acting on invalid subscript expressions
llvm-svn: 261312
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 32262f4..07f7505 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1434,8 +1434,10 @@
// Reject array indices starting with a lambda-expression. '[[' is
// reserved for attributes.
- if (CheckProhibitedCXX11Attribute())
+ if (CheckProhibitedCXX11Attribute()) {
+ (void)Actions.CorrectDelayedTyposInExpr(LHS);
return ExprError();
+ }
BalancedDelimiterTracker T(*this, tok::l_square);
T.consumeOpen();
@@ -1463,6 +1465,7 @@
SourceLocation RLoc = Tok.getLocation();
+ ExprResult OrigLHS = LHS;
if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() &&
Tok.is(tok::r_square)) {
if (ColonLoc.isValid()) {
@@ -1473,7 +1476,10 @@
Idx.get(), RLoc);
}
} else {
- (void)Actions.CorrectDelayedTyposInExpr(LHS);
+ LHS = ExprError();
+ }
+ if (LHS.isInvalid()) {
+ (void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
(void)Actions.CorrectDelayedTyposInExpr(Idx);
(void)Actions.CorrectDelayedTyposInExpr(Length);
LHS = ExprError();