+2018-05-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR c++/85400
+ * c-attribs.c (handle_visibility_attribute): Do not set no_add_attrs.
+
2018-05-07 Nathan Sidwell <nathan@acm.org>
* c.opt (ffor-scope): Remove functionality, issue warning.
static tree
handle_tls_model_attribute (tree *node, tree name, tree args,
- int ARG_UNUSED (flags), bool *no_add_attrs)
+ int ARG_UNUSED (flags),
+ bool *ARG_UNUSED (no_add_attrs))
{
tree id;
tree decl = *node;
enum tls_model kind;
- *no_add_attrs = true;
-
if (!VAR_P (decl) || !DECL_THREAD_LOCAL_P (decl))
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
+2018-05-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR c++/85400
+ * decl2.c (adjust_var_decl_tls_model): New static function.
+ (comdat_linkage): Call it on a variable.
+ (maybe_make_one_only): Likewise.
+
2018-05-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/85713
}
}
+/* Adjust the TLS model on variable DECL if need be, typically after
+ the linkage of DECL has been modified. */
+
+static void
+adjust_var_decl_tls_model (tree decl)
+{
+ if (CP_DECL_THREAD_LOCAL_P (decl)
+ && !lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl)))
+ set_decl_tls_model (decl, decl_default_tls_model (decl));
+}
+
/* Set DECL up to have the closest approximation of "initialized common"
linkage available. */
if (TREE_PUBLIC (decl))
DECL_COMDAT (decl) = 1;
+
+ if (VAR_P (decl))
+ adjust_var_decl_tls_model (decl);
}
/* For win32 we also want to put explicit instantiations in
/* Mark it needed so we don't forget to emit it. */
node->forced_by_abi = true;
TREE_USED (decl) = 1;
+
+ adjust_var_decl_tls_model (decl);
}
}
}
+2018-05-10 Eric Botcazou <ebotcazou@adacore.com>
+
+ * g++.dg/tls/pr85400.C: New test.
+
2018-05-09 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/85713
--- /dev/null
+// PR c++/85400
+// Testcase by Brian Vandenberg <phantall@gmail.com>
+
+// { dg-do link { target c++11 } }
+// { dg-require-effective-target fpic }
+// { dg-require-effective-target shared }
+// { dg-require-effective-target tls }
+// { dg-options "-shared -fPIC -O" }
+// { dg-add-options tls }
+
+struct Test
+{
+ int blah (int y)
+ {
+ thread_local int mything = 3;
+ mything = y > 0 ? y : mything;
+ return mything;
+ }
+};
+
+int stuff (Test& test, int y)
+{
+ return test.blah(y);
+}