[clang] [Clang][Sema] Error message refers to `__begin1` with `constexpr` variable in range-based for loop (PR #218145)
Mariya Podchishchaeva via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 02:53:09 PDT 2026
================
@@ -2961,6 +2961,10 @@ def err_for_range_decl_must_be_var : Error<
def err_for_range_storage_class : Error<
"%select{loop|expansion}0 variable %1 may not be declared %select{'extern'|'static'|"
"'__private_extern__'|'auto'|'register'|'constexpr'|'thread_local'}2">;
+def err_for_range_constexpr_loop_var : Error<
+ "constexpr variable %0 must be initialized by a constant expression; "
+ "a range-based for loop variable is initialized on each iteration from the "
+ "loop's iterator, whose value is not known at compile time">;
----------------
Fznamznon wrote:
If we go that way IMO that should be a note in addition to existing `err_constexpr_var_requires_const_init` instead fully copy-paste of an existing message with additional test.
https://github.com/llvm/llvm-project/pull/218145
More information about the cfe-commits
mailing list