{
if (DECL_INITIAL (node))
{
- error ("variable %q+D definition is marked dllimport",
- node);
+ error ("variable %q+D definition is marked dllimport", node);
*no_add_attrs = true;
}
+#if TARGET_WIN32_TLS
+ else if (DECL_THREAD_LOCAL_P (node))
+ {
+ error ("thread-local variable %q+D declared as dllimport", node);
+ *no_add_attrs = true;
+ }
+#endif
/* `extern' needn't be specified with dllimport.
Specify `extern' now and hope for the best. Sigh. */
&& flag_keep_inline_dllexport)
/* An exported function, even if inline, must be emitted. */
DECL_EXTERNAL (node) = 0;
+#if TARGET_WIN32_TLS
+ else if (VAR_P (node) && DECL_THREAD_LOCAL_P (node))
+ {
+ error ("thread-local variable %q+D declared as dllexport", node);
+ *no_add_attrs = true;
+ }
+#endif
/* Report error if symbol is not accessible at global scope. */
if (!TREE_PUBLIC (node) && VAR_OR_FUNCTION_DECL_P (node))
--- /dev/null
+/* { dg-do compile { target i?86-*-mingw* x86_64-*-mingw* } } */
+
+__declspec (dllimport) __thread int foo1; /* { dg-error "thread-local variable" } */
+
+__declspec (dllexport) __thread int foo2; /* { dg-error "thread-local variable" } */