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 93780c0a6a894662ee658d22a7175f5296ecac52..10f3c1712f8f17a1935a9119e29c5e0df5331aa4 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 455097e1182bb1a70a8fad41298eda97477f6c7d..716ab5f720c2aa6a2737f58b532b414f7a68d1b7 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 e15dc7913f3588dedefbc56d8e4166c4c39d503c..3f14726007c39aa83ebbee3051b89516e9ffde77 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[] = { {} };