Index: lib/Parse/ParseExpr.cpp =================================================================== --- lib/Parse/ParseExpr.cpp +++ 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: test/Sema/typo-correction.c =================================================================== --- test/Sema/typo-correction.c +++ 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}} +}