function.c (assign_temp): Accept either type or decl argument.

* function.c (assign_temp): Accept either type or decl argument.
        Detect variables whose size is too large to fit into an integer.
        * stmt.c (expand_decl): Pass the decl, not the type.

Co-Authored-By: Richard Henderson <rth@redhat.com>

From-SVN: r51788
This commit is contained in:
Eric Botcazou 2002-04-03 03:41:40 +00:00 committed by Richard Henderson
parent 058b12757e
commit 9432c136e5
3 changed files with 39 additions and 6 deletions

View File

@ -1,3 +1,11 @@
2002-04-02 Eric Botcazou <ebotcazou@multimania.com>
Richard Henderson <rth@redhat.com>
PR c/5484
* function.c (assign_temp): Accept either type or decl argument.
Detect variables whose size is too large to fit into an integer.
* stmt.c (expand_decl): Pass the decl, not the type.
2002-04-02 David O'Brien <obrien@FreeBSD.org>
* protoize.c: Match include directory usage with cppdefault.c.

View File

@ -845,7 +845,10 @@ assign_stack_temp (mode, size, keep)
return assign_stack_temp_for_type (mode, size, keep, NULL_TREE);
}
/* Assign a temporary of given TYPE.
/* 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.
@ -853,15 +856,26 @@ assign_stack_temp (mode, size, keep)
to wider modes. */
rtx
assign_temp (type, keep, memory_required, dont_promote)
tree type;
assign_temp (type_or_decl, keep, memory_required, dont_promote)
tree type_or_decl;
int keep;
int memory_required;
int dont_promote ATTRIBUTE_UNUSED;
{
enum machine_mode mode = TYPE_MODE (type);
tree type, decl;
enum machine_mode mode;
#ifndef PROMOTE_FOR_CALL_ONLY
int unsignedp = TREE_UNSIGNED (type);
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)
@ -883,6 +897,17 @@ assign_temp (type, keep, memory_required, dont_promote)
&& 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;
}

View File

@ -3969,7 +3969,7 @@ expand_decl (decl)
: GET_MODE_BITSIZE (DECL_MODE (decl)));
DECL_USER_ALIGN (decl) = 0;
x = assign_temp (TREE_TYPE (decl), 1, 1, 1);
x = assign_temp (decl, 1, 1, 1);
set_mem_attributes (x, decl, 1);
SET_DECL_RTL (decl, x);