From 3734964fdc273c28f7c8a20afa9022704fc9813a Mon Sep 17 00:00:00 2001 From: Dinar Temirbulatov Date: Wed, 23 Apr 2014 23:34:08 +0400 Subject: [PATCH] Fix for c++/PR57958 From-SVN: r209721 --- gcc/cp/ChangeLog | 6 +++++ gcc/cp/semantics.c | 2 ++ gcc/testsuite/g++.dg/cpp0x/pr57958.C | 39 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr57958.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 854cc4b21a4..072195bddae 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-04-23 Dinar Temirbulatov + + PR c++/57958 + * semantics.c (apply_deduced_return_type): Complete non-void type + before estimating whether the type is aggregate. + 2014-04-22 Marc Glisse PR libstdc++/43622 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 795086a5854..3f8ca44904e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10650,6 +10650,8 @@ apply_deduced_return_type (tree fco, tree return_type) if (!processing_template_decl) { + if (!VOID_TYPE_P (TREE_TYPE (result))) + complete_type_or_else (TREE_TYPE (result), NULL_TREE); bool aggr = aggregate_value_p (result, fco); #ifdef PCC_STATIC_STRUCT_RETURN cfun->returns_pcc_struct = aggr; diff --git a/gcc/testsuite/g++.dg/cpp0x/pr57958.C b/gcc/testsuite/g++.dg/cpp0x/pr57958.C new file mode 100644 index 00000000000..d35f9edf2ae --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr57958.C @@ -0,0 +1,39 @@ +// { dg-do run { target c++11 } } + +#define assert(E) if(!(E))__builtin_abort(); + +int n = 0; + +template +class Foo { + public: + Foo() { + n--; + } + Foo(const Foo&) { + n--; + } + ~Foo() { + n++; + } +}; + +struct Data {}; + +void a() +{ + Data b; +} + +int main(int argc, char *argv[]) { + auto fn = [] (const Foo& x) { + return (x); + }; + + { + Foo a; + fn(a); + } + + assert(n == 0); +} -- 2.30.2