[PATCH] D92671: Add diagnostic for for-range-declaration being specificed with thread_local

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 4 13:14:03 PST 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!

In D92671#2434154 <https://reviews.llvm.org/D92671#2434154>, @shafik wrote:

> The problem with this approach is given:
>
>   for (static thread_local int a : A()) {}
>
> it just issues one diagnostic and it points to `static` but I am not sure what the right approach to handling this case is.

I think that's reasonable behavior for this corner case.



================
Comment at: clang/lib/Sema/SemaDecl.cpp:12752
     Error = 4;
     break;
   }
----------------
Quuxplusone wrote:
> Incidentally, why is this case here to begin with? Loop variables can totally be `register`. (But I guess it's moot at this point; clearly no Clang user is depending on this to work, and `register` is gone from C++20.)
See [stmt.ranged]p2 -- it's explicitly disallowed. FWIW, loop variables in C++ can also be static (https://godbolt.org/z/rM15Yz). ;-)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92671/new/

https://reviews.llvm.org/D92671



More information about the cfe-commits mailing list