patch applied to expr.c / cp/typeck2.c

Joern Rennecke amylaar@cygnus.co.uk
Wed Oct 13 19:51:00 GMT 1999


Reviewed by Jim Wilson / Jason Merrill.
A new test has been added in testsuite/g++.old-deja/g++.other/union2.C .

gcc toplevel:
Wed Oct 13 22:01:35 1999  J"orn Rennecke <amylaar@cygnus.co.uk>

	* expr.c (store_constructor): Clear union if constructor is empty.

cp:
Wed Oct 13 22:01:35 1999  J"orn Rennecke <amylaar@cygnus.co.uk>

	* typeck2.c (process_init_constructor): Handle empty constructors.

Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.175
retrieving revision 1.176
diff -p -r1.175 -r1.176
*** expr.c	1999/10/08 00:10:08	1.175
--- expr.c	1999/10/14 02:18:09	1.176
*************** store_constructor (exp, target, align, c
*** 4073,4079 ****
        /* Inform later passes that the whole union value is dead.  */
        if (TREE_CODE (type) == UNION_TYPE
  	  || TREE_CODE (type) == QUAL_UNION_TYPE)
! 	emit_insn (gen_rtx_CLOBBER (VOIDmode, target));
  
        /* If we are building a static constructor into a register,
  	 set the initial value as zero so we can fold the value into
--- 4073,4086 ----
        /* Inform later passes that the whole union value is dead.  */
        if (TREE_CODE (type) == UNION_TYPE
  	  || TREE_CODE (type) == QUAL_UNION_TYPE)
! 	{
! 	  emit_insn (gen_rtx_CLOBBER (VOIDmode, target));
! 
! 	  /* If the constructor is empty, clear the union.  */
! 	  if (! CONSTRUCTOR_ELTS (exp)  && ! cleared)
! 	    clear_storage (target, expr_size (exp),
! 			   TYPE_ALIGN (type) / BITS_PER_UNIT);
! 	}
  
        /* If we are building a static constructor into a register,
  	 set the initial value as zero so we can fold the value into
Index: cp/typeck2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/typeck2.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -p -r1.66 -r1.67
*** typeck2.c	1999/09/15 14:04:10	1.66
--- typeck2.c	1999/10/14 02:18:10	1.67
*************** process_init_constructor (type, init, el
*** 921,927 ****
  	  members = expr_tree_cons (field, next1, members);
  	}
      }
!   else if (TREE_CODE (type) == UNION_TYPE)
      {
        register tree field = TYPE_FIELDS (type);
  
--- 921,929 ----
  	  members = expr_tree_cons (field, next1, members);
  	}
      }
!   else if (TREE_CODE (type) == UNION_TYPE
! 	   /* If the initializer was empty, use default zero initialization.  */
! 	   && tail)
      {
        register tree field = TYPE_FIELDS (type);
  


More information about the Gcc-patches mailing list