From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10844 invoked by alias); 24 Nov 2004 23:18:13 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10808 invoked by uid 48); 24 Nov 2004 23:18:11 -0000 Date: Wed, 24 Nov 2004 23:18:00 -0000 Message-ID: <20041124231811.10807.qmail@sourceware.org> From: "reichelt at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20041124172319.18652.reichelt@gcc.gnu.org> References: <20041124172319.18652.reichelt@gcc.gnu.org> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/18652] [4.0 regression] ICE on invalid redeclaration X-Bugzilla-Reason: CC X-SW-Source: 2004-11/txt/msg02991.txt.bz2 List-Id: ------- 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