[patch] Fix PR c++/30021: ICE on invalid parameter for main
reichelt@igpm.rwth-aachen.de
reichelt@igpm.rwth-aachen.de
Wed Nov 29 21:47:00 GMT 2006
The following code snippet crashes the C++ frontend on mainline:
int main(void,char**);
bug.cc:1: error: '<anonymous>' has incomplete type
bug.cc:1: error: invalid use of 'void'
bug.cc:1: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in check_main_parameter_types, at
c-common.c:1044
Please submit a full bug report, [etc.]
This problem appeared with the introduction of check_main_parameter_types.
The following patch fixes it by skipping the checks when an error_mark_node
is encountered as argument to main. The compiler already complained and
no additional diagnostic is required.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?
Regards,
Volker
:ADDPATCH C++:
2006-11-25 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/30021
* c-common.c (check_main_parameter_types): Check for error_mark_node.
=======================================================================
--- gcc/gcc/c-common.c 2006-11-10 19:22:19 +0100
+++ gcc/gcc/c-common.c 2006-11-25 17:15:26 +0100
@@ -1061,7 +1061,7 @@ check_main_parameter_types (tree decl)
{
tree type = args ? TREE_VALUE (args) : 0;
- if (type == void_type_node)
+ if (type == void_type_node || type == error_mark_node )
break;
++argct;
=======================================================================
2006-11-25 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/30021
* g++.dg/other/main1.C: New test.
=======================================================================
--- gcc/gcc/testsuite/g++.dg/other/main1.C 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/other/main1.C 2006-11-25 17:20:08 +0100
@@ -0,0 +1,4 @@
+// PR c++/30021
+// { dg-do compile }
+
+int main(void,char**); // { dg-error "incomplete type|invalid use" }
=======================================================================
More information about the Gcc-patches
mailing list