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 727213858CDA for ; Mon, 8 Apr 2024 22:55:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 727213858CDA 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 727213858CDA 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=1712616939; cv=none; b=YC/PAfgpuCvMFP6uMfrw5D2xDY/b316Wt5X9Dd1KqWcxMfpi2Zdco7JHi1vsJS9ZQumN+obxC3JBIUWEnupVy1wZ1vmkGd05lisb2GsMYmbQNZdaPTPRNYImtjn+R7qCvVIdAfzm2uPfsV5EJVGwizZkI9FMdtd787zsmJNDTEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712616939; c=relaxed/simple; bh=Mjfp3qiECUsORUFQ5JqYK+S4bNrXX36Y1HgPpD3WNY0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=EhZ/pahNmDLyykDSDI8rpsNqmGtlfuXyMo8HEjk3IgBWgodGcTBLnloRPV9SGp2uOIri54b2Fw9n5XCqpWKbRca3VWg5QBV38GEu0P6t9duezvrbBNsdG2za9nkCf6+1vnX8iinUuSr9eE72FkcvFxCIhZ9pd+YW43uuV5uYDII= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712616937; 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=yIE4aGFgCu4UZ/aibV4TB66Xs130PQ0X52MJyGWkOlw=; b=K6e+kfmZ8osBhGqt9I8XOC5Dv3alKsccnW7bZ+3oXLkGAHouTEkmFhMbkZDXD8vOGaR+/p X7bGD8ks2iV35eek0nhra7fbjR0yLOmjGkRddND1eBjryR3+YcxEu7voc+4Q1viDunofb4 fta1Vx8sletn3Ufni/93eDfvnM7cd+E= Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-meN6DpChOAqZTI92AUT_Wg-1; Mon, 08 Apr 2024 18:55:35 -0400 X-MC-Unique: meN6DpChOAqZTI92AUT_Wg-1 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-61807bac417so26466907b3.3 for ; Mon, 08 Apr 2024 15:55:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712616935; x=1713221735; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yIE4aGFgCu4UZ/aibV4TB66Xs130PQ0X52MJyGWkOlw=; b=CqDHcZLfnB9yXiKSSnnlJlwvJWx2hgo87FxS5Jf5WhaQzkwETrz6CHP/ARj5KNYPBT ug7fq2dNBmwYDt+5ga0Tjbq5uSFSp/zfphKBr7D3BJa8u3WvgJJHAGdZt35XP1Ilk7Zi FwbeZml94ufhMVdhYrsKfEVsjkcg60MLI9ty1/vCmxCAkzItg9Xha4YEIp3qL50hHtmU i6xgLy5iYnBSYUleHEoE1y1ZiPKgQtQRtDNkwZBOX7mTyngBizmPGNyNEnrDUwDW2crO idjn9GY0dpSg4e9E8DXW955NjZkuxVc7WCipGGjhJm4DVLUK6FtCDG1BK4/LdOD5HtfZ +wZQ== X-Gm-Message-State: AOJu0YzgrtR0jXpehscZNDRO9YddoPm3vZnXiHu2dqmqGtWSjs10BFb9 fCjGvZd6YdTSSXAIbwimQQb4EZGYTjFixLkRBOAqs92RYOlBf4yXJQ8bFQqbcAYiE+yBJAs0kEc 1WhwAuMMBirHWghG2QxR5OSaUxOk/oaWY03hwx4eLlh6p+8re6n/SJ5M= X-Received: by 2002:a81:92c9:0:b0:614:42b1:edd8 with SMTP id j192-20020a8192c9000000b0061442b1edd8mr9733769ywg.2.1712616935192; Mon, 08 Apr 2024 15:55:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGW8PdB5CSZSiT6oSAKadp4paCZ3jgjnoFUdikeaD760Ad2H3AurwvN/M9yn31i13b/NB5LAA== X-Received: by 2002:a81:92c9:0:b0:614:42b1:edd8 with SMTP id j192-20020a8192c9000000b0061442b1edd8mr9733759ywg.2.1712616934866; Mon, 08 Apr 2024 15:55:34 -0700 (PDT) Received: from [192.168.1.130] (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 b9-20020ac84f09000000b0043451e0c947sm2770851qte.72.2024.04.08.15.55.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Apr 2024 15:55:34 -0700 (PDT) Message-ID: <16f2fd2f-c545-41c5-8540-669696859b62@redhat.com> Date: Mon, 8 Apr 2024 18:55:33 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] c++: Fix up maybe_warn_for_constant_evaluated calls [PR114580] To: Marek Polacek , Jakub Jelinek Cc: 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=-7.0 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 4/5/24 14:47, Marek Polacek wrote: > On Fri, Apr 05, 2024 at 09:40:48AM +0200, Jakub Jelinek wrote: >> Hi! >> >> When looking at maybe_warn_for_constant_evaluated for the trivial >> infinite loops patch, I've noticed that it can emit weird diagnostics >> for if constexpr in templates, first warn that std::is_constant_evaluted() >> always evaluates to false (because the function template is not constexpr) >> and then during instantiation warn that std::is_constant_evaluted() >> always evaluates to true (because it is used in if constexpr condition). >> Now, only the latter is actually true, even when the if constexpr >> is in a non-constexpr function, it will still always evaluate to true. >> >> So, the following patch fixes it to call maybe_warn_for_constant_evaluated >> always with IF_STMT_CONSTEXPR_P (if_stmt) as the second argument rather than >> true if it is if constexpr with non-dependent condition etc. >> >> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? >> >> 2024-04-05 Jakub Jelinek >> >> PR c++/114580 >> * semantics.cc (finish_if_stmt_cond): Call >> maybe_warn_for_constant_evaluated with IF_STMT_CONSTEXPR_P (if_stmt) >> as the second argument, rather than true/false depending on if >> it is if constexpr with non-dependent constant expression with >> bool type. >> >> * g++.dg/cpp2a/is-constant-evaluated15.C: New test. >> >> --- gcc/cp/semantics.cc.jj 2024-04-03 09:58:33.407772541 +0200 >> +++ gcc/cp/semantics.cc 2024-04-04 12:11:36.203886572 +0200 >> @@ -1126,6 +1126,9 @@ tree >> finish_if_stmt_cond (tree orig_cond, tree if_stmt) >> { >> tree cond = maybe_convert_cond (orig_cond); >> + maybe_warn_for_constant_evaluated (cond, >> + /*constexpr_if=*/ >> + IF_STMT_CONSTEXPR_P (if_stmt)); > > I don't think we need the comment anymore since it's clear what the > argument does, and then the whole call can fit on a single line. > > But either way, the patch looks good, thanks. Agreed, OK with that change. Jason