aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-05-10 07:36:38 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-05-10 07:36:38 +0000
commit86c12f7629b43cbc259d8bbcb1875fff1f8e6a4f (patch)
tree5072c928276d92ea5db82bc91219a9b1b942ed7d
parent09dd57a3a4c2e71a972257587f1c3944a51d4846 (diff)
downloadgcc-86c12f7629b43cbc259d8bbcb1875fff1f8e6a4f.zip
gcc-86c12f7629b43cbc259d8bbcb1875fff1f8e6a4f.tar.gz
gcc-86c12f7629b43cbc259d8bbcb1875fff1f8e6a4f.tar.bz2
re PR c++/85400 (invalid Local Dynamic TLS relaxation for symbol defined in method)
PR c++/85400 cp/ * decl2.c (adjust_var_decl_tls_model): New static function. (comdat_linkage): Call it on a variable. (maybe_make_one_only): Likewise. c-family/ * c-attribs.c (handle_visibility_attribute): Do not set no_add_attrs. From-SVN: r260106
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-attribs.c5
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl2.c16
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/g++.dg/tls/pr85400.C24
6 files changed, 58 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 087379f..6ea5eaf 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index e063088..9bddc1a 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -2299,14 +2299,13 @@ handle_visibility_attribute (tree *node, tree name, tree args,
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);
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 98249e9..a2de8f6 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 9aae34a..6f3ad4c 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1838,6 +1838,17 @@ mark_vtable_entries (tree decl)
}
}
+/* 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. */
@@ -1888,6 +1899,9 @@ comdat_linkage (tree decl)
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
@@ -1926,6 +1940,8 @@ maybe_make_one_only (tree decl)
/* 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);
}
}
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 45327ac..5bbcd70 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+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
diff --git a/gcc/testsuite/g++.dg/tls/pr85400.C b/gcc/testsuite/g++.dg/tls/pr85400.C
new file mode 100644
index 0000000..f8d1bce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/pr85400.C
@@ -0,0 +1,24 @@
+// 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);
+}