public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-4084] c++: Implement CWG 2654 - Un-deprecation of compound volatile assignments
Date: Wed, 16 Nov 2022 09:24:24 +0000 (GMT)	[thread overview]
Message-ID: <20221116092424.BE5DA3835787@sourceware.org> (raw)

https://gcc.gnu.org/g:136029059686fed2d99c755baf35f98553fc0232

commit r13-4084-g136029059686fed2d99c755baf35f98553fc0232
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Nov 16 10:23:22 2022 +0100

    c++: Implement CWG 2654 - Un-deprecation of compound volatile assignments
    
    The following patch implements CWG 2654.
    
    2022-11-16  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.

Diff:
---
 gcc/cp/typeck.cc                       | 13 -------------
 gcc/testsuite/g++.dg/cpp1y/new1.C      |  2 +-
 gcc/testsuite/g++.dg/cpp2a/volatile1.C | 16 ++++++++--------
 gcc/testsuite/g++.dg/cpp2a/volatile3.C | 16 ++++++++--------
 gcc/testsuite/g++.dg/cpp2a/volatile5.C |  2 +-
 gcc/testsuite/g++.dg/ext/vector25.C    |  2 +-
 6 files changed, 19 insertions(+), 32 deletions(-)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 55c958533b4..6c911827778 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -9513,19 +9513,6 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
 			 && 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:
 
diff --git a/gcc/testsuite/g++.dg/cpp1y/new1.C b/gcc/testsuite/g++.dg/cpp1y/new1.C
index fec0088cb40..21f225cc847 100644
--- a/gcc/testsuite/g++.dg/cpp1y/new1.C
+++ b/gcc/testsuite/g++.dg/cpp1y/new1.C
@@ -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;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile1.C b/gcc/testsuite/g++.dg/cpp2a/volatile1.C
index a0264a47bc7..fc9d5e06c59 100644
--- a/gcc/testsuite/g++.dg/cpp2a/volatile1.C
+++ b/gcc/testsuite/g++.dg/cpp2a/volatile1.C
@@ -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" }
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile3.C b/gcc/testsuite/g++.dg/cpp2a/volatile3.C
index 58816dc3084..9f1a8dcd3eb 100644
--- a/gcc/testsuite/g++.dg/cpp2a/volatile3.C
+++ b/gcc/testsuite/g++.dg/cpp2a/volatile3.C
@@ -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" }
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile5.C b/gcc/testsuite/g++.dg/cpp2a/volatile5.C
index 3684be9837e..291b9bc894a 100644
--- a/gcc/testsuite/g++.dg/cpp2a/volatile5.C
+++ b/gcc/testsuite/g++.dg/cpp2a/volatile5.C
@@ -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 } }
diff --git a/gcc/testsuite/g++.dg/ext/vector25.C b/gcc/testsuite/g++.dg/ext/vector25.C
index 339865d6942..71eaac5d639 100644
--- a/gcc/testsuite/g++.dg/ext/vector25.C
+++ b/gcc/testsuite/g++.dg/ext/vector25.C
@@ -2,5 +2,5 @@ volatile int i __attribute__((vector_size(8)));
 
 void foo()
 {
-  i += i; // { dg-warning "deprecated" "" { target c++2a } }
+  i += i; // { dg-bogus "deprecated" }
 }

                 reply	other threads:[~2022-11-16  9:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221116092424.BE5DA3835787@sourceware.org \
    --to=jakub@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).