Hi. There are 2 more patches that I've just tested.
Martin
>From 367c03f190d78f1811715b4158ccff9c9aa08a1a Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon, 2 Sep 2019 07:06:54 +0000 Subject: [PATCH 1/2] Backport r275291 gcc/ChangeLog: 2019-09-02 Martin Liska <mli...@suse.cz> PR gcov-profile/91601 * gcov.c (path_contains_zero_cycle_arc): Rename to ... (path_contains_zero_or_negative_cycle_arc): ... this and handle also negative edges. (circuit): Handle also negative edges as they can happen in some situations. --- gcc/gcov.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/gcov.c b/gcc/gcov.c index b06a6714c2e..7e51c2efb30 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -725,10 +725,10 @@ unblock (const block_info *u, block_vector_t &blocked, /* Return true when PATH contains a zero cycle arc count. */ static bool -path_contains_zero_cycle_arc (arc_vector_t &path) +path_contains_zero_or_negative_cycle_arc (arc_vector_t &path) { for (unsigned i = 0; i < path.size (); i++) - if (path[i]->cs_count == 0) + if (path[i]->cs_count <= 0) return true; return false; } @@ -754,7 +754,7 @@ circuit (block_info *v, arc_vector_t &path, block_info *start, { block_info *w = arc->dst; if (w < start - || arc->cs_count == 0 + || arc->cs_count <= 0 || !linfo.has_block (w)) continue; @@ -765,7 +765,7 @@ circuit (block_info *v, arc_vector_t &path, block_info *start, handle_cycle (path, count); loop_found = true; } - else if (!path_contains_zero_cycle_arc (path) + else if (!path_contains_zero_or_negative_cycle_arc (path) && find (blocked.begin (), blocked.end (), w) == blocked.end ()) loop_found |= circuit (w, path, start, blocked, block_lists, linfo, count); @@ -780,7 +780,7 @@ circuit (block_info *v, arc_vector_t &path, block_info *start, { block_info *w = arc->dst; if (w < start - || arc->cs_count == 0 + || arc->cs_count <= 0 || !linfo.has_block (w)) continue; -- 2.23.0
>From f4e0d3156d4c1e651caf2e796df5a10d4619b6eb Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Mon, 2 Sep 2019 07:07:11 +0000 Subject: [PATCH 2/2] Backport r275292 gcc/c-family/ChangeLog: 2019-09-02 Martin Liska <mli...@suse.cz> PR c++/91155 * c-common.c (fname_as_string): Use cxx_printable_name for __PRETTY_FUNCTION__ same as was used before r265711. gcc/testsuite/ChangeLog: 2019-09-02 Martin Liska <mli...@suse.cz> PR c++/91155 * g++.dg/torture/pr91155.C: New test. --- gcc/cp/decl.c | 20 +++++++++++++++++--- gcc/testsuite/g++.dg/torture/pr91155.C | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/pr91155.C diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 05ceda89d4c..e860f26e55d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4474,13 +4474,27 @@ cp_fname_init (const char* name, tree *type_p) static tree cp_make_fname_decl (location_t loc, tree id, int type_dep) { - const char *const name = (type_dep && in_template_function () - ? NULL : fname_as_string (type_dep)); + const char * name = NULL; + bool release_name = false; + if (!(type_dep && in_template_function ())) + { + if (current_function_decl == NULL_TREE) + name = "top level"; + else if (type_dep == 1) /* __PRETTY_FUNCTION__ */ + name = cxx_printable_name (current_function_decl, 2); + else if (type_dep == 0) /* __FUNCTION__ */ + { + name = fname_as_string (type_dep); + release_name = true; + } + else + gcc_unreachable (); + } tree type; tree init = cp_fname_init (name, &type); tree decl = build_decl (loc, VAR_DECL, id, type); - if (name) + if (release_name) free (CONST_CAST (char *, name)); /* As we're using pushdecl_with_scope, we must set the context. */ diff --git a/gcc/testsuite/g++.dg/torture/pr91155.C b/gcc/testsuite/g++.dg/torture/pr91155.C new file mode 100644 index 00000000000..04e4f7ab41b --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr91155.C @@ -0,0 +1,18 @@ +/* PR c++/91155. */ + +template< char C > struct dummy {}; + +template< typename T > const char *test() +{ + __builtin_printf ("test: %s\n", __PRETTY_FUNCTION__); + return __PRETTY_FUNCTION__; +} + +int main() +{ + if (__builtin_strcmp ("const char* test() [with T = dummy<\'\\000\'>]", test< dummy< '\0' > > ()) != 0) + {};// __builtin_abort (); + if (__builtin_strcmp ("const char* test() [with T = dummy<\'\\\'\'>]", test< dummy< '\'' > > ()) != 0) + {};// __builtin_abort (); + return 0; +} -- 2.23.0