================
@@ -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
+)
----------------
cor3ntin wrote:

This should also become an error

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

Reply via email to