From: Jason Merrill <jason@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++, v2: Implement CWG 2654 - Un-deprecation of compound volatile assignments
Date: Tue, 15 Nov 2022 18:25:35 -0500 [thread overview]
Message-ID: <672c8afb-000f-66a3-5c0a-011dc486e05e@redhat.com> (raw)
In-Reply-To: <Y3DYaMLHMM3JCf0W@tucnak>
On 11/13/22 01:43, Jakub Jelinek wrote:
> 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.
OK.
> 2022-11-13 Jakub Jelinek <jakub@redhat.com>
>
> * 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.
>
> --- 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 %<volatile%>-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;
> }
>
>
>
> Jakub
>
prev parent reply other threads:[~2022-11-15 23:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 7:43 [PATCH] c++: " Jakub Jelinek
2022-11-13 11:43 ` [PATCH] c++, v2: " Jakub Jelinek
2022-11-15 23:25 ` Jason Merrill [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=672c8afb-000f-66a3-5c0a-011dc486e05e@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).