+2004-05-28 Aldy Hernandez <aldyh@redhat.com>
+
+ * testsuite/g++.dg/charset/function.cc: New.
+
+ * testsuite/gcc.dg/charset/function.c: New.
+
+ * c-decl.c (c_make_fname_decl): Free return value from
+ fname_as_string.
+
+ * cp/decl.c (cp_make_fname_decl): Free return value from
+ fname_as_string.
+
+ * c-common.c (fname_as_string): Translate if necessary.
+
2004-05-28 Geoffrey Keating <geoffk@apple.com>
* stringpool.c: Add comments to PCH saving/restoring routines.
}
/* Return the text name of the current function, suitably prettified
- by PRETTY_P. */
+ by PRETTY_P. Return string must be freed by caller. */
const char *
fname_as_string (int pretty_p)
{
const char *name = "top level";
+ char *namep;
int vrb = 2;
if (! pretty_p)
if (current_function_decl)
name = lang_hooks.decl_printable_name (current_function_decl, vrb);
- return name;
+ if (c_lex_string_translate)
+ {
+ int len = strlen (name) + 3; /* Two for '"'s. One for NULL. */
+ cpp_string cstr = { 0, 0 }, strname;
+
+ namep = xmalloc (len);
+ snprintf (namep, len, "\"%s\"", name);
+ strname.text = (unsigned char *) namep;
+ strname.len = len - 1;
+
+ if (cpp_interpret_string (parse_in, &strname, 1, &cstr, false))
+ return (char *) cstr.text;
+ }
+ else
+ {
+ namep = (char *) xcalloc (strlen (name) + 1, sizeof (char));
+ namep = xstrdup (name);
+ }
+
+ return namep;
}
/* Return the VAR_DECL for a const char array naming the current
DECL_ARTIFICIAL (decl) = 1;
init = build_string (length + 1, name);
+ free ((char *) name);
TREE_TYPE (init) = type;
DECL_INITIAL (decl) = init;