Marek Polacek ae48b74ca0 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.
2020-11-19 14:00:41 -05:00
2020-11-17 00:16:27 +00:00
2020-11-19 00:16:30 +00:00
2020-10-30 00:16:29 +00:00
2020-11-12 00:16:39 +00:00
2020-11-19 07:05:08 -08:00
2020-11-19 00:16:30 +00:00
2020-11-02 20:53:00 +00:00
2020-11-19 00:16:30 +00:00
2020-11-14 00:16:38 +00:00
2020-11-19 00:16:30 +00:00
2020-11-14 00:16:38 +00:00
2020-11-16 12:52:43 +01:00
2020-11-17 00:16:27 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 2.1 GiB
Languages
C++ 31.9%
C 31.3%
Ada 12%
D 6.5%
Go 6.4%
Other 11.5%