[clang] [clang][Parser] Warn when the body of expansion statement is not a compound statement (PR #209229)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 07:18:41 PDT 2026


================
@@ -457,6 +457,12 @@ def err_expansion_stmt_requires_cxx2c : Error<
   "expansion statements are only supported in C++2c">;
 def err_for_template : Error<
   "'for template' is invalid; use 'template for' instead">;
+def ext_expansion_stmt_body_not_compound_stmt : Extension<
+  "ISO C++ requires the body of an expansion statement to be a compound statement">,
+  InGroup<ExpansionStmtBody>;
+def ext_expansion_stmt_body_attr : Extension<
+  "ISO C++ forbids attributes before the compound statement of an expansion statement">,
+  InGroup<ExpansionStmtBody>;
----------------
cor3ntin wrote:

I do not think we need 2 diagnostics

`[[]]{}` is not a compound statement therefore `ext_expansion_stmt_body_not_compound_stmt` is enough

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


More information about the cfe-commits mailing list