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.

llvm-svn: 223705

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

index 583357e..a6ff02c 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 f7ef015..d303b58 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'?}}
+};