Skip to content
Snippets Groups Projects
Commit ad0288b5 authored by David Majnemer's avatar David Majnemer
Browse files

[Parse] Make sure we don't forget to diagnose typos in exprs

If ActOn*Op fails, we will forget to diagnose typos in the LHS of
expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261191 91177308-0d34-0410-b5e6-96231b3b80d8
parent c6c456a2
No related branches found
No related tags found
No related merge requests found
...@@ -431,6 +431,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { ...@@ -431,6 +431,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
} }
} }
ExprResult OrigLHS = LHS;
if (!LHS.isInvalid()) { if (!LHS.isInvalid()) {
// Combine the LHS and RHS into the LHS (e.g. build AST). // Combine the LHS and RHS into the LHS (e.g. build AST).
if (TernaryMiddle.isInvalid()) { if (TernaryMiddle.isInvalid()) {
...@@ -445,12 +446,15 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { ...@@ -445,12 +446,15 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(), LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
OpToken.getKind(), LHS.get(), RHS.get()); OpToken.getKind(), LHS.get(), RHS.get());
} else } else {
LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc, LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
LHS.get(), TernaryMiddle.get(), LHS.get(), TernaryMiddle.get(),
RHS.get()); RHS.get());
} else { }
// Ensure potential typos aren't left undiagnosed. }
// Ensure potential typos aren't left undiagnosed.
if (LHS.isInvalid()) {
Actions.CorrectDelayedTyposInExpr(OrigLHS);
Actions.CorrectDelayedTyposInExpr(TernaryMiddle); Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
Actions.CorrectDelayedTyposInExpr(RHS); Actions.CorrectDelayedTyposInExpr(RHS);
} }
......
...@@ -665,3 +665,8 @@ using C::D::Foofoo; // expected-error {{no member named 'Foofoo' in namespace ' ...@@ -665,3 +665,8 @@ using C::D::Foofoo; // expected-error {{no member named 'Foofoo' in namespace '
} }
int d = ? L : d; // expected-error {{expected expression}} expected-error {{undeclared identifier}} int d = ? L : d; // expected-error {{expected expression}} expected-error {{undeclared identifier}}
struct B0 {
int : 0 | // expected-error {{invalid operands to binary expression}}
(struct B0)e; // expected-error {{use of undeclared identifier}}
};
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