------- Additional Comments From reichelt at gcc dot gnu dot org 2004-11-24
23:18 -------
IMHO duplicate_decls and/or its callers are broken.
The comment on top of duplicate_decls reads:
/* If NEWDECL is a redeclaration of OLDDECL, merge the declarations.
If the redeclaration is invalid, a diagnostic is issued, and the
error_mark_node is returned. Otherwise, OLDDECL is returned.
If NEWDECL is not a redeclaration of OLDDECL, NULL_TREE is
returned. */
tree
duplicate_decls (tree newdecl, tree olddecl)
But in many situations we return a NULL_TREE, if an error occurred. In fact
we only return an error_mark_node twice. In the first case this leads to
the ICE:
error ("%q#D redeclared as different kind of symbol", newdecl);
if (TREE_CODE (olddecl) == TREE_LIST)
olddecl = TREE_VALUE (olddecl);
cp_error_at ("previous declaration of %q#D", olddecl);
return error_mark_node;
Changing the error_mark_node into NULL_TREE in fact makes the ICE go away.
However, that causes a minor regression in the testsuite:
FAIL: g++.dg/other/error8.C duplicate error messages (test for bogus messages,
line 8)
FAIL: g++.dg/other/error8.C duplicate error messages (test for bogus messages,
line 9)
Looks like the right fix is to make duplicate_decls behave like the comment
says and teach the callers how to handle error_mark_node.
Maybe this even fixes the triple error message in PR18625.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18652