[clang] 7772624 - Add code examples to the potentially breaking changes

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 17 05:44:25 PDT 2022


Author: Aaron Ballman
Date: 2022-09-17T08:44:13-04:00
New Revision: 7772624f3bac5499b36da8a20d5d73fcbc6f8683

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

LOG: Add code examples to the potentially breaking changes

It may help users to better understand the change by showing them a
contrived code example which demonstrates the difference in behavior.

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e81be2808fbd..240228a6d5e7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -44,21 +44,40 @@ code bases.
 
 - Clang will now correctly diagnose as ill-formed a constant expression where an
   enum without a fixed underlying type is set to a value outside the range of
-  the enumeration's values. Due to the extended period of time this bug was
-  present in major C++ implementations (including Clang), this error has the
-  ability to be downgraded into a warning (via:
-  ``-Wno-error=enum-constexpr-conversion``) to provide a transition period for
-  users. This diagnostic is expected to turn into an error-only diagnostic in
-  the next Clang release. Fixes
-  `Issue 50055: <https://github.com/llvm/llvm-project/issues/50055>`_.
+  the enumeration's values.
+
+  .. code-block:: c++
+
+    enum E { Zero, One, Two, Three, Four };
+    constexpr E Val1 = (E)3;  // Ok
+    constexpr E Val2 = (E)7;  // Ok
+    constexpr E Val3 = (E)8;  // Now diagnosed as out of the range [0, 7]
+    constexpr E Val4 = (E)-1; // Now diagnosed as out of the range [0, 7]
+
+  Due to the extended period of time this bug was present in major C++
+  implementations (including Clang), this error has the ability to be
+  downgraded into a warning (via: ``-Wno-error=enum-constexpr-conversion``) to
+  provide a transition period for users. This diagnostic is expected to turn
+  into an error-only diagnostic in the next Clang release. Fixes
+  `Issue 50055 <https://github.com/llvm/llvm-project/issues/50055>`_.
+
 - ``-Wincompatible-function-pointer-types`` now defaults to an error in all C
   language modes. It may be downgraded to a warning with
   ``-Wno-error=incompatible-function-pointer-types`` or disabled entirely with
-  ``-Wno-implicit-function-pointer-types``. *NOTE* We recommend that projects
-  using configure scripts verify the results do not change before/after setting
+  ``-Wno-implicit-function-pointer-types``.
+
+  **NOTE:** We recommend that projects using configure scripts verify that the
+  results do not change before/after setting
   ``-Werror=incompatible-function-pointer-types`` to avoid incompatibility with
   Clang 16.
 
+  .. code-block:: c
+
+    void func(const int *i);
+    void other(void) {
+      void (*fp)(int *) = func; // Previously a warning, now a downgradable error.
+    }
+
 
 What's New in Clang |release|?
 ==============================


        


More information about the cfe-commits mailing list