re PR c++/60859 (Value-initialization of scalar in aggregate yields "braces around...
authorPaolo Carlini <paolo.carlini@oracle.com>
Mon, 1 Dec 2014 18:52:05 +0000 (18:52 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Mon, 1 Dec 2014 18:52:05 +0000 (18:52 +0000)
/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.

From-SVN: r218244

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/initlist88.C [new file with mode: 0644]

index 93780c0..10f3c17 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2014-12-01  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/63956
index 455097e..716ab5f 100644 (file)
@@ -5511,9 +5511,15 @@ reshape_init_r (tree type, reshape_iter *d, bool first_initializer_p,
        {
          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 e15dc79..3f14726 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-01  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/60859
+       * g++.dg/cpp0x/initlist88.C: New.
+
 2014-12-01  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * gcc.target/aarch64/fuse_adrp_add_1.c: Gate test on aarch64_small.
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist88.C b/gcc/testsuite/g++.dg/cpp0x/initlist88.C
new file mode 100644 (file)
index 0000000..d0a38fd
--- /dev/null
@@ -0,0 +1,4 @@
+// PR c++/60859
+// { dg-do compile { target c++11 } }
+
+int a[] = { {} };