aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-10-21 09:00:41 +0200
committerJakub Jelinek <jakub@redhat.com>2022-10-21 09:00:41 +0200
commit5f9fac6ca86458ef21ab91ca471429d63f954003 (patch)
tree9a76e76ff9cc24216013920e23ebf787d4040073 /gcc/cp/semantics.cc
parent36ba985145ffa8e2078033fc1f1cf22851707a8e (diff)
downloadgcc-5f9fac6ca86458ef21ab91ca471429d63f954003.zip
gcc-5f9fac6ca86458ef21ab91ca471429d63f954003.tar.gz
gcc-5f9fac6ca86458ef21ab91ca471429d63f954003.tar.bz2
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.
Diffstat (limited to 'gcc/cp/semantics.cc')
-rw-r--r--gcc/cp/semantics.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 7d46c3c..82f9dd8 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -3164,7 +3164,14 @@ finish_compound_literal (tree type, tree compound_literal,
{
/* DR2351 */
if (VOID_TYPE_P (type) && CONSTRUCTOR_NELTS (compound_literal) == 0)
- return void_node;
+ {
+ if (!processing_template_decl)
+ return void_node;
+ TREE_TYPE (compound_literal) = type;
+ TREE_HAS_CONSTRUCTOR (compound_literal) = 1;
+ CONSTRUCTOR_IS_DEPENDENT (compound_literal) = 0;
+ return compound_literal;
+ }
else if (VOID_TYPE_P (type)
&& processing_template_decl
&& maybe_zero_constructor_nelts (compound_literal))