[clang] [clang] Add test for CWG3088 about macros defining special identifiers (PR #189309)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 30 05:43:54 PDT 2026


================
@@ -0,0 +1,270 @@
+// RUN: %clang_cc1 -std=c++98 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected
+// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx11
+// RUN: %clang_cc1 -std=c++14 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx11
+// RUN: %clang_cc1 -std=c++17 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx11
+// RUN: %clang_cc1 -std=c++20 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx11,since-cxx20
+// RUN: %clang_cc1 -std=c++23 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx11,since-cxx20
+// RUN: %clang_cc1 -std=c++2c -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx11,since-cxx20
+
+namespace cwg3088 { // cwg3088: partial
+#define asm
----------------
AaronBallman wrote:

Per the wording, I think we also need tests for function-like macro definitions. However, I question the value of diagnosing a function-like macro definition unless the keyword would could otherwise be followed by balanced parens. e.g., I think it's useless to diagnose `#define case()` because the keyword can only ever be used without parens, it's very sensible to diagnose `#define if()` because `if` has to have balanced parens, and it *might* be sensible to diagnose `#define int()` because `int(12.0f)` is a valid function-style cast notation. But maybe this is splitting hairs.

https://github.com/llvm/llvm-project/pull/189309


More information about the cfe-commits mailing list