From patchwork Thu Dec 2 17:22:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 74001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E51C7B70A9 for ; Fri, 3 Dec 2010 04:23:07 +1100 (EST) Received: (qmail 2687 invoked by alias); 2 Dec 2010 17:23:02 -0000 Received: (qmail 2662 invoked by uid 22791); 2 Dec 2010 17:23:01 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Dec 2010 17:22:57 +0000 Received: (qmail 1030 invoked from network); 2 Dec 2010 17:22:55 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 2 Dec 2010 17:22:55 -0000 Date: Thu, 2 Dec 2010 12:22:52 -0500 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] fix PR c/45062, ICE when parsing invalid declaration parameter list Message-ID: <20101202172251.GA18963@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The patch below fixes PR 45062, a bit of DECL_CHAIN fallout. The problem was that in grokparms, we did: else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE) { if (!funcdef_flag) pedwarn (input_location, 0, "parameter names (without types) in function declaration"); arg_info->parms = arg_info->types; arg_info->types = 0; return 0; } which is somewhat dodgy, as arg_info->parms is logically a list of DECLs and we were setting it to a TREE_LIST. With the stricter checking provided by DECL_CHAIN, we blew up later on. The approach I took was simply to NULL out ->parms in the pedwarn case. It would have been nice to NULL it out regardless, but K&R argument list handling groks ->parms as TREE_LIST, so the assignment needs to remain in the non-pedwarn case. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan PR c/45062 * c-decl.c (grokparms): Set arg_info->parms to NULL_TREE when !funcdef_flag. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index b1055b0..ac8f020 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -6131,9 +6131,13 @@ grokparms (struct c_arg_info *arg_info, bool funcdef_flag) else if (arg_types && TREE_CODE (TREE_VALUE (arg_types)) == IDENTIFIER_NODE) { if (!funcdef_flag) - pedwarn (input_location, 0, "parameter names (without types) in function declaration"); + { + pedwarn (input_location, 0, "parameter names (without types) in function declaration"); + arg_info->parms = NULL_TREE; + } + else + arg_info->parms = arg_info->types; - arg_info->parms = arg_info->types; arg_info->types = 0; return 0; }