Commit d5449acf by Jason Merrill Committed by Jason Merrill

DR 1467 PR c++/51747

	DR 1467
	PR c++/51747
	* typeck2.c (digest_init_r): Fix single element list.

From-SVN: r222881
parent a3facd7c
2015-05-07 Jason Merrill <jason@redhat.com>
DR 1467
PR c++/51747
* typeck2.c (digest_init_r): Fix single element list.
2015-05-05 Jason Merrill <jason@redhat.com> 2015-05-05 Jason Merrill <jason@redhat.com>
* cp-gimplify.c (cp_genericize_r): Track TRY_BLOCK and * cp-gimplify.c (cp_genericize_r): Track TRY_BLOCK and
......
...@@ -1096,6 +1096,19 @@ digest_init_r (tree type, tree init, bool nested, int flags, ...@@ -1096,6 +1096,19 @@ digest_init_r (tree type, tree init, bool nested, int flags,
|| TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == COMPLEX_TYPE); || TREE_CODE (type) == COMPLEX_TYPE);
/* "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." */
if (cxx_dialect >= cxx11
&& BRACE_ENCLOSED_INITIALIZER_P (init)
&& CONSTRUCTOR_NELTS (init) == 1
&& (CLASS_TYPE_P (type) || VECTOR_TYPE_P (type)))
{
tree elt = CONSTRUCTOR_ELT (init, 0)->value;
if (reference_related_p (type, TREE_TYPE (elt)))
init = elt;
}
if (BRACE_ENCLOSED_INITIALIZER_P (init) if (BRACE_ENCLOSED_INITIALIZER_P (init)
&& !TYPE_NON_AGGREGATE_CLASS (type)) && !TYPE_NON_AGGREGATE_CLASS (type))
return process_init_constructor (type, init, complain); return process_init_constructor (type, init, complain);
......
// PR c++/51747
// { dg-do compile { target c++11 } }
struct B {};
struct D : B {D(B b) : B{b} {}};
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