Correct more typos in conditional expressions

We didn't correctly handle some edge cases, causing us to bail out
before correcting all the typos.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261109 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2016-02-17 17:19:00 +00:00
Родитель adf405e2a8
Коммит de18bd8785
4 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -449,9 +449,11 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) {
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 } else {
// Ensure potential typos in the RHS aren't left undiagnosed. // Ensure potential typos aren't left undiagnosed.
Actions.CorrectDelayedTyposInExpr(TernaryMiddle);
Actions.CorrectDelayedTyposInExpr(RHS); Actions.CorrectDelayedTyposInExpr(RHS);
}
} }
} }

Просмотреть файл

@ -6838,8 +6838,23 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
// doesn't handle dependent types properly, so make sure any TypoExprs have // doesn't handle dependent types properly, so make sure any TypoExprs have
// been dealt with before checking the operands. // been dealt with before checking the operands.
ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr); ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
if (!CondResult.isUsable()) return ExprError(); ExprResult LHSResult = CorrectDelayedTyposInExpr(LHSExpr);
ExprResult RHSResult = CorrectDelayedTyposInExpr(RHSExpr);
if (!CondResult.isUsable())
return ExprError();
if (LHSExpr) {
if (!LHSResult.isUsable())
return ExprError();
}
if (!RHSResult.isUsable())
return ExprError();
CondExpr = CondResult.get(); CondExpr = CondResult.get();
LHSExpr = LHSResult.get();
RHSExpr = RHSResult.get();
} }
// If this is the gnu "x ?: y" extension, analyze the types as though the LHS // If this is the gnu "x ?: y" extension, analyze the types as though the LHS

Просмотреть файл

@ -55,3 +55,5 @@ void fn2() {
f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}} f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}} afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
} }
int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}

Просмотреть файл

@ -663,3 +663,5 @@ class Bar : public A::B::Foofoo {};
using C::D::Foofoo; // expected-error {{no member named 'Foofoo' in namespace 'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}} using C::D::Foofoo; // expected-error {{no member named 'Foofoo' in namespace 'PR24781_using_crash::C::D'; did you mean 'A::B::Foofoo'?}}
} }
int d = ? L : d; // expected-error {{expected expression}} expected-error {{undeclared identifier}}