r236371 - Diagnose delayed typos when parsing a postfix expression with an
Kaelyn Takata
rikka at google.com
Fri May 1 17:49:19 PDT 2015
Author: rikka
Date: Fri May 1 19:49:18 2015
New Revision: 236371
URL: http://llvm.org/viewvc/llvm-project?rev=236371&view=rev
Log:
Diagnose delayed typos when parsing a postfix expression with an
unmatched l_paren before setting the LHS to ExprError().
Fixes PR23285.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=236371&r1=236370&r2=236371&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri May 1 19:49:18 2015
@@ -1479,7 +1479,19 @@ Parser::ParsePostfixExpressionSuffix(Exp
if (LHS.isInvalid()) {
SkipUntil(tok::r_paren, StopAtSemi);
} else if (Tok.isNot(tok::r_paren)) {
- PT.consumeClose();
+ bool HadDelayedTypo = false;
+ if (Actions.CorrectDelayedTyposInExpr(LHS).get() != LHS.get())
+ HadDelayedTypo = true;
+ for (auto &E : ArgExprs)
+ if (Actions.CorrectDelayedTyposInExpr(E).get() != E)
+ HadDelayedTypo = true;
+ // If there were delayed typos in the LHS or ArgExprs, call SkipUntil
+ // instead of PT.consumeClose() to avoid emitting extra diagnostics for
+ // the unmatched l_paren.
+ if (HadDelayedTypo)
+ SkipUntil(tok::r_paren, StopAtSemi);
+ else
+ PT.consumeClose();
LHS = ExprError();
} else {
assert((ArgExprs.size() == 0 ||
Modified: cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp?rev=236371&r1=236370&r2=236371&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction-delayed.cpp Fri May 1 19:49:18 2015
@@ -203,3 +203,9 @@ namespace PR23350 {
int z = 1 ? N : ; // expected-error {{expected expression}}
// expected-error-re at -1 {{use of undeclared identifier 'N'{{$}}}}
}
+
+// PR 23285. This test must be at the end of the file to avoid additional,
+// unwanted diagnostics.
+// expected-error-re at +2 {{use of undeclared identifier 'uintmax_t'{{$}}}}
+// expected-error at +1 {{expected ';' after top level declarator}}
+unsigned int a = 0(uintmax_t
More information about the cfe-commits
mailing list