From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29529 invoked by alias); 19 Nov 2007 23:25:39 -0000 Received: (qmail 29515 invoked by uid 22791); 19 Nov 2007 23:25:39 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 19 Nov 2007 23:25:36 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lAJNLVo4013236; Mon, 19 Nov 2007 18:21:31 -0500 Received: from devserv.devel.redhat.com (devserv.devel.redhat.com [10.10.36.72]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lAJNLVnZ000405; Mon, 19 Nov 2007 18:21:31 -0500 Received: from devserv.devel.redhat.com (localhost.localdomain [127.0.0.1]) by devserv.devel.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id lAJNLVhS015459; Mon, 19 Nov 2007 18:21:31 -0500 Received: (from jakub@localhost) by devserv.devel.redhat.com (8.12.11.20060308/8.12.11/Submit) id lAJNLVRC015457; Mon, 19 Nov 2007 18:21:31 -0500 Date: Tue, 20 Nov 2007 10:14:00 -0000 From: Jakub Jelinek To: Jason Merrill , Mark Mitchell Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Avoid ice-on-invalid in xref_basetypes (PR c++/34089) Message-ID: <20071119232131.GL5451@devserv.devel.redhat.com> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-11/txt/msg01045.txt.bz2 Hi! xref_basetypes relies on the first argument being aggregate type, but on invalid testcases like the attached one cp_parser_class_specifier can contain various other types (in this case LANG_TYPE - a type of OVERLOAD). As begin_class_definition has all the needed code to report diagnostics and have sane error recovery and cp_parser_class_specifier calls it shortly after this, I think the best fix for this is instead of duplicating such checks and error recovery just not call xref_basetypes for non-aggregates at all and just let begin_class_definition do its job. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2007-11-19 Jakub Jelinek PR c++/34089 * parser.c (cp_parser_class_specifier): Don't call xref_basetypes if type is not aggregate type. * g++.dg/template/crash74.C: New test. --- gcc/cp/parser.c.jj 2007-11-08 01:19:18.000000000 +0100 +++ gcc/cp/parser.c 2007-11-19 17:47:34.000000000 +0100 @@ -14134,7 +14134,7 @@ cp_parser_class_specifier (cp_parser* pa /* Process the base classes. If they're invalid, skip the entire class body. */ - if (!xref_basetypes (type, bases)) + if (IS_AGGR_TYPE (type) && !xref_basetypes (type, bases)) { /* Consuming the closing brace yields better error messages later on. */ --- gcc/testsuite/g++.dg/template/crash74.C.jj 2007-11-19 17:53:27.000000000 +0100 +++ gcc/testsuite/g++.dg/template/crash74.C 2007-11-19 17:54:38.000000000 +0100 @@ -0,0 +1,6 @@ +// PR c++/34089 +// { dg-do compile } +// { dg-options "" } + +template void foo () { } +template struct foo { }; // { dg-error "template class without a name|abstract decl" } Jakub