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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 11:51:56 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>;
----------------
AaronBallman wrote:

> That’s true if we just look at the grammar, but I’m not sure it’s obvious to users that an attributed-statement is not a compound-statement... imo this is clearer

Strong +1; it's not a compound statement to a language lawyer, but to a user who isn't on the standards committee, `{}` is a compound statement; that there's an attribute before it doesn't make it any less of a compound statement.

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


More information about the cfe-commits mailing list