aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2019-09-02 09:07:11 +0200
committerMartin Liska <marxin@gcc.gnu.org>2019-09-02 07:07:11 +0000
commitae0d3f6a593058ab9fd56a34f604852ea2dec79b (patch)
treec3b601db82ad4fda4657cb815a436a963f261361 /gcc/cp
parent9297e013293e4d332fc7c40859ea4dd9616e0d88 (diff)
downloadgcc-ae0d3f6a593058ab9fd56a34f604852ea2dec79b.zip
gcc-ae0d3f6a593058ab9fd56a34f604852ea2dec79b.tar.gz
gcc-ae0d3f6a593058ab9fd56a34f604852ea2dec79b.tar.bz2
Use cxx_printable_name for __PRETTY_FUNCTION__ in cp_fname_init.
2019-09-02 Martin Liska <mliska@suse.cz> PR c++/91155 * c-common.c (fname_as_string): Use cxx_printable_name for __PRETTY_FUNCTION__ same as was used before r265711. 2019-09-02 Martin Liska <mliska@suse.cz> PR c++/91155 * g++.dg/torture/pr91155.C: New test. From-SVN: r275292
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/decl.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 3497874..6de95cd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4511,13 +4511,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. */