c++: Fix up mangling ICE with void{} [PR106863]
authorJakub Jelinek <jakub@redhat.com>
Fri, 21 Oct 2022 07:00:41 +0000 (09:00 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 21 Oct 2022 07:00:41 +0000 (09:00 +0200)
commit5f9fac6ca86458ef21ab91ca471429d63f954003
tree9a76e76ff9cc24216013920e23ebf787d4040073
parent36ba985145ffa8e2078033fc1f1cf22851707a8e
c++: Fix up mangling ICE with void{} [PR106863]

We ICE on the following testcase during mangling, finish_compound_literal
returns for void{} void_node and the mangler doesn't handle it.
Handling void_node in the mangler seems problematic to me, because
we don't know for which case it has been created.
The following patch arranges to mangle it as other compound literals
with no operands, so it demangles as void{}, by returning a void type
COMPOUND_LITERAL_P with no elements if processing_template_decl.
Otherwise it keeps returning void_node.

2022-10-21  Jakub Jelinek  <jakub@redhat.com>

PR c++/106863
* semantics.cc (finish_compound_literal): For void{}, if
processing_template_decl return a COMPOUND_LITERAL_P
CONSTRUCTOR rather than void_node.

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