[clang] b12aea6 - [Clang] Implement CWG2654: Un-deprecation of compound volatile assignments

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 29 08:15:45 PST 2022


Author: Corentin Jabot
Date: 2022-11-29T17:15:39+01:00
New Revision: b12aea6659e1170ecbc773a4a363dd0def93daa9

URL: https://github.com/llvm/llvm-project/commit/b12aea6659e1170ecbc773a4a363dd0def93daa9
DIFF: https://github.com/llvm/llvm-project/commit/b12aea6659e1170ecbc773a4a363dd0def93daa9.diff

LOG: [Clang] Implement CWG2654: Un-deprecation of compound volatile assignments

Reviewed By: #clang-language-wg, erichkeane

Differential Revision: https://reviews.llvm.org/D138918

Added: 
    

Modified: 
    clang-tools-extra/clangd/Diagnostics.cpp
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Basic/DiagnosticSemaKinds.td
    clang/lib/Sema/SemaExpr.cpp
    clang/test/CXX/drs/dr26xx.cpp
    clang/test/SemaCXX/deprecated.cpp
    clang/www/cxx_dr_status.html

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp b/clang-tools-extra/clangd/Diagnostics.cpp
index 031192f763e6e..c0951edcf5258 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -331,7 +331,6 @@ void setTags(clangd::Diag &D) {
       diag::warn_deprecated,
       diag::warn_deprecated_altivec_src_compat,
       diag::warn_deprecated_comma_subscript,
-      diag::warn_deprecated_compound_assign_volatile,
       diag::warn_deprecated_copy,
       diag::warn_deprecated_copy_with_dtor,
       diag::warn_deprecated_copy_with_user_provided_copy,

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 551070b27b2da..0e57feb6e085b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -607,6 +607,8 @@ C++ Language Changes in Clang
   conforming GNU extensions. Projects incompatible with C++17 can add
   ``-std=gnu++14`` to their build settings to restore the previous behaviour.
 - Implemented DR2358 allowing init captures in lambdas in default arguments.
+- implemented `DR2654 <https://wg21.link/cwg2654>`_ which undeprecates
+  all compound assignements operations on volatile qualified variables.
 
 C++20 Feature Support
 ^^^^^^^^^^^^^^^^^^^^^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 84ce58c69848c..15f85b778ccc6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7627,9 +7627,6 @@ def warn_deprecated_increment_decrement_volatile : Warning<
 def warn_deprecated_simple_assign_volatile : Warning<
   "use of result of assignment to object of volatile-qualified type %0 "
   "is deprecated">, InGroup<DeprecatedVolatile>;
-def warn_deprecated_compound_assign_volatile : Warning<
-  "compound assignment to object of volatile-qualified type %0 is deprecated">,
-  InGroup<DeprecatedVolatile>;
 def warn_deprecated_volatile_return : Warning<
   "volatile-qualified return type %0 is deprecated">,
   InGroup<DeprecatedVolatile>;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 1ba88ad6cc2a6..06c70fbba6ffa 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13982,19 +13982,6 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
       //   type is deprecated unless the assignment is either a discarded-value
       //   expression or an unevaluated operand
       ExprEvalContexts.back().VolatileAssignmentLHSs.push_back(LHSExpr);
-    } else {
-      // C++20 [expr.ass]p6:
-      //   [Compound-assignment] expressions are deprecated if E1 has
-      //   volatile-qualified type and op is not one of the bitwise
-      //   operators |, &, ˆ.
-      switch (Opc) {
-      case BO_OrAssign:
-      case BO_AndAssign:
-      case BO_XorAssign:
-        break;
-      default:
-        Diag(Loc, diag::warn_deprecated_compound_assign_volatile) << LHSType;
-      }
     }
   }
 

diff  --git a/clang/test/CXX/drs/dr26xx.cpp b/clang/test/CXX/drs/dr26xx.cpp
index 46d81e544b5c2..6aa0e5053bc9a 100644
--- a/clang/test/CXX/drs/dr26xx.cpp
+++ b/clang/test/CXX/drs/dr26xx.cpp
@@ -78,3 +78,13 @@ class X {
 };
 int i0 = f<X>(0);   //expected-error {{no matching function for call to 'f'}}
 }
+
+namespace dr2654 { // dr2654: 16
+void f() {
+    int neck, tail;
+    volatile int brachiosaur;
+    brachiosaur += neck;                // OK
+    brachiosaur -= neck;                // OK
+    brachiosaur |= neck;                // OK
+}
+}

diff  --git a/clang/test/SemaCXX/deprecated.cpp b/clang/test/SemaCXX/deprecated.cpp
index 0c2eaaa53ca64..a93331023f7e2 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -186,10 +186,10 @@ namespace DeprecatedVolatile {
     --n; // cxx20-warning {{decrement of object of volatile-qualified type 'volatile int' is deprecated}}
     n++; // cxx20-warning {{increment of object of volatile-qualified type 'volatile int' is deprecated}}
     n--; // cxx20-warning {{decrement of object of volatile-qualified type 'volatile int' is deprecated}}
-    n += 5; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
-    n *= 3; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
-    n /= 2; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
-    n %= 42; // cxx20-warning {{compound assignment to object of volatile-qualified type 'volatile int' is deprecated}}
+    n += 5; // undeprecated as a DR in C++23
+    n *= 3; // undeprecated as a DR in C++23
+    n /= 2; // undeprecated as a DR in C++23
+    n %= 42; // undeprecated as a DR in C++23
     n &= 2; // undeprecated as a DR in C++23
     n |= 2; // undeprecated as a DR in C++23
     n ^= 2; // undeprecated as a DR in C++23

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 678c91313a47e..cec9fe58cf601 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -15732,7 +15732,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
     <td><a href="https://wg21.link/cwg2654">2654</a></td>
     <td>DR</td>
     <td>Un-deprecation of compound volatile assignments</td>
-    <td class="none" align="center">Unknown</td>
+    <td class="unreleased" align="center">Clang 16</td>
   </tr></table>
 
 </div>


        


More information about the cfe-commits mailing list