From: Paolo Carlini Date: Mon, 1 Dec 2014 18:52:05 +0000 (+0000) Subject: re PR c++/60859 (Value-initialization of scalar in aggregate yields "braces around... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ad1f2178c1843170c80c027f62594dba3c600d69;p=gcc.git re PR c++/60859 (Value-initialization of scalar in aggregate yields "braces around scalar initializer") /cp 2014-12-01 Paolo Carlini PR c++/60859 * decl.c (reshape_init_r): Do not reject value-initialization of scalar array element. /testsuite 2014-12-01 Paolo Carlini PR c++/60859 * g++.dg/cpp0x/initlist88.C: New. From-SVN: r218244 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 93780c0a6a8..10f3c1712f8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-12-01 Paolo Carlini + + PR c++/60859 + * decl.c (reshape_init_r): Do not reject value-initialization of + scalar array element. + 2014-12-01 Marek Polacek PR sanitizer/63956 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 455097e1182..716ab5f720c 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e15dc7913f3..3f14726007c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-01 Paolo Carlini + + PR c++/60859 + * g++.dg/cpp0x/initlist88.C: New. + 2014-12-01 Kyrylo Tkachov * 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 index 00000000000..d0a38fd4f65 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/initlist88.C @@ -0,0 +1,4 @@ +// PR c++/60859 +// { dg-do compile { target c++11 } } + +int a[] = { {} };