diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-07 20:36:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-07 20:36:12 +0000 |
commit | 5ca153f112ce478e4fed668f1351eb6fdb749704 (patch) | |
tree | 6f1e8f02895143506c03ce831655c2cb30ae8bed | |
parent | 5a43b461fc5c8278ccbcfd0f9328ffadbf74ab75 (diff) | |
download | bcm5719-llvm-5ca153f112ce478e4fed668f1351eb6fdb749704.tar.gz bcm5719-llvm-5ca153f112ce478e4fed668f1351eb6fdb749704.zip |
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>.
llvm-svn: 139253
-rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaCXX/member-init.cpp | 18 |
2 files changed, 21 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index e400ed1391d..3abb0c5cbf6 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/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/clang/test/SemaCXX/member-init.cpp b/clang/test/SemaCXX/member-init.cpp index 7ca1f0e4513..192851460cf 100644 --- a/clang/test/SemaCXX/member-init.cpp +++ b/clang/test/SemaCXX/member-init.cpp @@ -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(...) { + } +} |