[PATCH] D22930: [Parser] only correct delayed typos for conditional expressions when needed.
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 28 18:03:25 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277095: [Parser] Fix bug where delayed typo in conditional expression was corrected… (authored by epilk).
Changed prior to commit:
https://reviews.llvm.org/D22930?vs=65965&id=66067#toc
Repository:
rL LLVM
https://reviews.llvm.org/D22930
Files:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/Sema/typo-correction.c
Index: cfe/trunk/lib/Parse/ParseExpr.cpp
===================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp
+++ cfe/trunk/lib/Parse/ParseExpr.cpp
@@ -446,14 +446,15 @@
LHS = Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(),
OpToken.getKind(), LHS.get(), RHS.get());
- // In this case, ActOnBinOp performed the CorrectDelayedTyposInExpr check.
- if (!getLangOpts().CPlusPlus)
- continue;
} else {
LHS = Actions.ActOnConditionalOp(OpToken.getLocation(), ColonLoc,
LHS.get(), TernaryMiddle.get(),
RHS.get());
}
+ // In this case, ActOnBinOp or ActOnConditionalOp performed the
+ // CorrectDelayedTyposInExpr check.
+ if (!getLangOpts().CPlusPlus)
+ continue;
}
// Ensure potential typos aren't left undiagnosed.
if (LHS.isInvalid()) {
Index: cfe/trunk/test/Sema/typo-correction.c
===================================================================
--- cfe/trunk/test/Sema/typo-correction.c
+++ cfe/trunk/test/Sema/typo-correction.c
@@ -65,3 +65,18 @@
void fn_with_unknown(int a, int b) {
fn_with_unknown(unknown, unknown | unknown); // expected-error 3 {{use of undeclared identifier}}
}
+
+// Two typos in a parenthesized expression or argument list with a conditional
+// expression caused a crash in C mode.
+//
+// r272587 fixed a similar bug for binary operations. The same fix was needed for
+// conditional expressions.
+
+int g(int x, int y) {
+ return x + y;
+}
+
+int h() {
+ g(x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
+ (x, 5 ? z : 0); // expected-error 2 {{use of undeclared identifier}}
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22930.66067.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160729/faea1507/attachment.bin>
More information about the cfe-commits
mailing list