[clang] [clang][test] Add test for comma operator rejection in preprocessor conditionals (PR #155570)
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 22 01:53:32 PDT 2025
================
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -E -pedantic-errors %s -verify -std=c++98
+// RUN: %clang_cc1 -E -pedantic-errors %s -verify -std=c++11
+// RUN: %clang_cc1 -E -pedantic-errors %s -verify -std=c++14
+// RUN: %clang_cc1 -E -pedantic-errors %s -verify -std=c++17
+// RUN: %clang_cc1 -E -pedantic-errors %s -verify -std=c++20
+// RUN: %clang_cc1 -E -pedantic-errors %s -verify -std=c++23
+
+// Test 1: Top-level comma
+// expected-error at +1 {{expected end of line in preprocessor expression}}
+#if 1, 2
+#endif
----------------
DavidSpickett wrote:
I presume our preprocessor treats `#elif` exactly the same, as `<keyword> <expression>` however I would check at least one of these with `#elif` as well. Just to be sure that's how it works.
https://github.com/llvm/llvm-project/pull/155570
More information about the cfe-commits
mailing list