aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2020-11-18 19:07:07 -0500
committerMarek Polacek <polacek@redhat.com>2020-11-19 14:00:41 -0500
commitae48b74ca0c0ba33d396a6ebad7a1c0a6dadb1f7 (patch)
tree115dc14a237f248003d2f6e875dd29931a089ea9 /gcc/c/c-decl.c
parent25056bdf94d5f3e66bef039702f7fae799ef16b9 (diff)
downloadgcc-ae48b74ca0c0ba33d396a6ebad7a1c0a6dadb1f7.zip
gcc-ae48b74ca0c0ba33d396a6ebad7a1c0a6dadb1f7.tar.gz
gcc-ae48b74ca0c0ba33d396a6ebad7a1c0a6dadb1f7.tar.bz2
c++: Fix array new with value-initialization [PR97523]
Since my r11-3092 the following is rejected with -std=c++20: struct T { explicit T(); }; void fn(int n) { new T[1](); } with "would use explicit constructor 'T::T()'". It is because since that change we go into the P1009 block in build_new (array_p is false, but nelts is non-null and we're in C++20). Since we only have (), we build a {} and continue to build_new_1, which then calls build_vec_init and then we error because the {} isn't CONSTRUCTOR_IS_DIRECT_INIT. For (), which is value-initializing, we want to do what we were doing before: pass empty init and let build_value_init take care of it. For various reasons I wanted to dig a little bit deeper into this, and as a result, I'm adding a test for [expr.new]/24 (and checked that out current behavior matches clang++). gcc/cp/ChangeLog: PR c++/97523 * init.c (build_new): When value-initializing an array new, leave the INIT as an empty vector. gcc/testsuite/ChangeLog: PR c++/97523 * g++.dg/expr/anew5.C: New test. * g++.dg/expr/anew6.C: New test.
Diffstat (limited to 'gcc/c/c-decl.c')
0 files changed, 0 insertions, 0 deletions