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]

fix c_tree_printer vs types


Discovered %T didn't work when I went to use it.


r~


        * c-objc-common.c (c_tree_printer): Handle types correctly.
        Factor code a bit.

Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.14.2.19
diff -c -p -d -r1.14.2.19 c-objc-common.c
*** c-objc-common.c	28 Sep 2003 06:06:04 -0000	1.14.2.19
--- c-objc-common.c	31 Oct 2003 07:03:50 -0000
*************** static bool
*** 295,323 ****
  c_tree_printer (pretty_printer *pp, text_info *text)
  {
    tree t = va_arg (*text->args_ptr, tree);
  
    switch (*text->format_spec)
      {
      case 'D':
      case 'F':
      case 'T':
!       {
!         const char *n = DECL_NAME (t)
!           ? (*lang_hooks.decl_printable_name) (t, 2)
!           : "({anonymous})";
!         pp_string (pp, n);
!       }
!       return true;
  
      case 'E':
!        if (TREE_CODE (t) == IDENTIFIER_NODE)
!          {
!            pp_string (pp, IDENTIFIER_POINTER (t));
!            return true;
!          }
!        return false;
  
      default:
        return false;
      }
  }
--- 295,335 ----
  c_tree_printer (pretty_printer *pp, text_info *text)
  {
    tree t = va_arg (*text->args_ptr, tree);
+   const char *n = "({anonymous})";
  
    switch (*text->format_spec)
      {
      case 'D':
      case 'F':
+       if (DECL_NAME (t))
+ 	n = (*lang_hooks.decl_printable_name) (t, 2);
+       break;
+ 
      case 'T':
!       if (TREE_CODE (t) == TYPE_DECL)
! 	{
! 	  if (DECL_NAME (t))
! 	    n = (*lang_hooks.decl_printable_name) (t, 2);
! 	}
!       else
! 	{
! 	  t = TYPE_NAME (t);
! 	  if (t)
! 	    n = IDENTIFIER_POINTER (t);
! 	}
!       break;
  
      case 'E':
!       if (TREE_CODE (t) == IDENTIFIER_NODE)
! 	n = IDENTIFIER_POINTER (t);
!       else
!         return false;
!       break;
  
      default:
        return false;
      }
+ 
+   pp_string (pp, n);
+   return true;
  }


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