From fa7d53fa31516920d3425f5b2095d3fefb38ede2 Mon Sep 17 00:00:00 2001 From: Ed Schouten <ed@80386.nl> Date: Sat, 14 Sep 2013 16:17:20 +0000 Subject: [PATCH] Make __has_extension(c_thread_local) work. 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 | 4 ++-- lib/Lex/PPMacroExpansion.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/LanguageExtensions.rst b/docs/LanguageExtensions.rst index 65f4e7c63b6..917be931090 100644 --- a/docs/LanguageExtensions.rst +++ b/docs/LanguageExtensions.rst @@ -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 ====================== diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index 0eb1169c5ac..0a4610d06c8 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -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) -- GitLab