From: Kaelyn Takata Date: Mon, 8 Dec 2014 22:41:42 +0000 (+0000) Subject: Handle possible TypoExprs in member initializers. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a15a6dc78e46163bf10aa28fe05cb646a6d23b6e;p=platform%2Fupstream%2Fllvm.git Handle possible TypoExprs in member initializers. Includes a new test case since none of the existing tests were hitting this code path. llvm-svn: 223705 --- diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 583357e..a6ff02c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/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/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index f7ef015..d303b58 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/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'?}} +};