While keywords introduced in later standards can legally be used as identifiers in code compiled to earlier standards, doing so will eventually
cause problems. Such code will cause compile errors if (when) the compiler is upgraded, and fixing those errors could be difficult and painful.
Additionally, such misuse of keywords has the potential to thoroughly confuse people who are unfamiliar with the code base, possibly leading them
to introduce additional errors.
For these reasons, the earlier this practice is stopped, the better.
This rule flags instances of the following keywords used as identifiers:
C99
inline
, restrict
, _Bool
, _Complex
, _Noreturn
, _Static_assert
,
_Thread_local
C11
_Alignas
, _Alignof
, _Atomic
, _Generic
, _Imaginary
C++11
alignas
, alignof
, char16_t
, char32_t
, constexpr
, decltype
,
noexcept
, nullptr
, static_assert
, thread_local
C++20
concept
, requires
, constinit
, consteval
, co_await
, co_return
,
co_yield
, char8_t
Noncompliant code example
int inline = 0;
Compliant solution
int inline_count = 0;