diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2016-02-18 06:37:44 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2016-02-18 06:37:44 +0000 |
| commit | bc24cb5fb53753fcf643a33885ba04b3c6f32041 (patch) | |
| tree | 4722ab4df9a92a68c4b0c71a17c72d394ecde8c0 | |
| parent | d85ab7fc103b163494046317120ad57055a2b7db (diff) | |
| download | bcm5719-llvm-bc24cb5fb53753fcf643a33885ba04b3c6f32041.tar.gz bcm5719-llvm-bc24cb5fb53753fcf643a33885ba04b3c6f32041.zip | |
[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.
llvm-svn: 261191
| -rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaCXX/typo-correction.cpp | 5 |
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 82f36856940..32262f433d1 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -431,6 +431,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { } } + ExprResult OrigLHS = LHS; if (!LHS.isInvalid()) { // Combine the LHS and RHS into the LHS (e.g. build AST). if (TernaryMiddle.isInvalid()) { @@ -445,12 +446,15 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(), OpToken.getKind(), LHS.get(), RHS.get()); - } else + } else { LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc, LHS.get(), TernaryMiddle.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(RHS); } diff --git a/clang/test/SemaCXX/typo-correction.cpp b/clang/test/SemaCXX/typo-correction.cpp index 4f7c4e61fad..ae6bfa53c93 100644 --- a/clang/test/SemaCXX/typo-correction.cpp +++ b/clang/test/SemaCXX/typo-correction.cpp @@ -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}} + +struct B0 { + int : 0 | // expected-error {{invalid operands to binary expression}} + (struct B0)e; // expected-error {{use of undeclared identifier}} +}; |

