From patchwork Mon Nov 18 19:04:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1196907 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513947-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="BZAvRhHz"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="cuJlx9DI"; dkim-atps=neutral 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 47Gz0J4FDTz9sPT for ; Tue, 19 Nov 2019 06:04:30 +1100 (AEDT) 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 :content-transfer-encoding; q=dns; s=default; b=wDhveDRU6SNh84s9 YxAEpPi+NLXTLBEcscGRNYWBltSdq9JOE0AyjOm0gr1wmebTlu3hW6ZpQCJUIpSD maRlU4CiJcTfh7aJZq0XbiHH3G7/fv5YAGDhiR3Wh4I92M+zeL3DL1iHy+V3u1aK 4+stGu2otxGMUdObjbR1sYo6cF0= 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 :content-transfer-encoding; s=default; bh=Eph1xTExcvmpt8CHY/HQzn 5AEN0=; b=BZAvRhHz2Y+vUgIEbpHm5wvtlhBV4n9Krb2xkwKOf8OC1Fh5ZxVZ07 k1mxjcgepD2LW0gqjktVzxmAMQrpCAKD5ofzWh7CCS6LTLb62WcLQhdp9McUH7N7 +H/pV3ncBTWy2zBu+tOncPhnh74xhFpVqyx2rPtlufw8rZiFrgciQ= Received: (qmail 15086 invoked by alias); 18 Nov 2019 19:04:22 -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 15075 invoked by uid 89); 18 Nov 2019 19:04:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-delivery-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Nov 2019 19:04:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574103859; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ghwKYVBg7mEWIgmpc9TfWsR3KVH003dEzNKUMX26oqc=; b=cuJlx9DIWjc7pdeMe0ljusLuSwfAVpDBceoATqtmGxknDCOPnZ9uNtZV10B/Ywv29T3tyB Kug/uJYi37VFSXfZuyLrt9SFPZz4ZAh6vZNOgtal4uSUMtbuiEhnxISDJBhNjXJklOO5DT uVGYA4tKddS9BZW3tny8cfCml384Wfs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-358-mLRqEZZDN4iFu9ELQZY05w-1; Mon, 18 Nov 2019 14:04:18 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F1AC802680 for ; Mon, 18 Nov 2019 19:04:17 +0000 (UTC) Received: from redhat.com (ovpn-121-84.rdu2.redhat.com [10.10.121.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 11ED61A8D6; Mon, 18 Nov 2019 19:04:16 +0000 (UTC) Date: Mon, 18 Nov 2019 14:04:15 -0500 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [C++ PATCH] c++/92450 - ICE with invalid nested name specifier. Message-ID: <20191118190415.GL3791@redhat.com> MIME-Version: 1.0 User-Agent: Mutt/1.12.1 (2019-06-15) X-Mimecast-Spam-Score: 0 Content-Disposition: inline The newly added diagnostic causes an ICE because the new grokdeclarator call returned error_mark_node and DECL_SOURCE_LOCATION crashes on that. So don't attempt to print the new diagnostic if we've encountered something not resembling a bit-field. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-11-18 Marek Polacek PR c++/92450 - ICE with invalid nested name specifier. * parser.c (cp_parser_member_declaration): Bail out for invalid code. * g++.dg/parse/crash71.C: New test. diff --git gcc/cp/parser.c gcc/cp/parser.c index c473e7fd92f..caed6946977 100644 --- gcc/cp/parser.c +++ gcc/cp/parser.c @@ -25052,6 +25052,9 @@ cp_parser_member_declaration (cp_parser* parser) tree d = grokdeclarator (declarator, &decl_specifiers, BITFIELD, /*initialized=*/false, &attributes); + /* Hopelessly invalid code, give up. */ + if (error_operand_p (d)) + goto out; error_at (DECL_SOURCE_LOCATION (d), "bit-field %qD has non-integral type %qT", d, TREE_TYPE (d)); diff --git gcc/testsuite/g++.dg/parse/crash71.C gcc/testsuite/g++.dg/parse/crash71.C new file mode 100644 index 00000000000..13f484801fe --- /dev/null +++ gcc/testsuite/g++.dg/parse/crash71.C @@ -0,0 +1,11 @@ +// PR c++/92450 - ICE with invalid nested name specifier. + +typedef int C2; +struct B1 { + struct B2 { + }; +}; + +struct S6g { + C2 : B1:B2; // { dg-error "" } +};