From patchwork Wed May 25 14:00:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 626191 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rFDTS1PCbz9sdb for ; Thu, 26 May 2016 00:01:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=ZfotKVyp; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=nB9Qzs95fu+50KPv3ABmB5YjUrrzGPy6yL/g4PO4q83IlMLcg1c/P 7MW7EHlsbesTksF4Fgf83Rb3fUuDvnbgQ6Vbn1M5EEEnSny4d6U9C2LZZCE/eRf+ glxLmHD0FtMMB0wCN3ohKeAqRgzq4iQvmwuBHC83sWwl9D9QcqZ3Ts= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=3ejmIz+wiB1bp1SOy4tE8JeaOew=; b=ZfotKVyppwjCUdoTk461 0R5TLPpICSPYdi7VuFCix3AAW9gJraf21nPJMsMAjUSLhtOw1oSOlTFsVpm4gZKY UCDWHCQ6CrlP4ImrnqjN+rKZfny14w+WCs3ShIfryCqJ696TN/LYZQLi8BJXf24K CZnrGw1R7qqUTOKf+DSCZdg= Received: (qmail 94268 invoked by alias); 25 May 2016 14:01:07 -0000 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 Received: (qmail 94255 invoked by uid 89); 25 May 2016 14:01:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=arising X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 25 May 2016 14:01:05 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABBBE12B36; Wed, 25 May 2016 14:01:03 +0000 (UTC) Received: from redhat.com (ovpn-204-26.brq.redhat.com [10.40.204.26]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4PE0xIp004753 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 25 May 2016 10:01:01 -0400 Date: Wed, 25 May 2016 16:00:59 +0200 From: Marek Polacek To: GCC Patches , Joseph Myers Subject: [C PATCH] Fix ICE-on-invalid with old-style-parameter-declaration and enum (PR c/71266) Message-ID: <20160525140058.GC17920@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) ICE-on-invalid on old-style-parameter-declaration arising from adding a bogus parameter to the vector of parameters (seen_args). Skipping such parameters prevents the ICE later on. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-05-25 Marek Polacek PR c/71266 * c-decl.c (store_parm_decls_oldstyle): Skip non-PARM_DECLs. * gcc.dg/noncompile/old-style-parm-3.c: New test. Marek diff --git gcc/c/c-decl.c gcc/c/c-decl.c index 9441fbb..96bd491 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -8605,8 +8605,11 @@ store_parm_decls_oldstyle (tree fndecl, const struct c_arg_info *arg_info) continue; /* If we got something other than a PARM_DECL it is an error. */ if (TREE_CODE (decl) != PARM_DECL) - error_at (DECL_SOURCE_LOCATION (decl), - "%qD declared as a non-parameter", decl); + { + error_at (DECL_SOURCE_LOCATION (decl), + "%qD declared as a non-parameter", decl); + continue; + } /* If the declaration is already marked, we have a duplicate name. Complain and ignore the duplicate. */ else if (seen_args.contains (decl)) diff --git gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c index e69de29..f9d6d0f 100644 --- gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c +++ gcc/testsuite/gcc.dg/noncompile/old-style-parm-3.c @@ -0,0 +1,9 @@ +/* PR c/71266 */ +/* { dg-do compile } */ + +int fn1 (a) + enum b { /* { dg-warning "empty declaration" } */ + a /* { dg-error ".a. declared as a non-parameter" } */ + }; +{ +}