The following testcase causes an ICE on the 4.1 branch and mainline: ==================================== struct A { template<int> void foo(X); }; ==================================== bug.cc:7: error: 'X' was not declared in this scope bug.cc:7: error: variable or field 'foo' declared void bug.cc:7: internal compiler error: tree check: expected var_decl, have field_decl in cp_finish_decl, at cp/decl.c:4933 Please submit a full bug report, [etc.] This is a very recent regression, since GCC 4.1.1 is not affected. Mark, your patch for PR 27819 seems to have caused this: http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00198.html
Here's a testcase with a slightly different error message: ======================================== template<int> void f()(0); ======================================== bug.cc:1: error: function 'void f()' is initialized like a variable bug.cc:1: internal compiler error: tree check: expected var_decl, have function_decl in cp_finish_decl, at cp/decl.c:5083 Please submit a full bug report, [etc.]
A regression hunt on powerpc-linux using the testcase from the submitter's description identified the following patch: http://gcc.gnu.org/viewcvs?view=rev&rev=114119 r114119 | mmitchel | 2006-05-25 20:18:26 +0000 (Thu, 25 May 2006)
Reproduced by Janis.
Subject: Bug number PR c++/27961 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-09/msg01018.html
Subject: Bug 27961 Author: lmillward Date: Thu Oct 12 20:02:53 2006 New Revision: 117671 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117671 Log: PR c++/27961 * decl.c (start_decl): Return error_mark_node if a function is initialized like a variable. (check_var_type): If a variable of field is declared void, set the type to error_mark_node. (grokdeclarator): Check the return type of check_var_type. * class.c (finish_struct_1): Robustify. * g++.dg/template/crash60.C: New test. * g++.dg/other/large-size-array.C: Adjust error markers. * g++.dg/parse/crash27.C: Likewise. * g++.dg/template/crash1.C: Likewise. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/class.c trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/other/large-size-array.C trunk/gcc/testsuite/g++.dg/parse/crash27.C trunk/gcc/testsuite/g++.dg/template/crash1.C
Subject: Bug 27961 Author: lmillward Date: Thu Oct 12 20:06:36 2006 New Revision: 117672 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117672 Log: PR c++/27961 * g++.dg/template/crash60.C: New test. Added: trunk/gcc/testsuite/g++.dg/template/crash60.C
Fixed on mainline.
> Fixed on mainline. Alas this is only partially true: Although the original testcase is indeed fixed on mainline (and 4.2 branch), the following variant (which only differs in the return type of the template function) still crashes: ==================================== struct A { template<int> int foo(X); }; ==================================== I'll open a new PR for this failure. Btw, the testcase from comment #1 is also fixed on the 4.1 branch (with "void" or "int" as return type).
Closing 4.1 branch.