https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/192073

>From d5c3cd1f77a34e6b0b281d2a40f23a16dc760457 Mon Sep 17 00:00:00 2001
From: yronglin <[email protected]>
Date: Tue, 14 Apr 2026 22:44:09 +0800
Subject: [PATCH 1/2] [NFC][Clang] Add test for P2843R3 - Preprocessing is
 never undefined

Signed-off-by: yronglin <[email protected]>
---
 clang/docs/ReleaseNotes.rst         |  4 ++++
 clang/test/Preprocessor/p2843r3.cpp | 35 +++++++++++++++++++++++++++++
 clang/www/cxx_status.html           |  2 +-
 3 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Preprocessor/p2843r3.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3e2d287d1eb1f..859b7e999848a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -133,6 +133,10 @@ C++ Language Changes
 C++2c Feature Support
 ^^^^^^^^^^^^^^^^^^^^^
 
+- Implemented `P2843R3 <https://wg21.link/P2843R3>`_ Preprocessing is never 
undefined.
+  The constructs it makes ill-formed were already diagnosed by Clang under
+  ``-pedantic``; no behavior change, just conformance.
+
 C++23 Feature Support
 ^^^^^^^^^^^^^^^^^^^^^
 
diff --git a/clang/test/Preprocessor/p2843r3.cpp 
b/clang/test/Preprocessor/p2843r3.cpp
new file mode 100644
index 0000000000000..53c272390527c
--- /dev/null
+++ b/clang/test/Preprocessor/p2843r3.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++26 -pedantic -verify -Wno-invalid-pp-token %s
+// RUN: %clang_cc1 -std=c++23 -pedantic -verify -Wno-invalid-pp-token %s
+
+// P2843R3: Preprocessing is never undefined.
+// These constructs were previously "undefined behavior" in the preprocessor;
+// as of C++26 they are ill-formed (diagnostic required). Clang already
+// diagnoses them under -pedantic, so this test just pins that behavior down.
+
+// [cpp.cond] A macro that expands to 'defined' in a conditional expression.
+#define DEFINED defined
+#if DEFINED(bar) // expected-warning {{macro expansion producing 'defined' has 
undefined behavior}}
+#endif
+
+// [cpp.replace.general] A preprocessing directive inside the arguments of a
+// function-like macro invocation.
+#define FUNCTION_MACRO(...)
+FUNCTION_MACRO(
+    #if 0 // expected-warning {{embedding a directive within macro arguments 
has undefined behavior}}
+    #endif
+)
+
+// [cpp.concat] Concatenation that does not form a valid preprocessing token.
+#define CONCAT(A, B) A ## B
+CONCAT(=, >) // expected-error {{pasting formed '=>', an invalid preprocessing 
token}}
+// expected-error@-1 {{expected unqualified-id}}
+
+// [cpp.predefined] #undef of a reserved identifier / builtin macro.
+#undef defined  // expected-error {{'defined' cannot be used as a macro name}}
+#undef __DATE__ // expected-warning {{undefining builtin macro}}
+
+// [cpp.line] #line with a non-positive or out-of-range argument.
+#line 0          // expected-warning {{#line directive with zero argument is a 
GNU extension}}
+#line -1         // expected-error {{#line directive requires a positive 
integer argument}}
+#line 2147483647 // ok, largest value required to be accepted
+#line 2147483648 // expected-warning {{C requires #line number to be less than 
2147483648, allowed as extension}}
diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 2c834b07f9a8f..4a669ff4da8a1 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -330,7 +330,7 @@ <h2 id="cxx26">C++2c implementation status</h2>
  <tr>
    <td>Preprocessing is never undefined</td>
    <td><a href="https://wg21.link/P2843";>P2843R3</a></td>
-   <td class="none" align="center">No</td>
+   <td class="full" align="center">Clang 23</td>
  </tr>
  <!-- Kona, Fall 2025-->
  <tr>

>From 3cf297853d16cb4215fb1b98468b4537c0c98406 Mon Sep 17 00:00:00 2001
From: yronglin <[email protected]>
Date: Tue, 14 Apr 2026 23:00:19 +0800
Subject: [PATCH 2/2] Update ReleaseNotes

Signed-off-by: yronglin <[email protected]>
---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 859b7e999848a..8d69c4716620b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -133,7 +133,7 @@ C++ Language Changes
 C++2c Feature Support
 ^^^^^^^^^^^^^^^^^^^^^
 
-- Implemented `P2843R3 <https://wg21.link/P2843R3>`_ Preprocessing is never 
undefined.
+- Mark `P2843R3 <https://wg21.link/P2843R3>`_ Preprocessing is never undefined 
as implemented.
   The constructs it makes ill-formed were already diagnosed by Clang under
   ``-pedantic``; no behavior change, just conformance.
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to