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

Reid Kleckner rnk at google.com
Wed Apr 30 11:58:24 PDT 2014


================
Comment at: lib/Sema/SemaDecl.cpp:8928-8934
@@ +8927,9 @@
+    const CXXRecordDecl *RD = var->getType()->getAsCXXRecordDecl();
+    if (RD && RD->hasNonTrivialDefaultConstructor()) {
+      // MSVC doesn't allow thread local variables with any constructors, but we
+      // only look for the default constructor.
+      Diag(var->getLocation(), diag::err_thread_nontrivial_ctor);
+      if (getLangOpts().CPlusPlus11)
+        Diag(var->getLocation(), diag::note_use_thread_local);
+    }
+  }
----------------
Richard Smith wrote:
> This seems really weird. We're already checking for non-constant initialization; do you have any idea what this check is for? You can check for 'any constructor' using `CXXRecordDecl::hasUserDeclaredConstructor`.
Yeah, this was broken.  I fixed the TLS_Static check below in r207675, and it works for __declspec(thread), so I nuked this code.

http://reviews.llvm.org/D3551






More information about the cfe-commits mailing list