[PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 19 06:49:24 PST 2016


On Fri, Feb 19, 2016 at 9:44 AM, Andrey Bokhanko
<andreybokhanko at gmail.com> wrote:
> Aaron, you might be right... but still, I doubt MS will fix it any
> time soon -- I suppose enough code already depends on this.
>
> Either way, it's up to Reid, as Windows maintainer, to decide whatever
> we want this to be supported in clang or not.

This is not a conforming language extension, so my vote is "no" unless
Microsoft comes back and says it's not a bug or unless there is a
significant library that won't compile without it.

~Aaron

>
> Yours,
> Andrey
>
>
> On Fri, Feb 19, 2016 at 4:43 PM, Aaron Ballman <aaron at aaronballman.com> wrote:
>> On Fri, Feb 19, 2016 at 8:08 AM, Andrey Bokhanko via cfe-commits
>> <cfe-commits at lists.llvm.org> wrote:
>>> andreybokhanko created this revision.
>>> andreybokhanko added reviewers: rnk, majnemer, thakis.
>>> andreybokhanko added a subscriber: cfe-commits.
>>>
>>> MS compiler recognizes "static_assert" keyword is C mode as well, while clang-cl doesn't. This patch fixes this.
>>
>> Are we sure this isn't an MS bug? I notice that they do not support
>> _Static_assert as a spelling under their C mode, either. Well, that's
>> not entirely true, they support _Static_assert(); (!!!!) but not
>> _Static_assert(0, "something"); (???)
>> (https://connect.microsoft.com/VisualStudio/feedback/details/2379885/static-assert-in-c-mode)
>>
>> ~Aaron
>>
>>>
>>> http://reviews.llvm.org/D17444
>>>
>>> Files:
>>>   include/clang/Basic/TokenKinds.def
>>>   test/Lexer/keywords_test.cpp
>>>
>>> Index: include/clang/Basic/TokenKinds.def
>>> ===================================================================
>>> --- include/clang/Basic/TokenKinds.def
>>> +++ include/clang/Basic/TokenKinds.def
>>> @@ -354,7 +354,7 @@
>>>  CXX11_KEYWORD(decltype              , 0)
>>>  CXX11_KEYWORD(noexcept              , 0)
>>>  CXX11_KEYWORD(nullptr               , 0)
>>> -CXX11_KEYWORD(static_assert         , 0)
>>> +CXX11_KEYWORD(static_assert         , KEYMS)
>>>  CXX11_KEYWORD(thread_local          , 0)
>>>
>>>  // C++ concepts TS keywords
>>> Index: test/Lexer/keywords_test.cpp
>>> ===================================================================
>>> --- test/Lexer/keywords_test.cpp
>>> +++ test/Lexer/keywords_test.cpp
>>> @@ -2,17 +2,17 @@
>>>  // RUN: %clang_cc1 -std=c++11 -DCXX11 -fsyntax-only %s
>>>  // RUN: %clang_cc1 -std=c++14 -fconcepts-ts -DCXX11 -DCONCEPTS -fsyntax-only %s
>>>  // RUN: %clang_cc1 -std=c++03 -fdeclspec -DDECLSPEC -fsyntax-only %s
>>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -DDECLSPEC -fsyntax-only %s
>>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -DDECLSPEC -fsyntax-only %s
>>>  // RUN: %clang_cc1 -std=c++03 -fborland-extensions -DDECLSPEC -fsyntax-only %s
>>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fsyntax-only %s
>>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec -fsyntax-only %s
>>>  // RUN: %clang_cc1 -std=c++03 -fborland-extensions -fno-declspec -fsyntax-only %s
>>>  // RUN: %clang_cc1 -std=c++03 -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
>>>  // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
>>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
>>> -// RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec -fsyntax-only %s
>>> -// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
>>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fno-declspec -fdeclspec -DDECLSPEC -fsyntax-only %s
>>> +// RUN: %clang_cc1 -std=c++03 -fms-extensions -DMS -fdeclspec -fno-declspec -fsyntax-only %s
>>> +// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC -fsyntax-only %s
>>>  // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
>>> -// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec -fsyntax-only %s
>>> +// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec -fsyntax-only %s
>>>  // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only %s
>>>
>>>  #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
>>> @@ -50,7 +50,12 @@
>>>  CXX11_TYPE(char32_t);
>>>  CXX11_KEYWORD(constexpr);
>>>  CXX11_KEYWORD(noexcept);
>>> +#ifndef MS
>>>  CXX11_KEYWORD(static_assert);
>>> +#else
>>> +// MS compiler recognizes static_assert in all modes. So should we.
>>> +IS_KEYWORD(static_assert);
>>> +#endif
>>>  CXX11_KEYWORD(thread_local);
>>>
>>>  // Concepts TS keywords
>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>


More information about the cfe-commits mailing list