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.129.124]) by sourceware.org (Postfix) with ESMTPS id 467BD3858D35 for ; Thu, 26 Oct 2023 21:23:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 467BD3858D35 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 467BD3858D35 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=1698355386; cv=none; b=WvvCFKFneWPHomgtZJpC+jzYSrFuyYPIjd+7trGlt4iYiBOD0VZCOlF4VTfV5+4s1/CI2iFvWjxUf5M46byFgrUPTlZRtQIi3h+pHOJWIpNmZghdEFK/fxigclUTAzxHXGyPk1ZsPAEtU7btCel143toYayoc9Ye2zJqf+mkih0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698355386; c=relaxed/simple; bh=QdugZJZkt1370VM8MiZtOR+qFgOgOf4IBgrSn8BsOgw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ZF/LWPziTt+p4WvYWGqTJy2oUoiGnwxQWBVLSlBk22V3kQD9X+qpqqk2oQ5th9f4X0UFOhX1Gz0JZmNJn8GATFW0tIW7w7K0B7Ww/MYNRFPcrK7hxjCjGzcsr+ulN1umJQRL8zJUaeaYmFF2kVO2VV5wA/r08ZXavqCBE1siXmE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698355384; 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=Z5SSzRKX+mf/EdidvgtOUN6FEKrZR+CJwKlEBOUDWj8=; b=ABRDet5gSek8lErr78e3UJk44hQ9JlkCEsdILCBVeTub2sAWKqK4eBV0cHz4YZCt45etQY 7Gkef6/UhNmkZannMbQ+DNBiVPCy0REJwCUfSGuN6noTko2Eh6/F/LWwxEYGKp4tz1eNA4 WkQka/cwBkkxeDfh6xXZxjyKpnH1Wb8= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-XMUhIWSmP12xw5eBLNLuaA-1; Thu, 26 Oct 2023 17:22:58 -0400 X-MC-Unique: XMUhIWSmP12xw5eBLNLuaA-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-41cd5166101so18056191cf.0 for ; Thu, 26 Oct 2023 14:22:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698355378; x=1698960178; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Z5SSzRKX+mf/EdidvgtOUN6FEKrZR+CJwKlEBOUDWj8=; b=XnXWtVVRYSkqJfZVw1iNy5JU/GN1u6OTNfOlHVfF0kv5XZOvVeb6I/45z4F390EvGx h9q4g+pDJkGpvtw9xYGjIK4mvJGbuPX9Rzn83jpOf0kyqMFXRdsoAAXOhV/oYDasM4l9 NQVQqU0PNMEm1QXxwMTniJTnyUKo5Zq5ex2qDRp3KUXN4M86LmCww0P2EYKUtr5uwqzR 5SPp5x6v2ZPrUiYNFZOlsQ/CtccKjbJ088sTwvW9deQBcSKtA6u446L3cAJhMngeTkvY C0Ul1k1Mfcdo209AUEyHjp4wyCCr0u9CtfZQ/JeTBDoY0UlKLCVue836o04jSR40N46L tIsg== X-Gm-Message-State: AOJu0YxO/GA6Uf7gVFtNMUGGphUWinjRAHVM90g2BpNRICZzexIf3BfH czM82BtQlppRXPmwxGl7U6OcfrurE9iZkh2SyOXXtbfWSgb6kPpFMTxWC5H2zIrky9W57ISLZQp PQmpCxlTFz96/S1gLwQ== X-Received: by 2002:ac8:5893:0:b0:418:1588:2653 with SMTP id t19-20020ac85893000000b0041815882653mr1078483qta.12.1698355378010; Thu, 26 Oct 2023 14:22:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtgVZgsDMrHw3JQyderlpxNJ/PX5vRBwkSJJk/TCxc5Irhi4ElpnjVA4AYZf6z1xcoymKvXQ== X-Received: by 2002:ac8:5893:0:b0:418:1588:2653 with SMTP id t19-20020ac85893000000b0041815882653mr1078470qta.12.1698355377698; Thu, 26 Oct 2023 14:22:57 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id x5-20020ac84d45000000b00419c40a0d70sm75929qtv.54.2023.10.26.14.22.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Oct 2023 14:22:56 -0700 (PDT) Message-ID: Date: Thu, 26 Oct 2023 17:22:55 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: Implement C++ DR 2406 - [[fallthrough]] attribute and iteration statements To: Richard Biener , Jakub Jelinek Cc: Marek Polacek , gcc-patches@gcc.gnu.org References: From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.3 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_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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 8/28/23 06:34, Richard Biener wrote: > On Fri, 25 Aug 2023, Jakub Jelinek wrote: > >> Hi! >> >> The following patch implements >> CWG 2406 - [[fallthrough]] attribute and iteration statements >> The genericization of some loops leaves nothing at all or just a label >> after a body of a loop, so if the loop is later followed by >> case or default label in a switch, the fallthrough statement isn't >> diagnosed. >> >> The following patch implements it by marking the IFN_FALLTHROUGH call >> in such a case, such that during gimplification it can be pedantically >> diagnosed even if it is followed by case or default label or some normal >> labels followed by case/default labels. >> >> While looking into this, I've discovered other problems. >> expand_FALLTHROUGH_r is removing the IFN_FALLTHROUGH calls from the IL, >> but wasn't telling that to walk_gimple_stmt/walk_gimple_seq_mod, so >> the callers would then skip the next statement after it, and it would >> return non-NULL if the removed stmt was last in the sequence. This could >> lead to wi->callback_result being set even if it didn't appear at the very >> end of switch sequence. >> The patch makes use of wi->removed_stmt such that the callers properly >> know what happened, and use different way to handle the end of switch >> sequence case. >> >> That change discovered a bug in the gimple-walk handling of >> wi->removed_stmt. If that flag is set, the callback is telling the callers >> that the current statement has been removed and so the innermost >> walk_gimple_seq_mod shouldn't gsi_next. The problem is that >> wi->removed_stmt is only reset at the start of a walk_gimple_stmt, but that >> can be too late for some cases. If we have two nested gimple sequences, >> say GIMPLE_BIND as the last stmt of some gimple seq, we remove the last >> statement inside of that GIMPLE_BIND, set wi->removed_stmt there, don't >> do gsi_next correctly because already gsi_remove moved us to the next stmt, >> there is no next stmt, so we return back to the caller, but wi->removed_stmt >> is still set and so we don't do gsi_next even in the outer sequence, despite >> the GIMPLE_BIND (etc.) not being removed. That means we walk the >> GIMPLE_BIND with its whole sequence again. >> The patch fixes that by resetting wi->removed_stmt after we've used that >> flag in walk_gimple_seq_mod. Nothing really uses that flag after the >> outermost walk_gimple_seq_mod, it is just a private notification that >> the stmt callback has removed a stmt. >> >> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > The gimple-walk.cc/gimplify.cc changes are OK, I don't understand > the c-gimplify.cc one. Seems like it would be good to document this non-obvious meaning of *_NOTHROW for ICF_FALLTHROUGH. Maybe at its entry in internal-fn.def? OK with that change. Jason