[all-commits] [llvm/llvm-project] 992424: [Clang] [C++26] Expansion Statements (Part 9: Cont...

Sirraide via All-commits all-commits at lists.llvm.org
Fri Jul 10 13:01:26 PDT 2026


  Branch: refs/heads/users/Sirraide/expansion-stmts-8-codegen
  Home:   https://github.com/llvm/llvm-project
  Commit: 992424ffc8c9ae45a973fd3d0242aa2db175dae4
      https://github.com/llvm/llvm-project/commit/992424ffc8c9ae45a973fd3d0242aa2db175dae4
  Author: Sirraide <aeternalmail at gmail.com>
  Date:   2026-07-10 (Fri, 10 Jul 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticCommonKinds.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/ScopeInfo.h
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Parse/ParseStmt.cpp
    M clang/lib/Sema/SemaLookup.cpp
    M clang/lib/Sema/SemaStmt.cpp
    A clang/test/AST/ast-dump-expansion-stmt.cpp
    A clang/test/AST/ast-print-expansion-stmts.cpp
    A clang/test/SemaCXX/cxx2c-expansion-stmts-control-flow.cpp
    M clang/www/cxx_status.html

  Log Message:
  -----------
  [Clang] [C++26] Expansion Statements (Part 9: Control Flow) (#169688)

This disallows certain `switch`-`case` constructs and labels in
expansion statements.

GNU local labels are supported as an extension. My reasoning for
allowing this is that:
1. I’d argue it makes sense: the main reason for disallowing labels is
that you’d end up w/ more than one label w/ the same name in a single
function, and jumping to such a label from outside an expansion
statement becomes rather ill-defined as a result (which instantiation
does it jump to? what if the statement expands to nothing at all?). Both
of these issues don’t exist with local labels since they aren’t scoped
to the entire function and as a result can only be jumped to from inside
their respective instantiation.
2. Codegen and constant evaluation for this basically just works.
3. Disallowing this in the most straight-forward manner (e.g. by just
dropping the label) leads to rather poor QOI and a lot of diagnostics,
so even if we wanted to disallow local labels... we’d basically still
have to do everything I’m doing in this patch in addition to then
issuing a diagnostic for good QOI.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list