From patchwork Sun Nov 13 11:43:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 19350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1645432wru; Sun, 13 Nov 2022 03:44:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf51TqeEgK+zhAc3cYA8lajC7uq86Drt8eMjs31KqOM/hIkI3XjAhYuHVlihhEW56zBI5ZTb X-Received: by 2002:aa7:de92:0:b0:467:8fb6:d11 with SMTP id j18-20020aa7de92000000b004678fb60d11mr4504908edv.421.1668339871994; Sun, 13 Nov 2022 03:44:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668339871; cv=none; d=google.com; s=arc-20160816; b=SZtHjp7p33hCK0TzDx6+RPWSr79wv/Uz5Iq2pRBEL3LACySkuxmcB7z0OJAOZWxsgJ 9ePeAFZoJs/xLrNTn9ZYgl9PLNvQgGSCamwZ3/Aln1+B4FJ0APj6DnduvVdSttAd08Yl E9/Q+39B4WZ1nNDtqCIZEdfnOe8CyoknE93XvMmGWTa1/KdTsKc0+Xl3/tpUHD6ZkUVf Yq9PRvxTs4g2kc3YEXgcmCt6rV7S+qa6QCLW3PBiRizScNROaimEG8N2ne4ccxbPKvOl AHR5MAf+6JOmzoKikk9dZl7epJU/OEWq80h4FcaoWxearXEf1vlAbLeZuZzmx21aq/cN sDow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:in-reply-to:mime-version:references:message-id :subject:cc:to:date:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=MjDyh2Mb4fwnB72zN/devaboSw5F/dFkcz5svqdLShE=; b=LY2bxrkiUO9anwBInEzUogbHk8IlcV9zrNFQVl1AyQjGhkTTI2EJA4vGpyOvbZb5rV Zz3IsMeOBpdg/XnmAm+tN2vrx4U6jxMWuPSMhQdLZHFAfLWPFELX9LcMhLaSezZ2EI7d 9G4hIoRKy3v89WotAoCngl1ry/QF167IJV+A3gD5VOLVWzK/5MeGV0mrn43Evxz9CuCG bgw+6F7FUe4gLW/9L9/n6SNmsHnkGMt4lFNFOLLuFSC16qNf9WGHqCci2xiX9vOae6Zg zLOQwyApdB62LNKCeL2Ux9zjq4+h8DiytVhxwp622mi4J0q0/kB47S+i9/08h9d6wXK1 A/Wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=m4wDVFyx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l12-20020a056402254c00b004677827023esi5222168edb.560.2022.11.13.03.44.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 03:44:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=m4wDVFyx; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00AD3385843D for ; Sun, 13 Nov 2022 11:44:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00AD3385843D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668339871; bh=MjDyh2Mb4fwnB72zN/devaboSw5F/dFkcz5svqdLShE=; h=Date:To:Cc:Subject:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=m4wDVFyxGOrnUivGrvIhPzlac3OyQWD8IAuSB3hkLPxEqXLkYTbbkAOwTyETHfv1Z 1TXysVzrN0pw9EvEEYN9xJZUbCgAvlMu+bi2qvVzb1we7F7sJdW2FtE+IfIvdWru8s xQI+CQEG7MQhMqXVqKiTQ3xjjkacGlRF5+goGrkQ= 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 C128F385843A for ; Sun, 13 Nov 2022 11:43:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C128F385843A Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-45-bdhHSqdaNriyiXtKCrY1KA-1; Sun, 13 Nov 2022 06:43:42 -0500 X-MC-Unique: bdhHSqdaNriyiXtKCrY1KA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4E1E5380408D for ; Sun, 13 Nov 2022 11:43:42 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 09A28111E3E8; Sun, 13 Nov 2022 11:43:41 +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 2ADBhbIM2801373 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sun, 13 Nov 2022 12:43:37 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2ADBhbRP2801372; Sun, 13 Nov 2022 12:43:37 +0100 Date: Sun, 13 Nov 2022 12:43:36 +0100 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++, v2: Implement CWG 2654 - Un-deprecation of compound volatile assignments Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 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_H2, 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 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749381149806494869?= X-GMAIL-MSGID: =?utf-8?q?1749381149806494869?= On Fri, Nov 11, 2022 at 08:43:04AM +0100, Jakub Jelinek wrote: > Again, because stage1 close is near, posting the following patch > to implement CWG 2654. > > Ok for trunk if it passes bootstrap/regtest and is voted into C++23 > and C++20 as a DR? Here is an updated patch that passed bootstrap/regtest, difference is just a few further testsuite tweaks. 2022-11-13 Jakub Jelinek * typeck.cc (cp_build_modify_expr): Implement CWG 2654 - Un-deprecation of compound volatile assignments. Remove -Wvolatile warning about compound volatile assignments. * g++.dg/cpp2a/volatile1.C (fn2, fn3, racoon): Adjust expected diagnostics. * g++.dg/cpp2a/volatile3.C (fn2, fn3, racoon): Likewise. * g++.dg/cpp2a/volatile5.C (f): Likewise. * g++.dg/ext/vector25.C (foo): Don't expect a warning. * g++.dg/cpp1y/new1.C (test_unused): Likewise. Jakub --- gcc/cp/typeck.cc.jj 2022-11-09 11:22:42.617628059 +0100 +++ gcc/cp/typeck.cc 2022-11-10 23:19:00.394228067 +0100 @@ -9513,19 +9513,6 @@ cp_build_modify_expr (location_t loc, tr && MAYBE_CLASS_TYPE_P (TREE_TYPE (lhstype))) || MAYBE_CLASS_TYPE_P (lhstype))); - /* An expression of the form E1 op= E2. [expr.ass] says: - "Such expressions are deprecated if E1 has volatile-qualified - type and op is not one of the bitwise operators |, &, ^." - We warn here rather than in cp_genericize_r because - for compound assignments we are supposed to warn even if the - assignment is a discarded-value expression. */ - if (modifycode != BIT_AND_EXPR - && modifycode != BIT_IOR_EXPR - && modifycode != BIT_XOR_EXPR - && (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype))) - warning_at (loc, OPT_Wvolatile, - "compound assignment with %-qualified left " - "operand is deprecated"); /* Preevaluate the RHS to make sure its evaluation is complete before the lvalue-to-rvalue conversion of the LHS: --- gcc/testsuite/g++.dg/cpp2a/volatile1.C.jj 2022-08-16 13:15:22.739043862 +0200 +++ gcc/testsuite/g++.dg/cpp2a/volatile1.C 2022-11-10 23:23:18.949717772 +0100 @@ -74,17 +74,17 @@ fn2 () decltype(i = vi = 42) x3 = i; // Compound assignments. - vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + vi += i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi -= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi %= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } - vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + vi /= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } i *= vi; - decltype(vi -= 42) x2 = vi; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + decltype(vi -= 42) x2 = vi; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } // Structured bindings. int a[] = { 10, 5 }; @@ -107,12 +107,12 @@ fn3 () volatile U u; u.c = 42; i = u.c = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - u.c += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + u.c += 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } volatile T t; t.a = 3; j = t.a = 3; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - t.a += 3; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + t.a += 3; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } volatile int *src = &i; *src; // No assignment, don't warn. @@ -135,7 +135,7 @@ void raccoon () volatile T t, u; t = 42; u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } - t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++20 } } + t += 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } } --- gcc/testsuite/g++.dg/cpp2a/volatile3.C.jj 2022-08-16 13:15:22.753043682 +0200 +++ gcc/testsuite/g++.dg/cpp2a/volatile3.C 2022-11-10 23:24:24.781823998 +0100 @@ -75,17 +75,17 @@ fn2 () decltype(i = vi = 42) x3 = i; // Compound assignments. - vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + vi += i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi -= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } + vi %= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } - vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + vi /= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } i *= vi; - decltype(vi -= 42) x2 = vi; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + decltype(vi -= 42) x2 = vi; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } // Structured bindings. int a[] = { 10, 5 }; @@ -108,12 +108,12 @@ fn3 () volatile U u; u.c = 42; i = u.c = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - u.c += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + u.c += 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } volatile T t; t.a = 3; j = t.a = 3; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - t.a += 3; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + t.a += 3; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } volatile int *src = &i; *src; // No assignment, don't warn. @@ -136,7 +136,7 @@ void raccoon () volatile T t, u; t = 42; u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } - t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" } + t += 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" } } --- gcc/testsuite/g++.dg/cpp2a/volatile5.C.jj 2022-08-16 13:15:22.778043359 +0200 +++ gcc/testsuite/g++.dg/cpp2a/volatile5.C 2022-11-10 23:25:07.445244776 +0100 @@ -7,7 +7,7 @@ void f (bool b) { (b ? x : y) = 1; - (b ? x : y) += 1; // { dg-warning "compound assignment" "" { target c++20 } } + (b ? x : y) += 1; // { dg-bogus "compound assignment" } z = (b ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } ((z = 2) ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } (b ? (x = 2) : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } } --- gcc/testsuite/g++.dg/ext/vector25.C.jj 2020-01-14 20:02:46.842608950 +0100 +++ gcc/testsuite/g++.dg/ext/vector25.C 2022-11-12 09:18:20.654702399 +0100 @@ -2,5 +2,5 @@ volatile int i __attribute__((vector_siz void foo() { - i += i; // { dg-warning "deprecated" "" { target c++2a } } + i += i; // { dg-bogus "deprecated" } } --- gcc/testsuite/g++.dg/cpp1y/new1.C.jj 2020-09-24 11:58:14.049056885 +0200 +++ gcc/testsuite/g++.dg/cpp1y/new1.C 2022-11-12 09:16:49.349943682 +0100 @@ -65,7 +65,7 @@ void test_unused() { volatile double d = 0.0; double *p = new double (); - d += 1.0; // { dg-warning "deprecated" "" { target c++2a } } + d += 1.0; delete p; }