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

Akash Manna via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 27 21:51:18 PDT 2026


================
@@ -222,6 +222,8 @@ def note_constexpr_ltor_non_integral : Note<
   "is not allowed in a constant expression">;
 def note_constexpr_ltor_non_constexpr : Note<
   "read of non-constexpr variable %0 is not allowed in a constant expression">;
+def note_constexpr_ltor_for_range_var : Note<
+  "'begin' variable of range-based 'for' loop is not a constant expression">;
----------------
akash-manna-sky wrote:

Reworded again based on Sirraide's suggestion, to keep the variable name but phrase it as a read: `read of implicit variable '__begin1' of range-based 'for' loop is not allowed in a constant expression`. Same shape as the neighbouring `read of … is not allowed notes`, and it still says which of `__begin/__end/__range` was read. 

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


More information about the cfe-commits mailing list