]> gcc.gnu.org Git - gcc.git/commitdiff
Use proper location for tls_init function (PR c++/88263).
authorMartin Liska <mliska@suse.cz>
Thu, 27 Dec 2018 08:46:13 +0000 (09:46 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 27 Dec 2018 08:46:13 +0000 (08:46 +0000)
2018-12-27  Martin Liska  <mliska@suse.cz>

PR c++/88263
* decl2.c (get_local_tls_init_fn): Add location_t argument and
use it.
(get_tls_init_fn): Call it with location of variable for which
we'll need to create tls_init function.
(handle_tls_init): Likewise.
2018-12-27  Martin Liska  <mliska@suse.cz>

PR c++/88263
* g++.dg/gcov/pr88263.C: New test.

From-SVN: r267429

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gcov/pr88263.C [new file with mode: 0644]

index 2201a472d53e40ed32f25a3c5f13820ebb769e67..a53ea05251017a3cbf440cfd1af560f7ebd1d385 100644 (file)
@@ -1,3 +1,12 @@
+2018-12-27  Martin Liska  <mliska@suse.cz>
+
+       PR c++/88263
+       * decl2.c (get_local_tls_init_fn): Add location_t argument and
+       use it.
+       (get_tls_init_fn): Call it with location of variable for which
+       we'll need to create tls_init function.
+       (handle_tls_init): Likewise.
+
 2018-12-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/86524
index 1b3e758b6253c79c966948c68469a58f4899c9fb..7997a1dac85d597563a3c2c67ab760364e5dd4af 100644 (file)
@@ -3331,15 +3331,15 @@ var_needs_tls_wrapper (tree var)
    translation unit.  */
 
 static tree
-get_local_tls_init_fn (void)
+get_local_tls_init_fn (location_t loc)
 {
   tree sname = get_identifier ("__tls_init");
   tree fn = get_global_binding (sname);
   if (!fn)
     {
-      fn = build_lang_decl (FUNCTION_DECL, sname,
-                            build_function_type (void_type_node,
-                                                 void_list_node));
+      fn = build_lang_decl_loc (loc, FUNCTION_DECL, sname,
+                               build_function_type (void_type_node,
+                                                    void_list_node));
       SET_DECL_LANGUAGE (fn, lang_c);
       TREE_PUBLIC (fn) = false;
       DECL_ARTIFICIAL (fn) = true;
@@ -3369,7 +3369,7 @@ get_tls_init_fn (tree var)
   /* If the variable is internal, or if we can't generate aliases,
      call the local init function directly.  */
   if (!TREE_PUBLIC (var) || !TARGET_SUPPORTS_ALIASES)
-    return get_local_tls_init_fn ();
+    return get_local_tls_init_fn (DECL_SOURCE_LOCATION (var));
 
   tree sname = mangle_tls_init_fn (var);
   tree fn = get_global_binding (sname);
@@ -4435,7 +4435,7 @@ handle_tls_init (void)
   set_decl_tls_model (guard, decl_default_tls_model (guard));
   pushdecl_top_level_and_finish (guard, NULL_TREE);
 
-  tree fn = get_local_tls_init_fn ();
+  tree fn = get_local_tls_init_fn (loc);
   start_preparsed_function (fn, NULL_TREE, SF_PRE_PARSED);
   tree body = begin_function_body ();
   tree if_stmt = begin_if_stmt ();
index 4b39847d9d8a4937ae01722160b05387833e1d93..01e0999181f9f8aa7716dd526b258d489f0002f5 100644 (file)
@@ -1,3 +1,8 @@
+2018-12-27  Martin Liska  <mliska@suse.cz>
+
+       PR c++/88263
+       * g++.dg/gcov/pr88263.C: New test.
+
 2018-12-26  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85357
diff --git a/gcc/testsuite/g++.dg/gcov/pr88263.C b/gcc/testsuite/g++.dg/gcov/pr88263.C
new file mode 100644 (file)
index 0000000..10f0933
--- /dev/null
@@ -0,0 +1,30 @@
+// PR gcov-profile/88263
+// { dg-options "-fprofile-arcs -ftest-coverage -std=c++11" }
+// { dg-do run { target native } }
+
+#include <sstream>
+
+namespace log {
+
+class Logstream {
+public:
+
+private:
+    /// The logging stream
+    static thread_local std::ostringstream os_;
+};
+
+}
+
+namespace log {
+
+thread_local std::ostringstream Logstream::os_;
+
+}
+
+int main()
+{
+  return 0;
+}
+
+// { dg-final { run-gcov pr88263.C } }
This page took 0.10074 seconds and 5 git commands to generate.