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

Richard Smith richard at metafoo.co.uk
Tue Apr 29 18:05:11 PDT 2014


================
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";
----------------
Reid Kleckner wrote:
> Richard Smith wrote:
> > This seems like it should be unreachable.
> It's used for diagnostics now, and it uses DeclSpec::TSCS___declspec_thread.
> 
> Would you be in favor of a patch that removes the TSCS_* static const ints in DeclSpec and replaces them with uses of the Basic/Specifiers.h enumerators?
Where is it used for diagnostics? It seems strange for someone to pass it a `TSCS` that didn't come from a `DeclSpec`, and a `DeclSpec` cannot have `TSCS___declspec_thread`.

I don't think I'd be in favor of the patch you suggested -- the `DeclSpec` type and the `Basic` type notionally mean different things (even though they have the same underlying `enum`), and we're just punning between them here. In particular, it does not make sense for the `DeclSpec` type to have a value for `__declspec(thread)`, since a parsed decl-specifier-seq can't have such a thread storage class specifier.

Giving `DeclSpec` a separate `enum` that doesn't have a `__declspec(thread)` enumerator would seem more consistent with the intent here.

http://reviews.llvm.org/D3551






More information about the cfe-commits mailing list