From patchwork Thu Jun 23 15:06:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1647216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=hCRnrWz4; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LTNsZ71Vsz9sGP for ; Fri, 24 Jun 2022 01:07:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA52A385C33B for ; Thu, 23 Jun 2022 15:07:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA52A385C33B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1655996864; bh=YW0ggAzLwgYhe7SyoXFT0H8HF24HyxB6oB6Emf3A5Vc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hCRnrWz4VX9uoJg+swlxUbWtqc8/4TY2ukPZ5KvLndgs4zjz9EBzDflvatVAZK3No 4WahgORA3J2Ew0tecTSAckXuBYgEXsWe2wFNOrSTOtJPKBLbvUklqXk4+kKBcTTL8A eYLcodcn8ICHQOw+Lf/vZrQQLSlbsB0vFrQiBcpE= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id CC34538582A3 for ; Thu, 23 Jun 2022 15:07:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC34538582A3 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-250-ndQ1q5SiPJG6gDM4bCGdxQ-1; Thu, 23 Jun 2022 11:07:03 -0400 X-MC-Unique: ndQ1q5SiPJG6gDM4bCGdxQ-1 Received: by mail-qv1-f71.google.com with SMTP id s11-20020a0cb30b000000b004703e52d881so13020561qve.7 for ; Thu, 23 Jun 2022 08:07:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=YW0ggAzLwgYhe7SyoXFT0H8HF24HyxB6oB6Emf3A5Vc=; b=jca0ks/gJXt7tE5JzXX59JDX7U21SChj7t1Qf1g9oF5AQppMPYgUsc3PbnUcL1rA28 CZJsWdCJOoFgXBJ28zb+ODjq0P9Wf/FchdFCYWdbYZSKTYZYIBm0pQDd5F16CoYcqu2r 5qC7yfUAfVicKoPgzjPELqkCCT/aZuR01yVF6XMpPXOo3OMwlsTkPpFLxi+VTeCal7mI Y5wu3PYRdHtrESz/T0+c29tTBLPjAXQhi9QhvPzYC8/qjxU/JsjjkXOv2v55aXvDjX6C WcwcvG2kToQVMcL5WXgKQH37lGQWAJl/Ij9lr5GWd1fivfCH52pK73sT2+NOk7z43pZ+ yPCw== X-Gm-Message-State: AJIora8kbi/6sw4R0tyKe9xIb/hRI5clOz8CjZR4xn3EygYCdprGVBD0 ri5uaGlB2HIHfLqKrSsL/G8OlGlGBUt5mQJ6dcz6QExIZQJwbWOZW9t5ft8NnkIdqXz1l92iKbe GyM3RwVZIgrxifHbYpc+SlhMgqha5U+Ll1bbGJnKw9DT+mYVkTkTf6OYv/dkaRSRq4w== X-Received: by 2002:a05:6214:20a7:b0:46e:eb13:c8fd with SMTP id 7-20020a05621420a700b0046eeb13c8fdmr26917105qvd.61.1655996822665; Thu, 23 Jun 2022 08:07:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ugq17h6//AfaPTmCIcpim9/5vOe2U45yDI+G3zh0YgKvblsYsOJaH9tZM8lyuaYopSUuo6bg== X-Received: by 2002:a05:6214:20a7:b0:46e:eb13:c8fd with SMTP id 7-20020a05621420a700b0046eeb13c8fdmr26917027qvd.61.1655996821814; Thu, 23 Jun 2022 08:07:01 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id j25-20020ac86659000000b00317c519be8bsm248718qtp.66.2022.06.23.08.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 08:07:01 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: -Waddress and value-dependent expr [PR105885] Date: Thu, 23 Jun 2022 11:06:59 -0400 Message-Id: <20220623150659.114599-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.5 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_LOW, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" We already suppress various warnings for code that would be tautological if written directly, but not when it's the result of template substitution. It seems we need to do this for -Waddress as well. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/105885 gcc/cp/ChangeLog: * pt.cc (tsubst_copy_and_build): Also suppress -Waddress for comparison of dependent operands. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if37.C: New test. --- gcc/cp/pt.cc | 1 + gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C base-commit: 8a15cd3396aa08dc2633982481fe392af0aa9e78 diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 80d2bec2348..4535c14c26a 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -20438,6 +20438,7 @@ tsubst_copy_and_build (tree t, warning_sentinel s2(warn_div_by_zero, was_dep); warning_sentinel s3(warn_logical_op, was_dep); warning_sentinel s4(warn_tautological_compare, was_dep); + warning_sentinel s5(warn_address, was_dep); tree r = build_x_binary_op (input_location, TREE_CODE (t), diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C new file mode 100644 index 00000000000..e11e02cfa0e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if37.C @@ -0,0 +1,21 @@ +// PR c++/105885 +// { dg-do compile { target c++17 } } +// { dg-additional-options -Wall } + +int i; + +template +void test() { + if constexpr(ARG == nullptr) { + ++i; + } else { + --i; + } +} + +const char CONSTSTR[] = {'\n', '\t', ' ', '\0'}; + +int main() { + test(); + test(); +}