diff mbox series

Fix location of tls_wrapper_fn (PR gcov-profile/88263).

Message ID 3a0fba60-3bc1-b220-00df-ceec0eca8a34@suse.cz
State New
Headers show
Series Fix location of tls_wrapper_fn (PR gcov-profile/88263). | expand

Commit Message

Martin Liška Jan. 14, 2019, 3:43 p.m. UTC
Hi.

This is another fix for the PR where I updated location of
tls_wrapper.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

Comments

Jason Merrill Jan. 14, 2019, 4:10 p.m. UTC | #1
On 1/14/19 10:43 AM, Martin Liška wrote:
> Hi.
> 
> This is another fix for the PR where I updated location of
> tls_wrapper.
> 
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
> 
> Ready to be installed?

OK.

Jason
diff mbox series

Patch

From 07811d1057196abad898c9aeda08cd9113aedf70 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Mon, 14 Jan 2019 14:57:01 +0100
Subject: [PATCH] Fix location of tls_wrapper_fn (PR gcov-profile/88263).

gcc/cp/ChangeLog:

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.

gcc/testsuite/ChangeLog:

2019-01-14  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/88263
	* g++.dg/gcov/pr88263-2.C: New test.
---
 gcc/cp/decl2.c                        |  4 +++-
 gcc/testsuite/g++.dg/gcov/pr88263-2.C | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/gcov/pr88263-2.C

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index dbab95fbc96..9085e5cb154 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3433,7 +3433,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;
diff --git a/gcc/testsuite/g++.dg/gcov/pr88263-2.C b/gcc/testsuite/g++.dg/gcov/pr88263-2.C
new file mode 100644
index 00000000000..f0cf15f5d0a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/pr88263-2.C
@@ -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 } }
-- 
2.20.1