]> granicus.if.org Git - clang/commitdiff
Make __has_extension(c_thread_local) work.
authorEd Schouten <ed@80386.nl>
Sat, 14 Sep 2013 16:17:20 +0000 (16:17 +0000)
committerEd Schouten <ed@80386.nl>
Sat, 14 Sep 2013 16:17:20 +0000 (16:17 +0000)
Unlike C++11's "thread_local" keyword, C11's "_Thread_local" is in the
reserved namespace, meaning we provide it unconditionally; it is marked
as KEYALL in TokenKinds.def.

This means that like all the other C11 keywords, we can expose its
presence through __has_extension().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190755 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LanguageExtensions.rst
lib/Lex/PPMacroExpansion.cpp

index 65f4e7c63b6727d04c02db3657e06ee51129e401..917be931090afafaaeb8e5b2ffffae42d92e873e 100644 (file)
@@ -921,8 +921,8 @@ enabled.
 C11 ``_Thread_local``
 ^^^^^^^^^^^^^^^^^^^^^
 
-Use ``__has_feature(c_thread_local)`` to determine if support for
-``_Thread_local`` variables is enabled.
+Use ``__has_feature(c_thread_local)`` or ``__has_extension(c_thread_local)``
+to determine if support for ``_Thread_local`` variables is enabled.
 
 Checks for Type Traits
 ======================
index 0eb1169c5ac5cee6285b85881f942382e2a7a276..0a4610d06c8b658a3f4c96bfda9486a785796ef9 100644 (file)
@@ -1045,6 +1045,7 @@ static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II) {
            .Case("c_atomic", true)
            .Case("c_generic_selections", true)
            .Case("c_static_assert", true)
+           .Case("c_thread_local", PP.getTargetInfo().isTLSSupported())
            // C++11 features supported by other languages as extensions.
            .Case("cxx_atomic", LangOpts.CPlusPlus)
            .Case("cxx_deleted_functions", LangOpts.CPlusPlus)