llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: NohHyeon Kwon (swote-git) <details> <summary>Changes</summary> Add test coverage to ensure comma operators remain properly rejected in `#if` directives. Per CWG 1436, comma is not among the permitted operators in preprocessor conditional expressions. This test prevents regressions and clarifies the intended behavior. Addresses #<!-- -->132822 --- Full diff: https://github.com/llvm/llvm-project/pull/155570.diff 1 Files Affected: - (added) clang/test/Preprocessor/cxx_oper_comma.cpp (+26) ``````````diff diff --git a/clang/test/Preprocessor/cxx_oper_comma.cpp b/clang/test/Preprocessor/cxx_oper_comma.cpp new file mode 100644 index 0000000000000..5589024ede01c --- /dev/null +++ b/clang/test/Preprocessor/cxx_oper_comma.cpp @@ -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@+1 {{expected end of line in preprocessor expression}} +#if 1, 2 +#endif + +// Test 2: Comma in conditional expression +// expected-error@+1 {{comma operator in operand of #if}} +#if 1 ? 1, 0 : 3 +#endif + +// Test 3: Parenthesized comma +// expected-error@+1 {{comma operator in operand of #if}} +#if (1, 2) +#endif + +// Test 4: Multiple commas +// expected-error@+1 {{expected end of line in preprocessor expression}} +#if 1, 2, 3 +#endif `````````` </details> https://github.com/llvm/llvm-project/pull/155570 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
