diff mbox

C++ PATCH for c++/51747 (list-initialization from same type)

Message ID alpine.DEB.2.02.1404152253240.31023@stedding.saclay.inria.fr
State New
Headers show

Commit Message

Marc Glisse April 15, 2014, 8:58 p.m. UTC
On Tue, 15 Apr 2014, Jason Merrill wrote:

> It's just vectors, because they're an extension; the patch I checked in 
> covered the standard language.

Like this? (regtested on x86_64-linux-gnu)

2014-04-16  Marc Glisse  <marc.glisse@inria.fr>

gcc/cp/
 	* decl.c (reshape_init_r): Handle a single element of vector type.
gcc/testsuite/
 	* g++.dg/cpp0x/initlist-vect.C: New file.

Comments

Jason Merrill April 16, 2014, 4:46 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: gcc/cp/decl.c
===================================================================
--- gcc/cp/decl.c	(revision 209434)
+++ gcc/cp/decl.c	(working copy)
@@ -5400,21 +5400,21 @@  reshape_init_r (tree type, reshape_iter
 	    maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
 	}
 
       d->cur++;
       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)
+  if (cxx_dialect >= cxx11 && (CLASS_TYPE_P (type) || VECTOR_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]
 
Index: gcc/testsuite/g++.dg/cpp0x/initlist-vect.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/initlist-vect.C	(revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/initlist-vect.C	(working copy)
@@ -0,0 +1,6 @@ 
+// { dg-do compile { target c++11 } }
+
+typedef float X __attribute__ ((vector_size (4 * sizeof (float))));
+
+X x;
+X x2{x};