This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c++/27423: ICE on default argument for void parameter
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 05 May 2006 13:59:16 +0200 (CEST)
- Subject: [patch] Fix PR c++/27423: ICE on default argument for void parameter
The C++ frontend ICEs on the following code snippet:
void foo(void = 0);
void bar() { foo(); }
PR27423.cc:1: error: '<anonymous>' has incomplete type
PR27423.cc:1: error: invalid use of 'void'
PR27423.cc: In function 'void bar()':
PR27423.cc:2: internal compiler error: tree check: expected class 'type',
have 'exceptional' (error_mark) in convert_for_initialization,
at cp/typeck.c:6235
Please submit a full bug report, [etc.]
When calling "foo()" we try to convert the default argument to the
appropriate type of the function argument. Alas, this is an
error_mark_node in this case. We already perform sanity-checks for
the rhs of the initialization. This patch below fixes the ICE by adding
a sanity-check also for the type of the lhs.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline?
Regards,
Volker
:ADDPATCH C++:
2006-05-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27423
* typeck.c (convert_for_initialization): Skip erroneous types.
===================================================================
--- gcc/gcc/cp/typeck.c 2006-05-05 02:29:45 +0200
+++ gcc/gcc/cp/typeck.c 2006-05-05 02:28:20 +0200
@@ -6181,7 +6181,8 @@ convert_for_initialization (tree exp, tr
&& codel != REFERENCE_TYPE)
rhs = TREE_OPERAND (rhs, 0);
- if (rhs == error_mark_node
+ if (type == error_mark_node
+ || rhs == error_mark_node
|| (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node))
return error_mark_node;
===================================================================
2006-05-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27423
* g++.dg/other/void2.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/other/void2.C 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/other/void2.C 2006-05-05 02:54:43 +0200
@@ -0,0 +1,5 @@
+// PR c++/27423
+// { dg-do compile }
+
+void foo(void = 0); // { dg-error "incomplete type|invalid use" }
+void bar() { foo(); }
===================================================================