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]

PATCH to add tree.c:expr_last


expr_last is a new utility function that does for COMPOUND_EXPRs what
tree_last does for TREE_LISTs.

Objective-C had a static function with the same name; its purpose was
different and not immediately apparent, so I just renamed it to
objc_expr_last.

Booted and tested i686-pc-linux-gnu, applied to trunk and tree-ssa.

2003-05-20  Jason Merrill  <jason@redhat.com>

	* tree.c (expr_last): New fn.
	* tree.h: Declare it.
	* objc/objc-act (expr_last): Rename to objc_expr_last.

*** tree.c.~1~	Tue May 13 13:06:52 2003
--- tree.c	Tue May 20 12:56:46 2003
*************** tree_cons (purpose, value, chain)
*** 1149,1154 ****
--- 1149,1166 ----
    return node;
  }
  
+ /* Return the last expression in a sequence of COMPOUND_EXPRs.  */
+ 
+ tree
+ expr_last (expr)
+      tree expr;
+ {
+   if (expr == NULL_TREE)
+     return expr;
+   while (TREE_CODE (expr) == COMPOUND_EXPR)
+     expr = TREE_OPERAND (expr, 1);
+   return expr;
+ }
  
  /* Return the size nominally occupied by an object of type TYPE
     when it resides in memory.  The value is measured in units of bytes,
*** tree.h.~1~	Mon May 12 05:18:52 2003
--- tree.h	Tue May 20 12:56:46 2003
*************** extern tree pedantic_non_lvalue		PARAMS 
*** 2870,2875 ****
--- 2870,2876 ----
  
  extern tree convert			PARAMS ((tree, tree));
  extern unsigned int expr_align		PARAMS ((tree));
+ extern tree expr_last			PARAMS ((tree));
  extern tree size_in_bytes		PARAMS ((tree));
  extern HOST_WIDE_INT int_size_in_bytes	PARAMS ((tree));
  extern tree bit_position		PARAMS ((tree));
*** objc/objc-act.c.~1~	2003-05-14 15:34:02.000000000 -0400
--- objc/objc-act.c	2003-05-20 13:24:38.000000000 -0400
*************** static void really_start_method			PARAMS
*** 217,223 ****
  static int comp_method_with_proto		PARAMS ((tree, tree));
  static int comp_proto_with_proto		PARAMS ((tree, tree));
  static tree get_arg_type_list			PARAMS ((tree, int, int));
! static tree expr_last				PARAMS ((tree));
  
  /* Utilities for debugging and error diagnostics.  */
  
--- 217,223 ----
  static int comp_method_with_proto		PARAMS ((tree, tree));
  static int comp_proto_with_proto		PARAMS ((tree, tree));
  static tree get_arg_type_list			PARAMS ((tree, int, int));
! static tree objc_expr_last			PARAMS ((tree));
  
  /* Utilities for debugging and error diagnostics.  */
  
*************** encode_field_decl (field_decl, curtype, 
*** 7002,7008 ****
  }
  
  static tree
! expr_last (complex_expr)
       tree complex_expr;
  {
    tree next;
--- 7002,7008 ----
  }
  
  static tree
! objc_expr_last (complex_expr)
       tree complex_expr;
  {
    tree next;
*************** start_method_def (method)
*** 7063,7069 ****
  
  	  if (arg_decl)
  	    {
! 	      tree last_expr = expr_last (arg_decl);
  
  	      /* Unite the abstract decl with its name.  */
  	      TREE_OPERAND (last_expr, 0) = KEYWORD_ARG_NAME (arglist);
--- 7063,7069 ----
  
  	  if (arg_decl)
  	    {
! 	      tree last_expr = objc_expr_last (arg_decl);
  
  	      /* Unite the abstract decl with its name.  */
  	      TREE_OPERAND (last_expr, 0) = KEYWORD_ARG_NAME (arglist);
*************** really_start_method (method, parmlist)
*** 7204,7210 ****
      {
        /* Unite the complex decl (specified in the abstract decl) with the
  	 function decl just synthesized..(int *), (int (*)()), (int (*)[]).  */
!       tree save_expr = expr_last (ret_decl);
  
        TREE_OPERAND (save_expr, 0) = method_decl;
        method_decl = ret_decl;
--- 7204,7210 ----
      {
        /* Unite the complex decl (specified in the abstract decl) with the
  	 function decl just synthesized..(int *), (int (*)()), (int (*)[]).  */
!       tree save_expr = objc_expr_last (ret_decl);
  
        TREE_OPERAND (save_expr, 0) = method_decl;
        method_decl = ret_decl;

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