Fix for c++/PR57958

From-SVN: r209721
This commit is contained in:
Dinar Temirbulatov 2014-04-23 23:34:08 +04:00 committed by Dinar Temirbulatov
parent 7de90a6c27
commit 3734964fdc
3 changed files with 47 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);
}