================
@@ -161,6 +161,12 @@ static void diagnoseNonConstVariable(InterpState &S, 
CodePtr OpPC,
     return;
   }
 
+  if (const auto *VarD = dyn_cast<VarDecl>(VD);
+      VarD && VarD->isCXXForRangeImplicitVar()) {
----------------
akash-manna-sky wrote:



> I guess what we could do is change the note to ‘%0-variable of range-based 
> for loop’ and then add the variable name to the diagnostic. That would print 
> ‘'__begin'-variable ...’, which is not great, but I think that’s probably the 
> best we can do w/o refactoring the range-based for code...

So the note now takes the variable, so it prints '__begin1'-variable of 
range-based 'for' loop is not a constant expression and stays correct for 
__end/__range too. Tests match the name with a regex so the depth suffix isn't 
baked in.

https://github.com/llvm/llvm-project/pull/218145
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to