[PATCH] D66364: Diagnose use of _Thread_local as an extension when appropriate

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 19 12:54:28 PDT 2019


rsmith added a comment.

In D66364#1633981 <https://reviews.llvm.org/D66364#1633981>, @aaron.ballman wrote:

> My motivation is for portability. _Thread_local (and all the rest) do not exist in C99 or earlier (or C++), so having some way to warn users of that is useful. I agree that we should be consistent and go with all or none, but my preference is for all (esp since this is a -pedantic warning class).


OK, if the motivation is to catch cases where people thought they were writing portable C99 code, but they weren't then I can see this being a useful warning. And that suggests that we should warn on all C11 `_Keywords` when used in C99 or earlier (or in C++). And I suppose it's reasonable to split the hair between "this is code that someone might think is valid C99" (eg, use of `_Static_assert`) and "this is code that is using language extensions that no-one is likely to think is valid C99" (eg, use of `__builtin_*`).

That said, this direction will presumably mean that we start to reject (eg) libc++ when built with `-Wsystem-headers -pedantic-errors` (because it uses `_Atomic` to implement `std::atomic`), which doesn't seem ideal to me. Do you have any thoughts on that? Maybe we should change libc++ to use `__extension__` in those instances?


Repository:
  rC Clang

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

https://reviews.llvm.org/D66364





More information about the cfe-commits mailing list