When parsing a function-try-block that does not have a
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
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index e400ed1..3abb0c5 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1856,7 +1856,9 @@
// Constructor initializer list?
if (Tok.is(tok::colon))
ParseConstructorInitializer(Decl);
-
+ else
+ Actions.ActOnDefaultCtorInitializers(Decl);
+
if (PP.isCodeCompletionEnabled()) {
if (trySkippingFunctionBodyForCodeCompletion()) {
BodyScope.Exit();
diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp
index 7ca1f0e..1928514 100644
--- a/test/SemaCXX/member-init.cpp
+++ b/test/SemaCXX/member-init.cpp
@@ -52,3 +52,21 @@
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(...) {
+ }
+}