From 7e6393594b9b1b5c6daaaa10496aacb1d2f39516 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 18 Mar 2015 04:15:23 +0000 Subject: [PATCH] MSVC Compat: Permit char16_t, char32_t and _Atomic when targeting > 2013 We disabled support for _Atomic because the STL had name conflicts, they've been resolved in 2015. Similarly, reenable char16_t and char32_t. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232611 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/TokenKinds.def | 10 +++++----- lib/Basic/IdentifierTable.cpp | 7 ++++--- test/SemaCXX/MicrosoftCompatibility.cpp | 12 +++++++++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index 3319d4ed35..2382dbf048 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -225,8 +225,8 @@ PUNCTUATOR(greatergreatergreater, ">>>") // KEYCXX11 - This is a C++ keyword introduced to C++ in C++11 // KEYGNU - This is a keyword if GNU extensions are enabled // KEYMS - This is a keyword if Microsoft extensions are enabled -// KEYNOMS - This is a keyword that must never be enabled under -// Microsoft mode +// KEYNOMS18 - This is a keyword that must never be enabled under +// MSVC <= v18. // KEYOPENCL - This is a keyword in OpenCL // KEYALTIVEC - This is a keyword in AltiVec // KEYBORLAND - This is a keyword if Borland extensions are enabled @@ -270,7 +270,7 @@ KEYWORD(volatile , KEYALL) KEYWORD(while , KEYALL) KEYWORD(_Alignas , KEYALL) KEYWORD(_Alignof , KEYALL) -KEYWORD(_Atomic , KEYALL|KEYNOMS) +KEYWORD(_Atomic , KEYALL|KEYNOMS18) KEYWORD(_Bool , KEYNOCXX) KEYWORD(_Complex , KEYALL) KEYWORD(_Generic , KEYALL) @@ -331,8 +331,8 @@ CXX_KEYWORD_OPERATOR(xor_eq , caretequal) // C++11 keywords KEYWORD(alignas , KEYCXX11) KEYWORD(alignof , KEYCXX11) -KEYWORD(char16_t , KEYCXX11|KEYNOMS) -KEYWORD(char32_t , KEYCXX11|KEYNOMS) +KEYWORD(char16_t , KEYCXX11|KEYNOMS18) +KEYWORD(char32_t , KEYCXX11|KEYNOMS18) KEYWORD(constexpr , KEYCXX11) KEYWORD(decltype , KEYCXX11) KEYWORD(noexcept , KEYCXX11) diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index 613b43fce9..db148f493f 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -105,10 +105,10 @@ namespace { KEYOPENCL = 0x200, KEYC11 = 0x400, KEYARC = 0x800, - KEYNOMS = 0x01000, + KEYNOMS18 = 0x01000, WCHARSUPPORT = 0x02000, HALFSUPPORT = 0x04000, - KEYALL = (0xffff & ~KEYNOMS) // Because KEYNOMS is used to exclude. + KEYALL = (0xffff & ~KEYNOMS18) // Because KEYNOMS18 is used to exclude. }; /// \brief How a keyword is treated in the selected standard. @@ -154,7 +154,8 @@ static void AddKeyword(StringRef Keyword, KeywordStatus AddResult = getKeywordStatus(LangOpts, Flags); // Don't add this keyword under MSVCCompat. - if (LangOpts.MSVCCompat && (Flags & KEYNOMS)) + if (LangOpts.MSVCCompat && (Flags & KEYNOMS18) && + !LangOpts.isCompatibleWithMSVC(19)) return; // Don't add this keyword if disabled in this language. if (AddResult == KS_Disabled) return; diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp index 56486b8f04..480c7cbdca 100644 --- a/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/test/SemaCXX/MicrosoftCompatibility.cpp @@ -1,9 +1,15 @@ -// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions - - +// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=19.00 +// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions -fms-compatibility-version=18.00 + +#if _MSC_VER >= 1900 +char16_t x; +char32_t y; +_Atomic(int) z; +#else typedef unsigned short char16_t; typedef unsigned int char32_t; struct _Atomic {}; +#endif typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}} -- 2.40.0