diff options
author | Dinar Temirbulatov <dtemirbulatov@gmail.com> | 2014-04-23 23:34:08 +0400 |
---|---|---|
committer | Dinar Temirbulatov <dinar@gcc.gnu.org> | 2014-04-23 23:34:08 +0400 |
commit | 3734964fdc273c28f7c8a20afa9022704fc9813a (patch) | |
tree | 4b1f913be7f936221be60bee7b9466731154e43e | |
parent | 7de90a6c2758d158283211ac98fea71dd1483831 (diff) | |
download | gcc-3734964fdc273c28f7c8a20afa9022704fc9813a.zip gcc-3734964fdc273c28f7c8a20afa9022704fc9813a.tar.gz gcc-3734964fdc273c28f7c8a20afa9022704fc9813a.tar.bz2 |
Fix for c++/PR57958
From-SVN: r209721
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/pr57958.C | 39 |
3 files changed, 47 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 854cc4b..072195b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-04-23 Dinar Temirbulatov <dtemirbulatov@gmail.com> + + 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 <marc.glisse@inria.fr> PR libstdc++/43622 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 795086a..3f8ca44 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 0000000..d35f9ed --- /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 T> +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<Data>& x) { + return (x); + }; + + { + Foo<Data> a; + fn(a); + } + + assert(n == 0); +} |