Fix location of tls_wrapper_fn (PR gcov-profile/88263).
authorMartin Liska <mliska@suse.cz>
Mon, 14 Jan 2019 18:40:34 +0000 (19:40 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 14 Jan 2019 18:40:34 +0000 (18:40 +0000)
2019-01-14  Martin Liska  <mliska@suse.cz>

PR gcov-profile/88263
* decl2.c (get_tls_wrapper_fn): Use DECL_SOURCE_LOCATION
as location of the TLS wrapper.
2019-01-14  Martin Liska  <mliska@suse.cz>

PR gcov-profile/88263
* g++.dg/gcov/pr88263-2.C: New test.

From-SVN: r267921

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

index 32b2ab1f82efbf369e16ba65d681bc683908bf98..82412a789263d7b333a91b9da12f90260cd2324c 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-14  Martin Liska  <mliska@suse.cz>
+
+       PR gcov-profile/88263
+       * decl2.c (get_tls_wrapper_fn): Use DECL_SOURCE_LOCATION
+       as location of the TLS wrapper.
+
 2019-01-12  Paolo Carlini  <paolo.carlini@oracle.com>
 
        * decl.c (cp_finish_decl): Improve error location.
index e4cf4e0a361caac390dcc323a39bb06dbe20b3c8..1314ca812ee2b9895d3af1900f91f72660d51465 100644 (file)
@@ -3445,7 +3445,9 @@ get_tls_wrapper_fn (tree var)
       tree type = non_reference (TREE_TYPE (var));
       type = build_reference_type (type);
       tree fntype = build_function_type (type, void_list_node);
-      fn = build_lang_decl (FUNCTION_DECL, sname, fntype);
+
+      fn = build_lang_decl_loc (DECL_SOURCE_LOCATION (var),
+                               FUNCTION_DECL, sname, fntype);
       SET_DECL_LANGUAGE (fn, lang_c);
       TREE_PUBLIC (fn) = TREE_PUBLIC (var);
       DECL_ARTIFICIAL (fn) = true;
index 09ed22a909c36329fbb1e3dd7e6aaa604f822759..093c362f13dc390e9fed1385275c4b4e980fd793 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-14  Martin Liska  <mliska@suse.cz>
+
+       PR gcov-profile/88263
+       * g++.dg/gcov/pr88263-2.C: New test.
+
 2019-01-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/88796
diff --git a/gcc/testsuite/g++.dg/gcov/pr88263-2.C b/gcc/testsuite/g++.dg/gcov/pr88263-2.C
new file mode 100644 (file)
index 0000000..f0cf15f
--- /dev/null
@@ -0,0 +1,25 @@
+// PR gcov-profile/88263
+// { dg-options "-fprofile-arcs -ftest-coverage -std=c++11" }
+// { dg-do run { target native } }
+
+#include <sstream>
+
+namespace logging {
+    class Logstream {
+       ~Logstream();
+       static thread_local std::ostringstream os_;
+    };
+}
+namespace logging {
+    thread_local std::ostringstream Logstream::os_;
+    Logstream::~Logstream() {
+       os_.clear();
+    }
+}
+
+int main()
+{
+  return 0;
+}
+
+// { dg-final { run-gcov pr88263-2.C } }