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]

Re: [PATCH] Fix PR 5484


On Wed, Apr 03, 2002 at 01:37:31AM +0200, Eric Botcazou wrote:
>     * function.c (assign_temp): Detect variables whose size is
>     too large to fit into an integer.

Looks good, except it's nice when the offending variable
is present in the error message.  Plus, I'm not sure if
this ought to happen in cases other than user silliness.

I'm going to apply this revision.


r~



Index: function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.352
diff -c -p -d -r1.352 function.c
*** function.c	2002/03/29 21:46:00	1.352
--- function.c	2002/04/03 03:32:14
*************** assign_stack_temp (mode, size, keep)
*** 845,851 ****
    return assign_stack_temp_for_type (mode, size, keep, NULL_TREE);
  }
  
! /* Assign a temporary of given TYPE.
     KEEP is as for assign_stack_temp.
     MEMORY_REQUIRED is 1 if the result must be addressable stack memory;
     it is 0 if a register is OK.
--- 845,854 ----
    return assign_stack_temp_for_type (mode, size, keep, NULL_TREE);
  }
  
! /* Assign a temporary.
!    If TYPE_OR_DECL is a decl, then we are doing it on behalf of the decl
!    and so that should be used in error messages.  In either case, we
!    allocate of the given type.
     KEEP is as for assign_stack_temp.
     MEMORY_REQUIRED is 1 if the result must be addressable stack memory;
     it is 0 if a register is OK.
*************** assign_stack_temp (mode, size, keep)
*** 853,869 ****
     to wider modes.  */
  
  rtx
! assign_temp (type, keep, memory_required, dont_promote)
!      tree type;
       int keep;
       int memory_required;
       int dont_promote ATTRIBUTE_UNUSED;
  {
!   enum machine_mode mode = TYPE_MODE (type);
  #ifndef PROMOTE_FOR_CALL_ONLY
!   int unsignedp = TREE_UNSIGNED (type);
  #endif
  
    if (mode == BLKmode || memory_required)
      {
        HOST_WIDE_INT size = int_size_in_bytes (type);
--- 856,883 ----
     to wider modes.  */
  
  rtx
! assign_temp (type_or_decl, keep, memory_required, dont_promote)
!      tree type_or_decl;
       int keep;
       int memory_required;
       int dont_promote ATTRIBUTE_UNUSED;
  {
!   tree type, decl;
!   enum machine_mode mode;
  #ifndef PROMOTE_FOR_CALL_ONLY
!   int unsignedp;
  #endif
  
+   if (DECL_P (type_or_decl))
+     decl = type_or_decl, type = TREE_TYPE (decl);
+   else
+     decl = NULL, type = type_or_decl;
+ 
+   mode = TYPE_MODE (type);
+ #ifndef PROMOTE_FOR_CALL_ONLY
+   unsignedp = TREE_UNSIGNED (type);
+ #endif
+ 
    if (mode == BLKmode || memory_required)
      {
        HOST_WIDE_INT size = int_size_in_bytes (type);
*************** assign_temp (type, keep, memory_required
*** 882,887 ****
--- 896,912 ----
  	  && TYPE_ARRAY_MAX_SIZE (type) != NULL_TREE
  	  && host_integerp (TYPE_ARRAY_MAX_SIZE (type), 1))
  	size = tree_low_cst (TYPE_ARRAY_MAX_SIZE (type), 1);
+ 
+       /* The size of the temporary may be too large to fit into an integer.  */
+       /* ??? Not sure this should happen except for user silliness, so limit
+ 	 this to things that aren't compiler-generated temporaries.  The 
+ 	 rest of the time we'll abort in assign_stack_temp_for_type.  */
+       if (decl && size == -1
+ 	  && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST)
+ 	{
+ 	  error_with_decl (decl, "size of variable `%s' is too large");
+ 	  size = 1;
+ 	}
  
        tmp = assign_stack_temp_for_type (mode, size, keep, type);
        return tmp;
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.255
diff -c -p -d -r1.255 stmt.c
*** stmt.c	2002/04/01 20:25:58	1.255
--- stmt.c	2002/04/03 03:32:15
*************** expand_decl (decl)
*** 3969,3975 ****
  			   : GET_MODE_BITSIZE (DECL_MODE (decl)));
        DECL_USER_ALIGN (decl) = 0;
  
!       x = assign_temp (TREE_TYPE (decl), 1, 1, 1);
        set_mem_attributes (x, decl, 1);
        SET_DECL_RTL (decl, x);
  
--- 3969,3975 ----
  			   : GET_MODE_BITSIZE (DECL_MODE (decl)));
        DECL_USER_ALIGN (decl) = 0;
  
!       x = assign_temp (decl, 1, 1, 1);
        set_mem_attributes (x, decl, 1);
        SET_DECL_RTL (decl, x);
  


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