From a934c31d1056429a1e32fbcd198b4c5d0a42d84e Mon Sep 17 00:00:00 2001 From: Kaelyn Uhrain Date: Thu, 26 Sep 2013 21:13:05 +0000 Subject: [PATCH] Fix error recovery when a return type correction includes a new name specifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191459 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDecl.cpp | 7 ++++++- test/SemaCXX/typo-correction-pt2.cpp | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5997abe029..62f65a580e 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -426,8 +426,13 @@ bool Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II, llvm_unreachable("could not have corrected a typo here"); } + CXXScopeSpec tmpSS; + if (Corrected.getCorrectionSpecifier()) + tmpSS.MakeTrivial(Context, Corrected.getCorrectionSpecifier(), + SourceRange(IILoc)); SuggestedType = getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), - IILoc, S, SS, false, false, ParsedType(), + IILoc, S, tmpSS.isSet() ? &tmpSS : SS, false, + false, ParsedType(), /*IsCtorOrDtorName=*/false, /*NonTrivialTypeSourceInfo=*/true); } diff --git a/test/SemaCXX/typo-correction-pt2.cpp b/test/SemaCXX/typo-correction-pt2.cpp index f475b41a9f..543a5823f7 100644 --- a/test/SemaCXX/typo-correction-pt2.cpp +++ b/test/SemaCXX/typo-correction-pt2.cpp @@ -47,9 +47,7 @@ public: }; Inner Outer::MyMethod(Inner arg) { // expected-error {{unknown type name 'Inner'; did you mean 'Outer::Inner'?}} - // TODO: Recovery needs to be fixed/added for the typo-correction of the - // return type so the below error isn't still generated. - return Inner(); // expected-error {{no viable conversion from 'class_member_typo_corrections::Outer::Inner' to 'int'}} + return Inner(); } class Result { -- 2.50.1