[all-commits] [llvm/llvm-project] 4f057d: [Clang][Sema] Error message refers to `__begin1` w...

Akash Manna via All-commits all-commits at lists.llvm.org
Wed Sep 9 10:08:27 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4f057d974babd7782c175b4f13274346ab44aa21
      https://github.com/llvm/llvm-project/commit/4f057d974babd7782c175b4f13274346ab44aa21
  Author: Akash Manna <akash.manna.mymail at gmail.com>
  Date:   2026-09-09 (Wed, 09 Sep 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/include/clang/Basic/DiagnosticASTKinds.td
    M clang/lib/AST/ByteCode/Interp.cpp
    M clang/lib/AST/ExprConstant.cpp
    M clang/test/AST/ByteCode/cxx11.cpp
    M clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
    M clang/test/SemaCXX/constant-expression-cxx11.cpp

  Log Message:
  -----------
  [Clang][Sema] Error message refers to `__begin1` with `constexpr` variable in range-based for loop (#218145)

Fixes #211926

When a range-based for loop variable is declared `constexpr`, its
initializer is the compiler-built `*__begin1`, which normally can't be a
constant expression. The constant evaluator reports what it sees at the
leaf — `read of non-constexpr variable '__begin1' is not allowed in a
constant expression`, plus a `declared here` note pointing at the loop's
colon — without saying what `__begin1` is.

Both constant evaluators now emit a single dedicated note when they read
one of the loop's implicit variables, so the existing `constexpr
variable 'x' must be initialized by a constant expression` error is
followed by `'__begin1'-variable of range-based 'for' loop is not a
constant expression`, pointed at the loop it belongs to. The note takes
the variable as an argument, so it names `__end1` or `__range1` when
those are what was read. No Sema changes. A constexpr loop variable that
*is* valid (CWG1204, when `operator*` never reads the iterator) still
compiles, and expansion statement (`template for`) variables are
unaffected since their synthesized iterators are themselves `constexpr`.

LLM tools were used for this contribution. I've reviewed, built, and
tested the change myself before pushing to GitHub.



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