diff mbox

[C++] PR 60859

Message ID 547CA147.9020802@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 1, 2014, 5:11 p.m. UTC
Hi,

I'm pretty sure that we should accept this. Tested x86_64-linux.

Thanks,
Paolo.

////////////////////
/cp
2014-12-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60859
	* decl.c (reshape_init_r): Do not reject value-initialization of
	scalar array element.

/testsuite
2014-12-01  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/60859
	* g++.dg/cpp0x/initlist88.C: New.

Comments

Jason Merrill Dec. 1, 2014, 6 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 218217)
+++ cp/decl.c	(working copy)
@@ -5511,9 +5511,15 @@  reshape_init_r (tree type, reshape_iter *d, bool f
 	{
 	  if (SCALAR_TYPE_P (type))
 	    {
-	      if (complain & tf_error)
-		error ("braces around scalar initializer for type %qT", type);
-	      init = error_mark_node;
+	      if (cxx_dialect < cxx11
+		  /* Isn't value-initialization.  */
+		  || CONSTRUCTOR_NELTS (init) > 0)
+		{
+		  if (complain & tf_error)
+		    error ("braces around scalar initializer for type %qT",
+			   type);
+		  init = error_mark_node;
+		}
 	    }
 	  else
 	    maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
Index: testsuite/g++.dg/cpp0x/initlist88.C
===================================================================
--- testsuite/g++.dg/cpp0x/initlist88.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/initlist88.C	(working copy)
@@ -0,0 +1,4 @@ 
+// PR c++/60859
+// { dg-do compile { target c++11 } }
+
+int a[] = { {} };