]> granicus.if.org Git - clang/commitdiff
When parsing a function-try-block that does not have a
authorDouglas Gregor <dgregor@apple.com>
Wed, 7 Sep 2011 20:36:12 +0000 (20:36 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 7 Sep 2011 20:36:12 +0000 (20:36 +0000)
ctor-initializer, remember to call the Sema action to generate default
ctor-initializers. What a delightful little miscompile. Fixes PR10578
/ <rdar://problem/9877267>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139253 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseStmt.cpp
test/SemaCXX/member-init.cpp

index e400ed1391d2c1317bd236935355ea5911d7b51c..3abb0c5cbf63b8ffdbd5697cc26fc0125a671b92 100644 (file)
@@ -1856,7 +1856,9 @@ Decl *Parser::ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope) {
   // Constructor initializer list?
   if (Tok.is(tok::colon))
     ParseConstructorInitializer(Decl);
-
+  else
+    Actions.ActOnDefaultCtorInitializers(Decl);
+  
   if (PP.isCodeCompletionEnabled()) {
     if (trySkippingFunctionBodyForCodeCompletion()) {
       BodyScope.Exit();
index 7ca1f0e4513e4740b1629ed61762f72c5d643bfd..192851460cf67f7f6e14bc9f4dcb8d9186bf204d 100644 (file)
@@ -52,3 +52,21 @@ struct CheckExcSpecFail {
 struct TypedefInit {
   typedef int A = 0; // expected-error {{illegal initializer}}
 };
+
+// PR10578 / <rdar://problem/9877267>
+namespace PR10578 {
+  template<typename T>
+  struct X { 
+    X() {
+      T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}}
+    }
+  };
+
+  struct Y : X<int> {
+    Y();
+  };
+
+  Y::Y() try { // expected-note{{in instantiation of member function 'PR10578::X<int>::X' requested here}}
+  } catch(...) {
+  }
+}