builtins.c (fold_builtin_FUNCTION): Use lang_hooks.decl_printable_name.

gcc/
	* builtins.c (fold_builtin_FUNCTION): Use
	lang_hooks.decl_printable_name.

	gcc/cp/
	* g++.dg/cpp1y/builtin_FUNCTION.C: New.

From-SVN: r249784
This commit is contained in:
Nathan Sidwell 2017-06-29 14:00:44 +00:00 committed by Nathan Sidwell
parent f66459c160
commit f76b422479
4 changed files with 56 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2017-06-29 Nathan Sidwell <nathan@acm.org>
* builtins.c (fold_builtin_FUNCTION): Use
lang_hooks.decl_printable_name.
2017-06-29 Peter Bergner <bergner@vnet.ibm.com>
PR middle-end/81194

View File

@ -8739,13 +8739,12 @@ fold_builtin_FILE (location_t loc)
static inline tree
fold_builtin_FUNCTION ()
{
if (current_function_decl)
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
return build_string_literal (strlen (name) + 1, name);
}
const char *name = "";
return build_string_literal (1, "");
if (current_function_decl)
name = lang_hooks.decl_printable_name (current_function_decl, 0);
return build_string_literal (strlen (name) + 1, name);
}
/* Fold a call to __builtin_LINE to an integer constant. */

View File

@ -1,3 +1,7 @@
2017-06-29 Nathan Sidwell <nathan@acm.org>
* g++.dg/cpp1y/builtin_FUNCTION.C: New.
2017-06-29 Peter Bergner <bergner@vnet.ibm.com>
PR middle-end/81194

View File

@ -0,0 +1,42 @@
// { dg-do run }
#include <string.h>
const char *ct, *dt, *cv;
struct KLASS
{
KLASS () ;
~KLASS ();
operator int ();
};
KLASS::KLASS()
{
ct = __builtin_FUNCTION ();
}
KLASS::~KLASS ()
{
dt = __builtin_FUNCTION ();
}
KLASS::operator int ()
{
cv = __builtin_FUNCTION ();
return 0;
}
int main ()
{
int q = int (KLASS ());
if (strcmp (ct, "KLASS"))
return 1;
if (strcmp (dt, "~KLASS"))
return 2;
if (strcmp (cv, "operator int"))
return 3;
return 0;
}