From a4891bac9b285821ff2e23292db8037c0f336c78 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 16 Dec 2014 22:02:06 +0000 Subject: [PATCH] Look at whether TransformTypos returned a different Expr instead of looking at the number of uncorrected typos before and after. Correcting one typo may produce an expression with another TypoExpr in it, leading to matching counts even though a typo was corrected. Fixes PR21925! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224380 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 3 ++- test/SemaCXX/typo-correction-delayed.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 28fb0545ad..2d3d127618 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -6208,10 +6208,11 @@ ExprResult Sema::CorrectDelayedTyposInExpr( auto TyposResolved = DelayedTypos.size(); auto Result = TransformTypos(*this, Filter).Transform(E); TyposResolved -= DelayedTypos.size(); - if (TyposResolved) { + if (Result.isInvalid() || Result.get() != E) { ExprEvalContexts.back().NumTypos -= TyposResolved; return Result; } + assert(TyposResolved == 0 && "Corrected typo but got same Expr back?"); } return E; } diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp index 7879d299d0..c91fb6ca65 100644 --- a/test/SemaCXX/typo-correction-delayed.cpp +++ b/test/SemaCXX/typo-correction-delayed.cpp @@ -130,3 +130,16 @@ void UseOverload() { // expected-error@+1 {{use of undeclared identifier 'resulta'; did you mean 'result'?}} Overload(resulta); } + +namespace PR21925 { +struct X { + int get() { return 7; } // expected-note {{'get' declared here}} +}; +void test() { + X variable; // expected-note {{'variable' declared here}} + + // expected-error@+2 {{use of undeclared identifier 'variableX'; did you mean 'variable'?}} + // expected-error@+1 {{no member named 'getX' in 'PR21925::X'; did you mean 'get'?}} + int x = variableX.getX(); +} +} -- 2.40.0