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]

Properly convert nest of references in tree-nested.c


If we don't use handled_components_p, we will get confused with a
conversion in the middle of a reference nest.

Also, allow new variable to be of ARRAY_TYPE like gimplify.c.

This fixes a problem compiling a file from the Ada front end.  I think
it was sem_elim.adb, but don't hold me to it.

Tested on x86-64-linux-gnu.

2004-06-28  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* tree-nested.c (create_tmp_var_for): Allow ARRAY_TYPE.
	(convert_nonlocal_reference, convert_local_reference): Properly
	convert nest of handled component references.

*** tree-nested.c	25 Jun 2004 20:33:09 -0000	2.6
--- tree-nested.c	28 Jun 2004 11:47:32 -0000
*************** create_tmp_var_for (struct nesting_info 
*** 134,144 ****
  
  #if defined ENABLE_CHECKING
!   /* If the type is an array or a type which must be created by the
       frontend, something is wrong.  Note that we explicitly allow
       incomplete types here, since we create them ourselves here.  */
!   if (TREE_CODE (type) == ARRAY_TYPE || TREE_ADDRESSABLE (type))
!     abort ();
!   if (TYPE_SIZE_UNIT (type)
!       && TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST)
      abort ();
  #endif
--- 134,143 ----
  
  #if defined ENABLE_CHECKING
!   /* If the type is of variable size or a type which must be created by the
       frontend, something is wrong.  Note that we explicitly allow
       incomplete types here, since we create them ourselves here.  */
!   if (TREE_ADDRESSABLE (type)
!       || (TYPE_SIZE_UNIT (type)
! 	  && TREE_CODE (TYPE_SIZE_UNIT (type)) != INTEGER_CST))
      abort ();
  #endif
*************** convert_nonlocal_reference (tree *tp, in
*** 798,829 ****
      case REALPART_EXPR:
      case IMAGPART_EXPR:
-       wi->val_only = false;
-       walk_tree (&TREE_OPERAND (t, 0), convert_nonlocal_reference, wi, NULL);
-       wi->val_only = true;
-       break;
- 
      case COMPONENT_REF:
-       wi->val_only = false;
-       walk_tree (&TREE_OPERAND (t, 0), convert_nonlocal_reference, wi, NULL);
-       wi->val_only = true;
-       walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi, NULL);
-       break;
- 
      case ARRAY_REF:
      case ARRAY_RANGE_REF:
-       wi->val_only = false;
-       walk_tree (&TREE_OPERAND (t, 0), convert_nonlocal_reference, wi, NULL);
-       wi->val_only = true;
-       walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference, wi, NULL);
-       walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi, NULL);
-       walk_tree (&TREE_OPERAND (t, 3), convert_nonlocal_reference, wi, NULL);
-       break;
- 
      case BIT_FIELD_REF:
!       wi->val_only = false;
!       walk_tree (&TREE_OPERAND (t, 0), convert_nonlocal_reference, wi, NULL);
        wi->val_only = true;
!       walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference, wi, NULL);
!       walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi, NULL);
        break;
  
--- 797,835 ----
      case REALPART_EXPR:
      case IMAGPART_EXPR:
      case COMPONENT_REF:
      case ARRAY_REF:
      case ARRAY_RANGE_REF:
      case BIT_FIELD_REF:
!       /* Go down this entire nest and just look at the final prefix and
! 	 anything that describes the references.  Otherwise, we lose track
! 	 of whether a NOP_EXPR or VIEW_CONVERT_EXPR needs a simple value.  */
        wi->val_only = true;
!       for (; handled_component_p (t)
! 	   || TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR;
! 	   tp = &TREE_OPERAND (t, 0), t = *tp)
! 	{
! 	  if (TREE_CODE (t) == COMPONENT_REF)
! 	    walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi,
! 		       NULL);
! 	  else if (TREE_CODE (t) == ARRAY_REF
! 		   || TREE_CODE (t) == ARRAY_RANGE_REF)
! 	    {
! 	      walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference, wi,
! 			 NULL);
! 	      walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi,
! 			 NULL);
! 	      walk_tree (&TREE_OPERAND (t, 3), convert_nonlocal_reference, wi,
! 			 NULL);
! 	    }
! 	  else if (TREE_CODE (t) == BIT_FIELD_REF)
! 	    {
! 	      walk_tree (&TREE_OPERAND (t, 1), convert_nonlocal_reference, wi,
! 			 NULL);
! 	      walk_tree (&TREE_OPERAND (t, 2), convert_nonlocal_reference, wi,
! 			 NULL);
! 	    }
! 	}
!       wi->val_only = false;
!       walk_tree (tp, convert_nonlocal_reference, wi, NULL);
        break;
  
*************** convert_local_reference (tree *tp, int *
*** 939,970 ****
      case REALPART_EXPR:
      case IMAGPART_EXPR:
-       wi->val_only = false;
-       walk_tree (&TREE_OPERAND (t, 0), convert_local_reference, wi, NULL);
-       wi->val_only = true;
-       break;
- 
      case COMPONENT_REF:
-       wi->val_only = false;
-       walk_tree (&TREE_OPERAND (t, 0), convert_local_reference, wi, NULL);
-       wi->val_only = true;
-       walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi, NULL);
-       break;
- 
      case ARRAY_REF:
      case ARRAY_RANGE_REF:
-       wi->val_only = false;
-       walk_tree (&TREE_OPERAND (t, 0), convert_local_reference, wi, NULL);
-       wi->val_only = true;
-       walk_tree (&TREE_OPERAND (t, 1), convert_local_reference, wi, NULL);
-       walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi, NULL);
-       walk_tree (&TREE_OPERAND (t, 3), convert_local_reference, wi, NULL);
-       break;
- 
      case BIT_FIELD_REF:
!       wi->val_only = false;
!       walk_tree (&TREE_OPERAND (t, 0), convert_local_reference, wi, NULL);
        wi->val_only = true;
!       walk_tree (&TREE_OPERAND (t, 1), convert_local_reference, wi, NULL);
!       walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi, NULL);
        break;
  
--- 945,983 ----
      case REALPART_EXPR:
      case IMAGPART_EXPR:
      case COMPONENT_REF:
      case ARRAY_REF:
      case ARRAY_RANGE_REF:
      case BIT_FIELD_REF:
!       /* Go down this entire nest and just look at the final prefix and
! 	 anything that describes the references.  Otherwise, we lose track
! 	 of whether a NOP_EXPR or VIEW_CONVERT_EXPR needs a simple value.  */
        wi->val_only = true;
!       for (; handled_component_p (t)
! 	   || TREE_CODE (t) == REALPART_EXPR || TREE_CODE (t) == IMAGPART_EXPR;
! 	   tp = &TREE_OPERAND (t, 0), t = *tp)
! 	{
! 	  if (TREE_CODE (t) == COMPONENT_REF)
! 	    walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi,
! 		       NULL);
! 	  else if (TREE_CODE (t) == ARRAY_REF
! 		   || TREE_CODE (t) == ARRAY_RANGE_REF)
! 	    {
! 	      walk_tree (&TREE_OPERAND (t, 1), convert_local_reference, wi,
! 			 NULL);
! 	      walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi,
! 			 NULL);
! 	      walk_tree (&TREE_OPERAND (t, 3), convert_local_reference, wi,
! 			 NULL);
! 	    }
! 	  else if (TREE_CODE (t) == BIT_FIELD_REF)
! 	    {
! 	      walk_tree (&TREE_OPERAND (t, 1), convert_local_reference, wi,
! 			 NULL);
! 	      walk_tree (&TREE_OPERAND (t, 2), convert_local_reference, wi,
! 			 NULL);
! 	    }
! 	}
!       wi->val_only = false;
!       walk_tree (tp, convert_local_reference, wi, NULL);
        break;
  


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