From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4CAB23858D35 for ; Wed, 22 Nov 2023 12:21:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CAB23858D35 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 4CAB23858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700655677; cv=none; b=VDuADhI4PyS4me+BHu0tNHZGn4L6/+gh3lteeLVHVG7m00SpC3myR1Q0isbJS+uhDH6Pu9wbZDU90TT7qA/lqOxWfUWopowNl6unOfiGzu0z33l1ewM0pLnfdueouBNLe6UoXGzr0gkLCskdEdm9nuAclPrF/Bwc+WLzBS8rcmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700655677; c=relaxed/simple; bh=h4/XhksyEi+0FhAXbwhB74OKvHmhrItG5xLu3FH/i7Q=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=a/0JAkzKIWBfWdrWWqmFzu6/qx0P+cHE/YrfIjrdKpxhOhKLMv/58VeXp3PMBHVA4iHlt7Df25f/HWtk4ekogT3jo8Pd6ijA5YQyhBPolm9TfiBR17/Ox3Brfq5w66vlc7SrbfOhYDf7HyQWNgOEq02Q/301GDDjj477VZo9Qfk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700655675; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=VwJ3WdrH2Jl0euVaQO2JuYio2ZAS8DO9WIl59qpNSMM=; b=AiyEFbJ4zCRzPc+z5IPaTgvqFnjij8PRYTAodnqcoPGpW9nA4dUCtfKyD3pjweLqVsO9DL U14Q5SrfYXSqtW9p5TosftdXtrXIN92KH+FJwaXXoZIKn/jNobVfCjPr4phabHrmBDK31v iaEUYjG9pyJtHBGG+Y7KZK500QlgByE= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-328-fWPTtY6MOByNaBsR7flX3A-1; Wed, 22 Nov 2023 07:21:14 -0500 X-MC-Unique: fWPTtY6MOByNaBsR7flX3A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37403280D20C; Wed, 22 Nov 2023 12:21:14 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF2001C060AE; Wed, 22 Nov 2023 12:21:13 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3AMCLBPY2489537 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 22 Nov 2023 13:21:11 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3AMCLAdK2489536; Wed, 22 Nov 2023 13:21:10 +0100 Date: Wed, 22 Nov 2023 13:21:10 +0100 From: Jakub Jelinek To: Richard Biener , Jason Merrill , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree: Fix up try_catch_may_fallthru [PR112619] Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 List-Id: On Wed, Nov 22, 2023 at 01:06:28PM +0100, Jakub Jelinek wrote: > Looking at a trivial example > void bar (); > void > foo (void) > { > try { bar (); } catch (int) {} > } > it seems it is even more complicated, because what e.g. the gimplification > sees is not TRY_CATCH_EXPR with CATCH_EXPR second operand, but > TRY_BLOCK with HANDLER second operand (note, certainly not wrapped in a > STATEMENT_LIST, one would need another catch (long) {} for it after it), > C++ FE specific trees. > And cp_gimplify_expr then on the fly turns the TRY_BLOCK into TRY_CATCH_EXPR > (in genericize_try_block) and HANDLER into CATCH_EXPR > (genericize_catch_block). > When gimplifying EH_SPEC_BLOCK in genericize_eh_spec_block it even > creates TRY_CATCH_EXPR with genericize_eh_spec_block -> build_gimple_eh_filter_tree > if even creates TRY_CATCH_EXPR with EH_FILTER_EXPR as its second operand > (without intervening STATEMENT_LIST). Ah, and the difference between the above where TRY_BLOCK is turned into TRY_CATCH_EXPR and HANDLER into CATCH_EXPR vs. the ICE on the testcase from the PR is that in that case it isn't TRY_BLOCK, but CLEANUP_STMT which is not changed during gimplification but already during cp generication. So, pedantically perhaps just assuming TRY_CATCH_EXPR where second argument is not STATEMENT_LIST to be the CATCH_EXPR/EH_FILTER_EXPR case could work for C++, but there are other FEs and it would be fragile (and weird, given that STATEMENT_LIST with single stmt in it vs. that stmt ought to be generally interchangeable). Plus of course question whether we want to handle TRY_BLOCK/EH_SPEC_BLOCK in cxx_block_may_fallthru in addition to that remains (it apparently already handles CLEANUP_STMT, but strangely just the try/finally special case of it - I'd assume the CLEANUP_EH_ONLY case would be (block_may_fallthru (CLEANUP_BODY (stmt)) || block_may_fallthru (CLEANUP_EXPR (stmt))) because if the body can fallthru, everything can, and if there is an exception and cleanup can fallthru, then it could fallthru as well). Jakub