[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-15 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354162: [MSVC] Recognize `static_assert` keyword in C and 
C++98 (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D17444?vs=186741&id=187061#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Lexer/keywords_test.c
  test/Lexer/keywords_test.cpp


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -243,6 +243,7 @@
 //are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCLC   - This is a keyword in OpenCL C
@@ -363,7 +364,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++2a / concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -11,9 +11,9 @@
 // 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 -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)
@@ -51,7 +51,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
Index: test/Lexer/keywords_test.c
===
--- test/Lexer/keywords_test.c
+++ test/Lexer/keywords_test.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-NONE %s
 
-// RUN: %clang_cc1 -std=c99 -fms-extensions -E %s -o - \
+// RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
 // RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
@@ -42,3 +42,13 @@
 #else
 void has_declspec();
 #endif
+
+// CHECK-NONE: no_static_assert
+// CHECK-GNU-KEYWORDS: no_static_assert
+// CHECK-MS-KEYWORDS: has_static_assert
+// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
+#if __is_identifier(static_assert)
+void no_static_assert();
+#else
+void has_static_assert();
+#endif
Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -99,6 +99,7 @@
 KEYMODULES= 0x10,
 KEYCXX2A  = 0x20,
 KEYOPENCLCXX  = 0x40,
+KEYMSCOMPAT   = 0x80,
 KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,
 KEYALL = (0xff & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
@@ -125,6 +126,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -243,6 +243,7 @@
 //are enabled.
 //   KEYGNU   - This is a keyword 

[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-13 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Awesome, thanks.




Comment at: clang/test/Lexer/keywords_test.cpp:57
+#else
+// MS compiler recognizes static_assert in all modes. So should we.
+IS_KEYWORD(static_assert);

Should this comment (or a comment elsewhere) mention the plan that we want 
asked for the change to msvc's assert.h and that we want to stop defining this 
if _MSC_VER is new enough to have that change?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D17444#1397179 , @STL_MSFT wrote:

> @rnk I've forwarded this to the compiler front-end and Universal CRT teams.


Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk commandeered this revision.
rnk edited reviewers, added: andreybokhanko; removed: rnk.
rnk added a comment.
This revision now requires review to proceed.

Comandeering and updating description...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-13 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

@rnk I've forwarded this to the compiler front-end and Universal CRT teams.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17444/new/

https://reviews.llvm.org/D17444



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits