Commit 1c982d13 by Jason Merrill Committed by Jason Merrill

DR 1467 PR c++/51747

	DR 1467
	PR c++/51747
	* decl.c (reshape_init_r): Handle a single element of class type.

From-SVN: r209314
parent 7d0039a6
2014-04-11 Jason Merrill <jason@redhat.com>
DR 1467
PR c++/51747
* decl.c (reshape_init_r): Handle a single element of class type.
DR 1338
* decl.c (cxx_init_decl_processing): Set DECL_IS_MALLOC on
built-in operator new.
......
......@@ -5405,6 +5405,18 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p,
return init;
}
/* "If T is a class type and the initializer list has a single element of
type cv U, where U is T or a class derived from T, the object is
initialized from that element." Even if T is an aggregate. */
if (cxx_dialect >= cxx11 && CLASS_TYPE_P (type)
&& first_initializer_p
&& d->end - d->cur == 1
&& reference_related_p (type, TREE_TYPE (init)))
{
d->cur++;
return init;
}
/* [dcl.init.aggr]
All implicit type conversions (clause _conv_) are considered when
......
// DR 1467, c++/51747
// { dg-do compile { target c++11 } }
struct X { };
X x;
X x2{x};
......@@ -4,4 +4,4 @@ struct A
};
A a1 = { 1 }; // ok
A a2 = { a1 }; // { dg-error "cannot convert" }
A a2 = { a1 }; // { dg-error "cannot convert" "" { target { ! c++11 } } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment