From patchwork Tue Nov 28 16:51:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 1869395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H2XkaEOs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SfpQ02XwFz1yST for ; Wed, 29 Nov 2023 03:51:36 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E1B0D388215A for ; Tue, 28 Nov 2023 16:51:33 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9EBB93858C78 for ; Tue, 28 Nov 2023 16:51:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9EBB93858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9EBB93858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701190282; cv=none; b=Qmtwvd/uXROkiNMItZqMS2aBaQybqzRkXJlMM2OD/6PgCjmWA2XSkY0xcDqNBqz29mBKA6fsPwc50A564HnZv4pMXh0NEnQmb/sW4lLYXNzU35q0hnukhQMXcYk51Hqy19aEW3yq2R3HPfU9+7QMTgAy5Yde2dVi7zoC82VZFF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701190282; c=relaxed/simple; bh=QiP8DSLoZNLhSPQqxFiFkWvYgNI1jd2mLn2H0TWAUDY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rTUAINm/Hp5ghj7eWd5HQEC1DcC/R0voJTiqakq3q4q+FoYLBVOUxvJKI4IejF4tOhayOPjbpOADiwrb43V6laRws/o/DMyAQYC0bC1cCAKHinsP5stksZeVvH94KX2HlxMdg0FLHHq4wMh/LU+qyNd42LEUAkQtz/ePz1V2qcQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701190281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UOHjamqEJ94xQda4rDRGnARE1FxaWQ+1kttX7DsXwKo=; b=H2XkaEOsaky1tpWeSinaCkVc2JR5ukgUgj90WlWrfIO6QhdAIQf2NVdrWks1BkLJLUE+mE zq1S48bgCtalM2QCFIWeSBObuKIN7TRM+vf9nMRXDgPm0e3bmiQ6XYlf9jj0acXP+2L+LV 9MN+/wLvyLT90qn98Bu4KdpX5COYQfc= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-463-htxZp46bM_yHQEm3dNSdGw-1; Tue, 28 Nov 2023 11:51:20 -0500 X-MC-Unique: htxZp46bM_yHQEm3dNSdGw-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-67a3b35f343so31856826d6.3 for ; Tue, 28 Nov 2023 08:51:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701190279; x=1701795079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UOHjamqEJ94xQda4rDRGnARE1FxaWQ+1kttX7DsXwKo=; b=A5/ZleG4eVbWA+Hd/RF8xZSFbgLCfFkUMxCudWpSj+9LczVkrZ3I/PteknZrl+kdH7 qMa1o5ft2q/omDKAcTPqXRqHbK9zrzpnGA68GBHDaMGMnHs32bGUXibexPDwVL3oFmPx gjP3him7+wEcBrsUzGSJZL9dMEjBXI5PkxRSicxYtagjhxSygb9IfkOyXpoRydiQxmsi ZePXVjBnwq1qQfFZOPmaX+Ake4TxdQvaCOGeLPKPIjPEpCF9yXPKGjWlprI7ZkyF+MkT kjgNjcqW94ls4keePLMA7xO8q6TMe4tuPhOB+BuL90F7rLiDKrKfO5zHr79pxEYD/gTG WhMw== X-Gm-Message-State: AOJu0Yxnb+/ks6RzW7GutQdoZSbKZEqUD5U4H+XuuKiHN7xqCUBWbIuf n1Hh6K0cn4r9bNMTBu5c8SChmE1g/v87dYiQUFE9Ea9BIPC7IMwl/ykL/kj3NKr0gNqEGWD08yA 6t9mLyGymNEiKLHPziUR3b/PVBSRHIlFfhqN6+3Rp31XUvbI0P+z3Tx7y9QGwGoLgU8JAft8eg9 0= X-Received: by 2002:a05:6214:3103:b0:67a:35c1:2946 with SMTP id ks3-20020a056214310300b0067a35c12946mr11539066qvb.64.1701190278613; Tue, 28 Nov 2023 08:51:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3jSaA0dsS4k9Im2JRCaE3vzrTvbF8stUtSw/Ntj7y2hLdYFHB2xrWYFR5xyLLXxUA6rR5YA== X-Received: by 2002:a05:6214:3103:b0:67a:35c1:2946 with SMTP id ks3-20020a056214310300b0067a35c12946mr11539048qvb.64.1701190278317; Tue, 28 Nov 2023 08:51:18 -0800 (PST) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id i7-20020ad44107000000b0067a254f0febsm3547508qvp.146.2023.11.28.08.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 08:51:16 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH 2/2] c++: guard more against undiagnosed error_mark_node [PR112658] Date: Tue, 28 Nov 2023 11:51:12 -0500 Message-ID: <20231128165112.2571430-2-ppalka@redhat.com> X-Mailer: git-send-email 2.43.0.rc1 In-Reply-To: <20231128165112.2571430-1-ppalka@redhat.com> References: <20231128165112.2571430-1-ppalka@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This adds a sanity check to cp_parser_expression_statement similar to the one in finish_expr_stmt added by r6-6795-g0fd9d4921f7ba2, which effectively downgrades accepts-invalid/wrong-code bugs like this one into ice-on-invalid/ice-on-valid ones. PR c++/112658 gcc/cp/ChangeLog: * parser.cc (cp_parser_expression_statement): If the statement is erroneous, make sure we've seen an error. --- gcc/cp/parser.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 2464d1a0783..743d6517b09 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -12962,6 +12962,9 @@ cp_parser_expression_statement (cp_parser* parser, tree in_statement_expr) if (statement == error_mark_node && !cp_parser_uncommitted_to_tentative_parse_p (parser)) { + /* If we ran into a problem, make sure we complained. */ + gcc_assert (seen_error ()); + cp_parser_skip_to_end_of_block_or_statement (parser); return error_mark_node; }