[PATCH] Add support for __declspec(thread) under -fms-extensions

Richard Smith richard at metafoo.co.uk
Tue Apr 29 14:55:38 PDT 2014


The C++ standard recommends we support a nesting depth of at least 256 for function declarators, but... it seems unlikely anyone's going to get close to that, and as you say, we can deal with that if it ever happens.

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2084-2086
@@ -2083,2 +2083,5 @@
   "'selectany' can only be applied to data items with external linkage">;
+def err_multiple_thread_specifiers : Error<
+  "__declspec(thread) applied to variable declaration which already has a "
+  "thread specifier">;
 def err_attribute_dll_not_extern : Error<
----------------
Please give this a name involving 'declspec'. It's not as general as its name implies.

================
Comment at: include/clang/Sema/DeclSpec.h:235
@@ -234,2 +234,3 @@
   static const TSCS TSCS___thread = clang::TSCS___thread;
+  static const TSCS TSCS___declspec_thread = clang::TSCS___declspec_thread;
   static const TSCS TSCS_thread_local = clang::TSCS_thread_local;
----------------
This looks misleading, since we're never going to see this within a `DeclSpec`.

================
Comment at: lib/Sema/DeclSpec.cpp:386
@@ -385,2 +385,3 @@
   case DeclSpec::TSCS___thread:      return "__thread";
+  case DeclSpec::TSCS___declspec_thread: return "__declspec(thread)";
   case DeclSpec::TSCS_thread_local:  return "thread_local";
----------------
This seems like it should be unreachable.

http://reviews.llvm.org/D3551






More information about the cfe-commits mailing list