From patchwork Tue Jun 7 12:44:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 631564 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 3rPB9c6ySQz9t2D for ; Tue, 7 Jun 2016 22:45:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=HeLDrP1Z; 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=NmnFcsgoc2pt2IG3SIc2vnzwyAHQPGmySaEr8ZuzuwPZ1ECuEskmU Q6PE5HzSExxXytPB6tfXhKns6FuPMPSDGPDsxtGNYlci5dBuwfLHVON/EiSDegab /kwtb+sHo64AMXsdYq5JXZd85u36D4UaX8xahhwIsu4gDkj/gQbkYQ= 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=GEDQ221Ab20mM/Rw6n5mQrPZY9M=; b=HeLDrP1Zfmk6LoCQKC0s t2uyOACSFW52w16xln4cvfQcz11ouuXz3pWK4EiDs4YGFhOKKrrUKOFNMKri8S0y /B0qhm+5i+Y4iVOIaJn6pKE3AgSBC1bxWFeAoTvPXqmHyKqoKHrkPH4A4OXunezh rTfXOjtR0u+P6c5qJfWoPAA= Received: (qmail 30814 invoked by alias); 7 Jun 2016 12:45:00 -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 30784 invoked by uid 89); 7 Jun 2016 12:44:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Tue, 07 Jun 2016 12:44:58 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 8647E187705; Tue, 7 Jun 2016 12:44:57 +0000 (UTC) Received: from redhat.com (ovpn-204-26.brq.redhat.com [10.40.204.26]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u57CisNi015137 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 7 Jun 2016 08:44:56 -0400 Date: Tue, 7 Jun 2016 14:44:53 +0200 From: Marek Polacek To: GCC Patches , Joseph Myers Subject: C PATCH for c/71426 (ICE with bogus parameter) Message-ID: <20160607124453.GZ3014@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) cc1 crashed on the following invalid code, because it tripped this assert. The reason why b->nested was false for the FUNCTION_DECL 'x' was that when doing pushdecl, we found an incompatible duplicate, so pushdecl just bound 'x' to FUNCTION_DECL 'x', replacing the old binding, without the TREE_PUBLIC test that sets 'nested'. At first I thought about removing the assert but in the end I decided to add || seen_error -- for invalid code we might do the same as for ERROR_MARK. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2016-06-07 Marek Polacek PR c/71426 * c-decl.c (get_parm_info): Don't crash on an assert on invalid code. * gcc.dg/noncompile/pr71426.c: New test. Marek diff --git gcc/c/c-decl.c gcc/c/c-decl.c index d79802e..8ceb8ba 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -7054,9 +7054,9 @@ get_parm_info (bool ellipsis, tree expr) break; case FUNCTION_DECL: - /* FUNCTION_DECLs appear when there is an implicit function - declaration in the parameter list. */ - gcc_assert (b->nested); + /* FUNCTION_DECLs appear when there is an implicit function + declaration in the parameter list. */ + gcc_assert (b->nested || seen_error ()); goto set_shadowed; case CONST_DECL: diff --git gcc/testsuite/gcc.dg/noncompile/pr71426.c gcc/testsuite/gcc.dg/noncompile/pr71426.c index e69de29..874e189 100644 --- gcc/testsuite/gcc.dg/noncompile/pr71426.c +++ gcc/testsuite/gcc.dg/noncompile/pr71426.c @@ -0,0 +1,5 @@ +/* PR c/71426 */ +/* { dg-do compile } */ +/* { dg-options "-w" } */ + +int f (int x[x - x ()]); /* { dg-error "undeclared" } */