Patch to remove build_parse_node

Joseph S. Myers jsm28@cam.ac.uk
Sun Jan 28 10:48:00 GMT 2001


I previously noted
<URL: http://gcc.gnu.org/ml/gcc/2001-01/msg00894.html > that build_nt
and build_parse_node were identical.  In the absence of any comments
then on whether one of these functions should die, and which one, this
patch gets rid of build_parse_node since it was the one with fewer
calls.  (This change should make the compiler very slightly smaller.)

Bootstrapped with no regressions on i686-pc-linux-gnu.  OK to commit?

2001-01-28  Joseph S. Myers  <jsm28@cam.ac.uk>

	* tree.c, tree.h (build_parse_node): Remove; was identical to
	build_nt.
	* c-lang.c (start_cdtor), objc/objc-act.c
	(build_module_descriptor): Use build_nt instead of
	build_parse_node.

2001-01-28  Joseph S. Myers  <jsm28@cam.ac.uk>

	* decl2.c (build_expr_from_tree), lex.c (make_pointer_declarator,
	make_reference_declarator, make_call_declarator), method.c
	(implicitly_declare_fn), parse.y (namespace_using_decl,
	notype_unqualified_id, expr_or_declarator, new_type_id,
	after_type_declarator, direct_after_type_declarator,
	notype_declarator, complex_notype_declarator,
	complex_direct_notype_declarator, qualified_id,
	notype_qualified_id, overqualified_id, direct_new_declarator,
	absdcl, direct_abstract_declarator, conversion_declarator), pt.c
	(tsubst), semantics.c (begin_constructor_declarator): Use build_nt
	instead of build_parse_node.

diff -rupN gcc.orig/c-lang.c gcc/c-lang.c
--- gcc.orig/c-lang.c	Wed Jan 10 10:49:09 2001
+++ gcc/c-lang.c	Sun Jan 14 16:11:38 2001
@@ -187,10 +187,9 @@ start_cdtor (method_type)
   tree body;
 
   start_function (void_list_node_1,
-		  build_parse_node (CALL_EXPR, fnname,
-				    tree_cons (NULL_TREE, NULL_TREE,
-					       void_list_node_1),
-				    NULL_TREE),
+		  build_nt (CALL_EXPR, fnname,
+			    tree_cons (NULL_TREE, NULL_TREE, void_list_node_1),
+			    NULL_TREE),
 		  NULL_TREE, NULL_TREE);
   store_parm_decls ();
 
diff -rupN gcc.orig/cp/decl2.c gcc/cp/decl2.c
--- gcc.orig/cp/decl2.c	Thu Jan 11 15:58:51 2001
+++ gcc/cp/decl2.c	Sun Jan 14 16:12:39 2001
@@ -4025,8 +4025,8 @@ build_expr_from_tree (t)
     case ARRAY_REF:
       if (TREE_OPERAND (t, 0) == NULL_TREE)
 	/* new-type-id */
-	return build_parse_node (ARRAY_REF, NULL_TREE,
-				 build_expr_from_tree (TREE_OPERAND (t, 1)));
+	return build_nt (ARRAY_REF, NULL_TREE,
+			 build_expr_from_tree (TREE_OPERAND (t, 1)));
       return grok_array_decl (build_expr_from_tree (TREE_OPERAND (t, 0)),
 			      build_expr_from_tree (TREE_OPERAND (t, 1)));
 
diff -rupN gcc.orig/cp/lex.c gcc/cp/lex.c
--- gcc.orig/cp/lex.c	Sat Jan 13 17:31:40 2001
+++ gcc/cp/lex.c	Sun Jan 14 16:12:52 2001
@@ -149,7 +149,7 @@ make_pointer_declarator (cv_qualifiers, 
   if (target && TREE_CODE (target) == IDENTIFIER_NODE
       && ANON_AGGRNAME_P (target))
     error ("type name expected before `*'");
-  target = build_parse_node (INDIRECT_REF, target);
+  target = build_nt (INDIRECT_REF, target);
   TREE_TYPE (target) = cv_qualifiers;
   return target;
 }
@@ -181,7 +181,7 @@ make_reference_declarator (cv_qualifiers
       if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
 	  error ("type name expected before `&'");
     }
-  target = build_parse_node (ADDR_EXPR, target);
+  target = build_nt (ADDR_EXPR, target);
   TREE_TYPE (target) = cv_qualifiers;
   return target;
 }
@@ -190,11 +190,11 @@ tree
 make_call_declarator (target, parms, cv_qualifiers, exception_specification)
      tree target, parms, cv_qualifiers, exception_specification;
 {
-  target = build_parse_node (CALL_EXPR, target,
-			     tree_cons (parms, cv_qualifiers, NULL_TREE),
-			     /* The third operand is really RTL.  We
-				shouldn't put anything there.  */
-			     NULL_TREE);
+  target = build_nt (CALL_EXPR, target,
+		     tree_cons (parms, cv_qualifiers, NULL_TREE),
+		     /* The third operand is really RTL.  We
+			shouldn't put anything there.  */
+		     NULL_TREE);
   CALL_DECLARATOR_EXCEPTION_SPEC (target) = exception_specification;
   return target;
 }
diff -rupN gcc.orig/cp/method.c gcc/cp/method.c
--- gcc.orig/cp/method.c	Thu Jan 11 00:07:22 2001
+++ gcc/cp/method.c	Sun Jan 14 16:10:30 2001
@@ -2768,7 +2768,7 @@ implicitly_declare_fn (kind, type, const
     {
     case sfk_destructor:
       /* Destructor.  */
-      name = build_parse_node (BIT_NOT_EXPR, name);
+      name = build_nt (BIT_NOT_EXPR, name);
       args = void_list_node;
       raises = synthesize_exception_spec (type, &locate_dtor, 0);
       break;
@@ -2826,7 +2826,7 @@ implicitly_declare_fn (kind, type, const
   {
     tree declarator = make_call_declarator (name, args, NULL_TREE, raises);
     if (retref)
-      declarator = build_parse_node (ADDR_EXPR, declarator);
+      declarator = build_nt (ADDR_EXPR, declarator);
 
     fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE, NULL_TREE);
   }
diff -rupN gcc.orig/cp/parse.y gcc/cp/parse.y
--- gcc.orig/cp/parse.y	Thu Jan 11 12:43:41 2001
+++ gcc/cp/parse.y	Sun Jan 14 16:10:30 2001
@@ -545,11 +545,11 @@ using_decl:
 
 namespace_using_decl:
 	  USING namespace_qualifier identifier
-	        { $$ = build_parse_node (SCOPE_REF, $2, $3); }
+	        { $$ = build_nt (SCOPE_REF, $2, $3); }
 	| USING global_scope identifier
-	        { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
+	        { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
 	| USING global_scope namespace_qualifier identifier
-	        { $$ = build_parse_node (SCOPE_REF, $3, $4); }
+	        { $$ = build_nt (SCOPE_REF, $3, $4); }
 	;
 
 using_directive:
@@ -1442,9 +1442,9 @@ expr_no_comma_rangle:
 
 notype_unqualified_id:
 	  '~' see_typename identifier
-		{ $$ = build_parse_node (BIT_NOT_EXPR, $3); }
+		{ $$ = build_nt (BIT_NOT_EXPR, $3); }
 	| '~' see_typename template_type
-		{ $$ = build_parse_node (BIT_NOT_EXPR, $3); }
+		{ $$ = build_nt (BIT_NOT_EXPR, $3); }
         | template_id
 	| operator_name
 	| IDENTIFIER
@@ -1500,9 +1500,9 @@ expr_or_declarator_intern:
 expr_or_declarator:
 	  notype_unqualified_id
 	| '*' expr_or_declarator_intern  %prec UNARY
-		{ $$ = build_parse_node (INDIRECT_REF, $2); }
+		{ $$ = build_nt (INDIRECT_REF, $2); }
 	| '&' expr_or_declarator_intern  %prec UNARY
-		{ $$ = build_parse_node (ADDR_EXPR, $2); }
+		{ $$ = build_nt (ADDR_EXPR, $2); }
 	| '(' expr_or_declarator_intern ')'
 		{ $$ = $2; }
 	;
@@ -2767,7 +2767,7 @@ new_type_id:
 		{
 		  if (pedantic)
 		    pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
-		  $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
+		  $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
 		  $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
 		  $$.new_type_flag = $2.new_type_flag;
 		}
@@ -2828,7 +2828,7 @@ after_type_declarator:
 		{ $$ = make_reference_declarator (NULL_TREE, $2); }
 	| ptr_to_mem cv_qualifiers after_type_declarator_intern
 		{ tree arg = make_pointer_declarator ($2, $3);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| direct_after_type_declarator
 	;
@@ -2837,14 +2837,14 @@ direct_after_type_declarator:
 	  direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt  %prec '.'
 		{ $$ = make_call_declarator ($$, $2, $3, $4); }
 	| direct_after_type_declarator '[' expr ']'
-		{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
+		{ $$ = build_nt (ARRAY_REF, $$, $3); }
 	| direct_after_type_declarator '[' ']'
-		{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+		{ $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
 	| '(' after_type_declarator_intern ')'
 		{ $$ = $2; }
 	| nested_name_specifier type_name  %prec EMPTY
 		{ push_nested_class ($1, 3);
-		  $$ = build_parse_node (SCOPE_REF, $$, $2);
+		  $$ = build_nt (SCOPE_REF, $$, $2);
 		  TREE_COMPLEXITY ($$) = current_class_depth; }
 	| type_name  %prec EMPTY
 	;
@@ -2906,7 +2906,7 @@ notype_declarator:
 		{ $$ = make_reference_declarator (NULL_TREE, $2); }
 	| ptr_to_mem cv_qualifiers notype_declarator_intern
 		{ tree arg = make_pointer_declarator ($2, $3);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| direct_notype_declarator
 	;
@@ -2922,7 +2922,7 @@ complex_notype_declarator:
 		{ $$ = make_reference_declarator (NULL_TREE, $2); }
 	| ptr_to_mem cv_qualifiers notype_declarator_intern
 		{ tree arg = make_pointer_declarator ($2, $3);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| complex_direct_notype_declarator
 	;
@@ -2933,20 +2933,20 @@ complex_direct_notype_declarator:
 	| '(' complex_notype_declarator ')'
 		{ $$ = $2; }
 	| direct_notype_declarator '[' expr ']'
-		{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
+		{ $$ = build_nt (ARRAY_REF, $$, $3); }
 	| direct_notype_declarator '[' ']'
-		{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+		{ $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
 	| notype_qualified_id
                 { enter_scope_of ($1); }
 	| global_scope notype_qualified_id
                 { enter_scope_of ($2); $$ = $2;}
 	| global_scope notype_unqualified_id
-                { $$ = build_parse_node (SCOPE_REF, global_namespace, $2);
+                { $$ = build_nt (SCOPE_REF, global_namespace, $2);
 		  enter_scope_of ($$); 
 		}
         | nested_name_specifier notype_template_declarator
                 { got_scope = NULL_TREE;
-		  $$ = build_parse_node (SCOPE_REF, $1, $2);
+		  $$ = build_nt (SCOPE_REF, $1, $2);
 		  enter_scope_of ($$);
 		}
 	;
@@ -2954,19 +2954,19 @@ complex_direct_notype_declarator:
 qualified_id:
 	  nested_name_specifier unqualified_id
 		{ got_scope = NULL_TREE;
-		  $$ = build_parse_node (SCOPE_REF, $$, $2); }
+		  $$ = build_nt (SCOPE_REF, $$, $2); }
         | nested_name_specifier object_template_id
                 { got_scope = NULL_TREE;
- 		  $$ = build_parse_node (SCOPE_REF, $1, $2); }
+ 		  $$ = build_nt (SCOPE_REF, $1, $2); }
 	;
 
 notype_qualified_id:
 	  nested_name_specifier notype_unqualified_id
 		{ got_scope = NULL_TREE;
-		  $$ = build_parse_node (SCOPE_REF, $$, $2); }
+		  $$ = build_nt (SCOPE_REF, $$, $2); }
         | nested_name_specifier object_template_id
                 { got_scope = NULL_TREE;
-		  $$ = build_parse_node (SCOPE_REF, $1, $2); }
+		  $$ = build_nt (SCOPE_REF, $1, $2); }
 	;
 
 overqualified_id:
@@ -3173,11 +3173,11 @@ new_declarator:
 		{ $$ = make_reference_declarator ($2, NULL_TREE); }
 	| ptr_to_mem cv_qualifiers  %prec EMPTY
 		{ tree arg = make_pointer_declarator ($2, NULL_TREE);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| ptr_to_mem cv_qualifiers new_declarator
 		{ tree arg = make_pointer_declarator ($2, $3);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| direct_new_declarator  %prec EMPTY
 	;
@@ -3185,9 +3185,9 @@ new_declarator:
 /* ISO direct-new-declarator (5.3.4) */
 direct_new_declarator:
 	  '[' expr ']'
-		{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
+		{ $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
 	| direct_new_declarator '[' expr ']'
-		{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
+		{ $$ = build_nt (ARRAY_REF, $$, $3); }
 	;
 
 absdcl_intern:
@@ -3220,11 +3220,11 @@ absdcl:
 		{ $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
 	| ptr_to_mem cv_qualifiers  %prec EMPTY
 		{ tree arg = make_pointer_declarator ($2, NULL_TREE);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| ptr_to_mem cv_qualifiers absdcl_intern
 		{ tree arg = make_pointer_declarator ($2, $3);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	| direct_abstract_declarator  %prec EMPTY
 	;
@@ -3239,9 +3239,9 @@ direct_abstract_declarator:
 	| direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt  %prec '.'
 		{ $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
 	| direct_abstract_declarator '[' expr ']'  %prec '.'
-		{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
+		{ $$ = build_nt (ARRAY_REF, $$, $3); }
 	| direct_abstract_declarator '[' ']'  %prec '.'
-		{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+		{ $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
 	| '(' complex_parmlist ')' cv_qualifiers exception_specification_opt  %prec '.'
 		{ $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
 	| regcast_or_absdcl cv_qualifiers exception_specification_opt  %prec '.'
@@ -3249,9 +3249,9 @@ direct_abstract_declarator:
 	| fcast_or_absdcl cv_qualifiers exception_specification_opt  %prec '.'
 		{ set_quals_and_spec ($$, $2, $3); }
 	| '[' expr ']'  %prec '.'
-		{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
+		{ $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
 	| '[' ']'  %prec '.'
-		{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
+		{ $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
 	;
 
 /* For C++, decls and stmts can be intermixed, so we don't need to
@@ -3781,7 +3781,7 @@ conversion_declarator:
 		{ $$ = make_reference_declarator ($2, $3); }
 	| ptr_to_mem cv_qualifiers conversion_declarator
 		{ tree arg = make_pointer_declarator ($2, $3);
-		  $$ = build_parse_node (SCOPE_REF, $1, arg);
+		  $$ = build_nt (SCOPE_REF, $1, arg);
 		}
 	;
 
diff -rupN gcc.orig/cp/pt.c gcc/cp/pt.c
--- gcc.orig/cp/pt.c	Thu Jan 11 12:43:41 2001
+++ gcc/cp/pt.c	Sun Jan 14 16:10:30 2001
@@ -6804,7 +6804,7 @@ tsubst (t, args, complain, in_decl)
 	if (e1 == error_mark_node || e2 == error_mark_node)
 	  return error_mark_node;
 
-	return build_parse_node (ARRAY_REF, e1, e2, tsubst_expr);
+	return build_nt (ARRAY_REF, e1, e2, tsubst_expr);
       }
 
     case CALL_EXPR:
@@ -6831,7 +6831,7 @@ tsubst (t, args, complain, in_decl)
 	if (e1 == error_mark_node || e2 == error_mark_node)
 	  return error_mark_node;
 
-	return build_parse_node (TREE_CODE (t), e1, e2);
+	return build_nt (TREE_CODE (t), e1, e2);
       }
 
     case TYPEOF_TYPE:
diff -rupN gcc.orig/cp/semantics.c gcc/cp/semantics.c
--- gcc.orig/cp/semantics.c	Thu Jan 11 12:43:41 2001
+++ gcc/cp/semantics.c	Sun Jan 14 16:10:30 2001
@@ -1624,7 +1624,7 @@ begin_constructor_declarator (scope, nam
      tree scope;
      tree name;
 {
-  tree result = build_parse_node (SCOPE_REF, scope, name);
+  tree result = build_nt (SCOPE_REF, scope, name);
   enter_scope_of (result);
   return result;
 }
diff -rupN gcc.orig/objc/objc-act.c gcc/objc/objc-act.c
--- gcc.orig/objc/objc-act.c	Thu Jan 11 00:07:43 2001
+++ gcc/objc/objc-act.c	Sun Jan 14 16:12:08 2001
@@ -1855,12 +1855,12 @@ build_module_descriptor ()
     /* void _GLOBAL_$I$<gnyf> () {objc_execClass (&L_OBJC_MODULES);}  */
 
     start_function (void_list_node_1,
-		    build_parse_node (CALL_EXPR, init_function_name,
-				      /* This has the format of the output
-					 of get_parm_info.  */
-				      tree_cons (NULL_TREE, NULL_TREE,
-						 void_list_node_1),
-				      NULL_TREE),
+		    build_nt (CALL_EXPR, init_function_name,
+			      /* This has the format of the output
+				 of get_parm_info.  */
+			      tree_cons (NULL_TREE, NULL_TREE,
+					 void_list_node_1),
+			      NULL_TREE),
 		    NULL_TREE, NULL_TREE);
 #if 0 /* This should be turned back on later
 	 for the systems where collect is not needed.  */
diff -rupN gcc.orig/tree.c gcc/tree.c
--- gcc.orig/tree.c	Thu Jan  4 23:28:12 2001
+++ gcc/tree.c	Sun Jan 14 16:10:30 2001
@@ -2505,36 +2505,6 @@ build_nt VPARAMS ((enum tree_code code, 
   return t;
 }
 
-/* Similar to `build_nt', except we build
-   on the temp_decl_obstack, regardless.  */
-
-tree
-build_parse_node VPARAMS ((enum tree_code code, ...))
-{
-#ifndef ANSI_PROTOTYPES
-  enum tree_code code;
-#endif
-  va_list p;
-  register tree t;
-  register int length;
-  register int i;
-
-  VA_START (p, code);
-
-#ifndef ANSI_PROTOTYPES
-  code = va_arg (p, enum tree_code);
-#endif
-
-  t = make_node (code);
-  length = TREE_CODE_LENGTH (code);
-
-  for (i = 0; i < length; i++)
-    TREE_OPERAND (t, i) = va_arg (p, tree);
-
-  va_end (p);
-  return t;
-}
-
 #if 0
 /* Commented out because this wants to be done very
    differently.  See cp-lex.c.  */
diff -rupN gcc.orig/tree.h gcc/tree.h
--- gcc.orig/tree.h	Thu Jan 11 02:18:03 2001
+++ gcc/tree.h	Sun Jan 14 16:10:30 2001
@@ -1913,7 +1913,6 @@ extern tree maybe_get_identifier	PARAMS 
 
 extern tree build			PARAMS ((enum tree_code, tree, ...));
 extern tree build_nt			PARAMS ((enum tree_code, ...));
-extern tree build_parse_node		PARAMS ((enum tree_code, ...));
 
 extern tree build_int_2_wide		PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT));
 extern tree build_real			PARAMS ((tree, REAL_VALUE_TYPE));

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Gcc-patches mailing list