]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Implement DR2351 - void{} [PR102820]
authorJakub Jelinek <jakub@redhat.com>
Fri, 29 Oct 2021 07:28:32 +0000 (09:28 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 29 Oct 2021 07:28:32 +0000 (09:28 +0200)
commiteca767aa51d1f69614222ceb130ca6bb07713232
tree6fd22f2e45dab8a8542eeeff6ace686b4dd9e035
parent146b83e14a0a76a9ce8a4cb79997a078f437f779
c++: Implement DR2351 - void{} [PR102820]

Here is an implementation of DR2351 - void{} - where void{} after
pack expansion is considered valid and the same thing as void().
For templates, if CONSTRUCTOR_NELTS is 0, the CONSTRUCTOR is not dependent
and we can return void_node right away, if it is dependent and contains
only packs, then it is potentially zero element and so we need to build
CONSTRUCTOR_IS_DEPENDENT CONSTRUCTOR, while if it contains any non-pack
elts, we can diagnose it right away.

2021-10-29  Jakub Jelinek  <jakub@redhat.com>

PR c++/102820
* semantics.c (maybe_zero_constructor_nelts): New function.
(finish_compound_literal): Implement DR2351 - void{}.
If type is cv void and compound_literal has no elements, return
void_node.  If type is cv void and compound_literal might have no
elements after expansion, handle it like other dependent compound
literals.

* g++.dg/cpp0x/dr2351.C: New test.
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp0x/dr2351.C [new file with mode: 0644]