[llvm-branch-commits] [clang] [Clang] [C++26] Expansion Statements (Part 3: Enumerating Expansion Statements) (PR #169682)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon May 4 08:59:54 PDT 2026
================
@@ -64,13 +103,144 @@ StmtResult Sema::ActOnCXXExpansionStmtPattern(
Expr *ExpansionInitializer, SourceLocation LParenLoc,
SourceLocation ColonLoc, SourceLocation RParenLoc,
ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
+ if (!ExpansionInitializer || !ExpansionVarStmt)
+ return StmtError();
+
+ assert(CurContext->isExpansionStmt());
+ auto *DS = cast<DeclStmt>(ExpansionVarStmt);
+ if (!DS->isSingleDecl()) {
+ Diag(DS->getBeginLoc(), diag::err_type_defined_in_for_range);
+ return StmtError();
----------------
Sirraide wrote:
Hmm, well actually that diagnostic says ‘types may not be defined in a for range declaration’, and in the standard, _for-range-declaration_ is a grammar production that is also used for expansion statements; we can change to ‘in the declaration of an expansion variable’ maybe, but I’m not sure if that’s better
https://github.com/llvm/llvm-project/pull/169682
More information about the llvm-branch-commits
mailing list