Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add tests for comma operator rejection in preprocessor expressions #139209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions clang/test/Preprocessor/cxx_oper_comma.cpp
Original file line number Diff line number Diff line change
@@ -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