Variable with same name for the register

NIIBE Yutaka gniibe@chroot.org
Thu Oct 26 22:29:00 GMT 2000


>From the end of September, GCC for SuperH works bad.  Here's the test
case.  This is code for SuperH, but it's not SuperH specific issue.

--------------------------
f(int a0)
{
  register long r3 __asm__ ("r3") = a0;
  asm volatile ("trapa #10": : "r" (r3));
}
--------------------------

GCC doesn't assign the register "r3" when the variable name is also "r3".
Yes, we have an workaround having specification of asm ("%r3") (putting
'%'), but the above code worked fine with older versions of GCC.

Here's a patch to indicate the problem.  I'm not sure this is the
solution or not.  Well, "it works for me" (TM).


2000-10-27  NIIBE Yutaka  <gniibe@chroot.org>, kaz Kojima <kkojima@rr.iij4u.or.jp>

	* c-decl.c (finish_decl): Call rest_of_decl_compilation when
	there's asmspec.

Index: gcc/c-decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-decl.c,v
retrieving revision 1.171
diff -c -3 -p -r1.171 c-decl.c
*** c-decl.c	2000/10/25 17:45:41	1.171
--- c-decl.c	2000/10/27 05:18:52
*************** finish_decl (decl, init, asmspec_tree)
*** 3743,3755 ****
        maybe_objc_check_decl (decl);
  
        if (!DECL_CONTEXT (decl))
! 	rest_of_decl_compilation (decl, asmspec,
! 				  (DECL_CONTEXT (decl) == 0
! 				   || TREE_ASM_WRITTEN (decl)), 0);
        else
  	{
  	  if (asmspec)
! 	    DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
  	  add_decl_stmt (decl);
  	}
  
--- 3743,3758 ----
        maybe_objc_check_decl (decl);
  
        if (!DECL_CONTEXT (decl))
! 	rest_of_decl_compilation (decl, asmspec, 1, 0);
        else
  	{
  	  if (asmspec)
! 	    {
! 	      DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
! 	      rest_of_decl_compilation (decl, asmspec,
! 					TREE_ASM_WRITTEN (decl), 0);
! 	    }
! 
  	  add_decl_stmt (decl);
  	}
  
-- 


More information about the Gcc-patches mailing list