summaryrefslogtreecommitdiff
path: root/gcc/function.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-03 03:41:40 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-04-03 03:41:40 +0000
commit567c22a9b9994351bdcc68d2745627e795b618cf (patch)
tree844e400ff563761e03467d66dbae67488978921a /gcc/function.c
parentffbee6f84ed75606a0d335971539301e0f128c86 (diff)
downloadgcc-567c22a9b9994351bdcc68d2745627e795b618cf.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51788 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/function.c')
-rw-r--r--gcc/function.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/gcc/function.c b/gcc/function.c
index a17b249661f..5922712b8ed 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -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;
}