From 2eef427c8666cbe9a3cad40d4947c67c3ba0c400 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Wed, 7 Sep 2011 20:36:12 +0000 Subject: [PATCH] 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 / . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139253 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseStmt.cpp | 4 +++- test/SemaCXX/member-init.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index e400ed1391..3abb0c5cbf 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -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(); diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp index 7ca1f0e451..192851460c 100644 --- a/test/SemaCXX/member-init.cpp +++ b/test/SemaCXX/member-init.cpp @@ -52,3 +52,21 @@ struct CheckExcSpecFail { struct TypedefInit { typedef int A = 0; // expected-error {{illegal initializer}} }; + +// PR10578 / +namespace PR10578 { + template + struct X { + X() { + T* x = 1; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} + } + }; + + struct Y : X { + Y(); + }; + + Y::Y() try { // expected-note{{in instantiation of member function 'PR10578::X::X' requested here}} + } catch(...) { + } +} -- 2.40.0