From: Kaelyn Takata Date: Mon, 8 Dec 2014 22:41:42 +0000 (+0000) Subject: Handle possible TypoExprs in member initializers. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e789aab6353992a7a2b63c1f66bb9f78a473ae75;p=clang Handle possible TypoExprs in member initializers. Includes a new test case since none of the existing tests were hitting this code path. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223705 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 583357e234..a6ff02cc07 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2813,6 +2813,11 @@ Sema::BuildMemInitializer(Decl *ConstructorD, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc) { + ExprResult Res = CorrectDelayedTyposInExpr(Init); + if (!Res.isUsable()) + return true; + Init = Res.get(); + if (!ConstructorD) return true; diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp index f7ef01542e..d303b58554 100644 --- a/test/SemaCXX/typo-correction-delayed.cpp +++ b/test/SemaCXX/typo-correction-delayed.cpp @@ -112,3 +112,10 @@ void test_paren_suffix() { foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}} \ // expected-error {{expected expression}} } + +const int kNum = 10; // expected-note {{'kNum' declared here}} +class SomeClass { + int Kind; +public: + explicit SomeClass() : Kind(kSum) {} // expected-error {{use of undeclared identifier 'kSum'; did you mean 'kNum'?}} +};