On mainline we ICE on the following invalid code snippet:
=============================
int foo;
template<int> void foo() {}
=============================
The error message reads:
bug.cc:2: error: 'template<int <anonymous> > void foo()' redeclared
as different kind of symbol
bug.cc:1: error: previous declaration of 'int foo'
Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report, [etc.]
This is due to a problem in start_preparsed_function: When processing
the template declaration the call "push_template_decl (decl1);"
returns an error_mark_node, since "foo" is already declared as "int".
Since the error_mark_node is not handled, things go downhill from here.