]> granicus.if.org Git - clang/commitdiff
Handle possible TypoExprs in member initializers.
authorKaelyn Takata <rikka@google.com>
Mon, 8 Dec 2014 22:41:42 +0000 (22:41 +0000)
committerKaelyn Takata <rikka@google.com>
Mon, 8 Dec 2014 22:41:42 +0000 (22:41 +0000)
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

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/typo-correction-delayed.cpp

index 583357e234880621e3906ca510fdaf287b3d675b..a6ff02cc07d55dc54881cd27096084e783113bf8 100644 (file)
@@ -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;
 
index f7ef01542e77afa4856463a77961e86a2ed9aa6e..d303b58554d49a3b990625910f49544d1c820078 100644 (file)
@@ -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'?}}
+};