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]

Re: [patch] delete old dead code


On Mon, May 28, 2001 at 05:37:37PM +0100, Joseph S. Myers wrote:
> On Mon, 28 May 2001, Sam TH wrote:
> 
> > The attached patch deletes #if 0 blocks that have existed since the
> > beginning of egcs.  From the comments, some have existed much longer
> > than that - one references gcc 2.4 in the future, and two are from
> > 1994.  
> 
> In some cases, the comments inside the #if 0 block explain why you don't
> want to do what the block does.  Since the blocks can serve as
> documentation, but comments are better, most blocks should be replaced by
> comments (possibly the ones currently there, possibly modified versions)  
> explaining why you don't want to do what's in the block, to avoid someone
> making the mistake of adding essentially what's in the block back again.

Should we include the code as an example in the comments - don't do this?

> Here are comments on a few of the #if 0 blocks.  (Could you use the "-p" 
> option to diff to make it clearer where the code is coming from?)  

Learn something new every day.

> Everywhere in the C front end I haven't commented on may need further 
> consideration and possibly an appropriate comment, or you could send a 
> patch for just those cases in the C front end where I made an unequivocal 
> comment on what was required, so I can approve those first.
> 

Attached it a patch dealing with the stuff you were clear on.

> At what point do simple changes such as code removal require a copyright 
> assignment?

Well, the FSF policy on their website clearly allows copyright
renuciation as an alternative to assignment.  And I renounce copyright
on these changes.  But I would like an assignment form.

> old-releases/old-cvs on GCC mirrors.

I tried this, but I couldn't get the cvs server to log me in to any
combination I tried, nor is old-releases or old-cvs a module in the
/cvs/gcc repository.  What's the full path you have to use?

> > -#if 0
> > -      /* If this function takes a variable number of arguments,
> > -	 add a phony parameter to the end of the parm list,
> > -	 to represent the position of the first unnamed argument.  */
> 
> While I think this can be removed outright, I'd rather understand what it 
> was ever getting at first.

Well, it seems to be doing exactly what the comment says it's doing.

The oldest ChangeLog entry for that function (which is very close to
the same function that began egcs) is from 1998, so I have no idea why
that code was taken out.

> 
> > -
> > -  /* ??? This might be an improvement,
> > -     but needs to be thought about some more.  */
> > -#if 0
> > -  keep_next_level_flag = 1;
> > -#endif
> 
> What is this getting at?

I haven't the faintest idea. 
           
sam th --- sam@uchicago.edu --- http://www.abisource.com/~sam/
OpenPGP Key: CABD33FC --- http://samth.dyndns.org/key
DeCSS: http://samth.dyndns.org/decss

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.236
diff -u -p -r1.236 c-common.c
--- c-common.c	2001/05/25 20:00:54	1.236
+++ c-common.c	2001/05/29 01:01:00
@@ -2535,28 +2535,6 @@ truthvalue_conversion (expr)
   if (TREE_CODE (expr) == ERROR_MARK)
     return expr;
 
-#if 0 /* This appears to be wrong for C++.  */
-  /* These really should return error_mark_node after 2.4 is stable.
-     But not all callers handle ERROR_MARK properly.  */
-  switch (TREE_CODE (TREE_TYPE (expr)))
-    {
-    case RECORD_TYPE:
-      error ("struct type value used where scalar is required");
-      return boolean_false_node;
-
-    case UNION_TYPE:
-      error ("union type value used where scalar is required");
-      return boolean_false_node;
-
-    case ARRAY_TYPE:
-      error ("array type value used where scalar is required");
-      return boolean_false_node;
-
-    default:
-      break;
-    }
-#endif /* 0 */
-
   switch (TREE_CODE (expr))
     {
     case EQ_EXPR:
Index: c-convert.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-convert.c,v
retrieving revision 1.11
diff -u -p -r1.11 c-convert.c
--- c-convert.c	2001/04/23 22:55:31	1.11
+++ c-convert.c	2001/05/29 01:01:00
@@ -80,12 +80,9 @@ convert (type, expr)
     }
   if (code == VOID_TYPE)
     return build1 (CONVERT_EXPR, type, e);
-#if 0
-  /* This is incorrect.  A truncation can't be stripped this way.
-     Extensions will be stripped by the use of get_unwidened.  */
-  if (TREE_CODE (expr) == NOP_EXPR)
-    return convert (type, TREE_OPERAND (expr, 0));
-#endif
+  /* We don't handle the case of NOP_EXPR.  A truncation can't be
+     stripped this way.  Extensions will be stripped by the use of
+     get_unwidened.  */
   if (code == INTEGER_TYPE || code == ENUMERAL_TYPE)
     return fold (convert_to_integer (type, e));
   if (code == BOOLEAN_TYPE)
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.224
diff -u -p -r1.224 c-decl.c
--- c-decl.c	2001/05/27 21:04:27	1.224
+++ c-decl.c	2001/05/29 01:01:01
@@ -1004,33 +1004,10 @@ poplevel (keep, reverse, functionbody)
 
   keep |= current_binding_level->keep;
 
-  /* This warning is turned off because it causes warnings for
-     declarations like `extern struct foo *x'.  */
-#if 0
-  /* Warn about incomplete structure types in this level.  */
-  for (link = tags; link; link = TREE_CHAIN (link))
-    if (!COMPLETE_TYPE_P (TREE_VALUE (link)))
-      {
-	tree type = TREE_VALUE (link);
-	tree type_name = TYPE_NAME (type);
-	char *id = IDENTIFIER_POINTER (TREE_CODE (type_name) == IDENTIFIER_NODE
-				       ? type_name
-				       : DECL_NAME (type_name));
-	switch (TREE_CODE (type))
-	  {
-	  case RECORD_TYPE:
-	    error ("`struct %s' incomplete in scope ending here", id);
-	    break;
-	  case UNION_TYPE:
-	    error ("`union %s' incomplete in scope ending here", id);
-	    break;
-	  case ENUMERAL_TYPE:
-	    error ("`enum %s' incomplete in scope ending here", id);
-	    break;
-	  }
-      }
-#endif /* 0 */
-
+  /* We would like to warn about incomplete structure types here, but
+     unfortunately that causes warnings for declarations like `extern
+     struct foo *x'.  */
+  
   /* Get the decls in the order they were written.
      Usually current_binding_level->names is in reverse order.
      But parameter decls were previously put in forward order.  */
@@ -3725,17 +3702,6 @@ push_parm_decl (parm)
   decl_attributes (decl, TREE_VALUE (TREE_VALUE (parm)),
 		   TREE_PURPOSE (TREE_VALUE (parm)));
 
-#if 0
-  if (DECL_NAME (decl))
-    {
-      tree olddecl;
-      olddecl = lookup_name (DECL_NAME (decl));
-      if (pedantic && olddecl != 0 && TREE_CODE (olddecl) == TYPE_DECL)
-	pedwarn_with_decl (decl,
-			   "ANSI C forbids parameter `%s' shadowing typedef");
-    }
-#endif
-
   decl = pushdecl (decl);
 
   immediate_size_expand = old_immediate_size_expand;
@@ -4832,11 +4798,10 @@ grokdeclarator (declarator, declspecs, d
 	    type = build_array_type (c_build_qualified_type (TREE_TYPE (type),
 							     type_quals),
 				     TYPE_DOMAIN (type));
-#if 0
-	    /* Leave the field const or volatile as well.  */
-	    type_quals = TYPE_UNQUALIFIED;
-#endif
 	  }
+
+	/* Do not change the const-ness or volatile-ness of the field.  */
+	
 	decl = build_decl (FIELD_DECL, declarator, type);
 	DECL_NONADDRESSABLE_P (decl) = bitfield;
 
@@ -5013,10 +4978,6 @@ grokparms (parms_info, funcdef_flag)
 	 These tags can never be defined in the scope of the declaration,
 	 so the types can never be completed,
 	 and no call can be compiled successfully.  */
-#if 0
-      /* In a fcn definition, arg types must be complete.  */
-      if (funcdef_flag)
-#endif
 	for (parm = last_function_parms, typelt = first_parm;
 	     parm;
 	     parm = TREE_CHAIN (parm))
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.141
diff -u -p -r1.141 c-lex.c
--- c-lex.c	2001/05/23 19:05:37	1.141
+++ c-lex.c	2001/05/29 01:01:01
@@ -654,26 +654,6 @@ utf8_extend_token (c)
   while (shift);
 }
 #endif
-
-#if 0
-struct try_type
-{
-  tree *node_var;
-  char unsigned_flag;
-  char long_flag;
-  char long_long_flag;
-};
-
-struct try_type type_sequence[] =
-{
-  { &integer_type_node, 0, 0, 0},
-  { &unsigned_type_node, 1, 0, 0},
-  { &long_integer_type_node, 0, 1, 0},
-  { &long_unsigned_type_node, 1, 1, 0},
-  { &long_long_integer_type_node, 0, 1, 1},
-  { &long_long_unsigned_type_node, 1, 1, 1}
-};
-#endif /* 0 */
 
 struct pf_args
 {
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.121
diff -u -p -r1.121 c-typeck.c
--- c-typeck.c	2001/05/25 06:34:16	1.121
+++ c-typeck.c	2001/05/29 01:01:06
-#if 0 /* Produces wrong result if within sizeof.  */
-  /* Don't promote the operands separately if they promote
-     the same way.  Return the unpromoted type and let the combined
-     value get promoted if necessary.  */
-
-  if (TREE_TYPE (op1) == TREE_TYPE (op2)
-      && TREE_CODE (TREE_TYPE (op1)) != ARRAY_TYPE
-      && TREE_CODE (TREE_TYPE (op1)) != ENUMERAL_TYPE
-      && TREE_CODE (TREE_TYPE (op1)) != FUNCTION_TYPE)
-    {
-      if (TREE_CODE (ifexp) == INTEGER_CST)
-	return pedantic_non_lvalue (integer_zerop (ifexp) ? op2 : op1);
-
-      return fold (build (COND_EXPR, TREE_TYPE (op1), ifexp, op1, op2));
-    }
-#endif
-
   /* Promote both alternatives.  */
 
   if (TREE_CODE (TREE_TYPE (op1)) != VOID_TYPE)
@@ -3646,16 +3570,11 @@ internal_build_compound_expr (list, firs
     {
       /* Convert arrays to pointers when there really is a comma operator.  */
       if (!first_p && TREE_CODE (TREE_TYPE (TREE_VALUE (list))) == ARRAY_TYPE)
-	TREE_VALUE (list) = default_conversion (TREE_VALUE (list));
+		TREE_VALUE (list) = default_conversion (TREE_VALUE (list));
 
-#if 0 /* If something inside inhibited lvalueness, we should not override.  */
+	  /* If something inside inhibited lvalueness, we should not override.  */
       /* Consider (x, y+0), which is not an lvalue since y+0 is not.  */
 
-      /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
-      if (TREE_CODE (list) == NON_LVALUE_EXPR)
-	list = TREE_OPERAND (list, 0);
-#endif
-
       /* Don't let (0, 0) be null pointer constant.  */
       if (!first_p && integer_zerop (TREE_VALUE (list)))
 	return non_lvalue (TREE_VALUE (list));

PGP signature


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