This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix PR c++/19980: ICE on invalid template declaration


Volker Reichelt wrote:
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.

Ugh.


The right fix for this might really be to have start_preparsed function return false in this case (it presently does not have a return value), after popping any pushed context, and then have callers skip the body of the function. Trying to actually do anything in the body of such a function is risky.

But, that's too complicated for Stage 3. Your patch is OK.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]