Skip to content
Snippets Groups Projects
Commit d19902c3 authored by Kaelyn Takata's avatar Kaelyn Takata
Browse files

Diagnose delayed typos when parsing a postfix expression with an

unmatched l_paren before setting the LHS to ExprError().

Fixes PR23285.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236371 91177308-0d34-0410-b5e6-96231b3b80d8
parent 37d785b4
No related branches found
No related tags found
No related merge requests found
...@@ -1479,7 +1479,19 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) { ...@@ -1479,7 +1479,19 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (LHS.isInvalid()) { if (LHS.isInvalid()) {
SkipUntil(tok::r_paren, StopAtSemi); SkipUntil(tok::r_paren, StopAtSemi);
} else if (Tok.isNot(tok::r_paren)) { } 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(); LHS = ExprError();
} else { } else {
assert((ArgExprs.size() == 0 || assert((ArgExprs.size() == 0 ||
......
...@@ -203,3 +203,9 @@ namespace PR23350 { ...@@ -203,3 +203,9 @@ namespace PR23350 {
int z = 1 ? N : ; // expected-error {{expected expression}} int z = 1 ? N : ; // expected-error {{expected expression}}
// expected-error-re@-1 {{use of undeclared identifier 'N'{{$}}}} // expected-error-re@-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@+2 {{use of undeclared identifier 'uintmax_t'{{$}}}}
// expected-error@+1 {{expected ';' after top level declarator}}
unsigned int a = 0(uintmax_t
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment