This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

charset __FUNCTION__ patch


__FUNCTION__ and company need translation as well.

(Zack made me do the alloc() stuff.  I was perfectly happy with a
static and no free's :-)).

Bootstrap still going.  The charset testcases pass already.

Ok, pending tests?

Aldy

-- 
Will hack for surf.

	* 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.

Index: testsuite/gcc.dg/charset/function.c
===================================================================
RCS file: testsuite/gcc.dg/charset/function.c
diff -N testsuite/gcc.dg/charset/function.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.dg/charset/function.c	28 May 2004 01:16:09 -0000
***************
*** 0 ****
--- 1,10 ----
+ /* { dg-do compile }
+    { dg-require-iconv "IBM-1047" }
+    { dg-final { scan-assembler-not "\"foobar\"" } } */
+ 
+ const char *str;
+ 
+ void foobar (void)
+ {
+   str = __FUNCTION__;
+ }
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.501
diff -c -p -r1.501 c-decl.c
*** c-decl.c	19 May 2004 01:28:49 -0000	1.501
--- c-decl.c	28 May 2004 01:16:13 -0000
*************** c_make_fname_decl (tree id, int type_dep
*** 2362,2367 ****
--- 2362,2368 ----
    DECL_ARTIFICIAL (decl) = 1;
  
    init = build_string (length + 1, name);
+   free (name);
    TREE_TYPE (init) = type;
    DECL_INITIAL (decl) = init;
  
Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.501
diff -c -p -r1.501 c-common.c
*** c-common.c	22 May 2004 18:16:38 -0000	1.501
--- c-common.c	28 May 2004 01:16:16 -0000
*************** finish_fname_decls (void)
*** 1086,1097 ****
  }
  
  /* Return the text name of the current function, suitably prettified
!    by PRETTY_P.  */
  
  const char *
  fname_as_string (int pretty_p)
  {
    const char *name = "top level";
    int vrb = 2;
  
    if (! pretty_p)
--- 1086,1098 ----
  }
  
  /* Return the text name of the current function, suitably prettified
!    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)
*************** fname_as_string (int pretty_p)
*** 1103,1109 ****
    if (current_function_decl)
      name = lang_hooks.decl_printable_name (current_function_decl, vrb);
  
!   return name;
  }
  
  /* Return the VAR_DECL for a const char array naming the current
--- 1104,1129 ----
    if (current_function_decl)
      name = lang_hooks.decl_printable_name (current_function_decl, vrb);
  
!   if (c_lex_string_translate)
!     {
!       int len = strlen (name) + 3; /* Two for '"'s.  One for NULL.  */
!       cpp_string cstr = { 0, 0 }, strname;
! 
!       namep = (char *) xcalloc (len, sizeof (char));
!       snprintf (namep, len, "\"%s\"", name);
!       strname.text = namep;
!       strname.len = len - 1;
! 
!       if (cpp_interpret_string (parse_in, &strname, 1, &cstr, false))
! 	return cstr.text;
!     }
!   else
!     {
!       namep = (char *) xcalloc (strlen (name) + 1, sizeof (char));
!       strcpy (namep, name);
!     }
! 
!   return namep;
  }
  
  /* Return the VAR_DECL for a const char array naming the current
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1210
diff -c -p -r1.1210 decl.c
*** cp/decl.c	23 May 2004 21:06:56 -0000	1.1210
--- cp/decl.c	28 May 2004 01:16:21 -0000
*************** cp_make_fname_decl (tree id, int type_de
*** 3085,3090 ****
--- 3085,3092 ----
  			    ? NULL : fname_as_string (type_dep));
    tree type;
    tree init = cp_fname_init (name, &type);
+   if (name)
+     free ((char *) name);
    tree decl = build_decl (VAR_DECL, id, type);
  
    /* As we're using pushdecl_with_scope, we must set the context.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]