Currently we have a diagnostic that catches the other storage class specifies for the range based for loop declaration but we miss the thread_local case. This changes adds a diagnostic for that case as well.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
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.
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
12783 | 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.) |
Comment Actions
LGTM!
I think that's reasonable behavior for this corner case.
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
12783 | See [stmt.ranged]p2 -- it's explicitly disallowed. FWIW, loop variables in C++ can also be static (https://godbolt.org/z/rM15Yz). ;-) |
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.)