C++ PATCH: code clean up

Nathan Sidwell nathan@acm.org
Mon Oct 4 04:20:00 GMT 1999


Hi,
attached is a patch to clean up
1) grok_alignof. this erroneously asserts that things decay in comma
exprs. I remove that code. This does change the behaviour of __alignof__,
in these cases, but makes it consistent with non compound exprs and sizeof.
2) pending_sizes is an unused variable in build_new, and hence a test of it
will always fail. I remove the unreachable code.

You might notice both of these involve build_compound_expr. This is not a
coincidence.

ok?

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
        I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
1999-10-04  Nathan Sidwell  <nathan@acm.org>

	* decl2.c (grok_alignof): Don't decay lvalues.
	
	* init.c (build_new): Remove unused variable.

Index: cp/decl2.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/decl2.c,v
retrieving revision 1.270
diff -c -3 -p -r1.270 decl2.c
*** decl2.c	1999/09/30 06:15:53	1.270
--- decl2.c	1999/10/04 08:11:01
*************** grok_alignof (expr)
*** 1053,1069 ****
        return c_alignof (TREE_TYPE (TREE_TYPE (best)));
      }
    else
!     {
!       /* ANSI says arrays and fns are converted inside comma.
! 	 But we can't convert them in build_compound_expr
! 	 because that would break commas in lvalues.
! 	 So do the conversion here if operand was a comma.  */
!       if (TREE_CODE (expr) == COMPOUND_EXPR
! 	  && (TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
! 	      || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
! 	expr = default_conversion (expr);
!       return c_alignof (TREE_TYPE (expr));
!     }
  }
  
  /* Create an ARRAY_REF, checking for the user doing things backwards
--- 1053,1059 ----
        return c_alignof (TREE_TYPE (TREE_TYPE (best)));
      }
    else
!     return c_alignof (TREE_TYPE (expr));
  }
  
  /* Create an ARRAY_REF, checking for the user doing things backwards
Index: cp/init.c
===================================================================
RCS file: /cvs/egcs/egcs/gcc/cp/init.c,v
retrieving revision 1.140
diff -c -3 -p -r1.140 init.c
*** init.c	1999/09/26 18:16:47	1.140
--- init.c	1999/10/04 08:11:03
*************** build_new (placement, decl, init, use_gl
*** 1900,1907 ****
    tree nelts = NULL_TREE, t;
    int has_array = 0;
  
-   tree pending_sizes = NULL_TREE;
- 
    if (decl == error_mark_node)
      return error_mark_node;
  
--- 1900,1905 ----
*************** build_new (placement, decl, init, use_gl
*** 2059,2068 ****
    rval = build1 (NOP_EXPR, TREE_TYPE (rval), rval);
    TREE_NO_UNUSED_WARNING (rval) = 1;
  
-   if (pending_sizes)
-     rval = build_compound_expr (chainon (pending_sizes,
- 					 build_expr_list (NULL_TREE, rval)));
- 
    return rval;
  }
  
--- 2057,2062 ----


More information about the Gcc-patches mailing list