From: Eric Botcazou Date: Wed, 3 Apr 2002 03:41:40 +0000 (+0000) Subject: function.c (assign_temp): Accept either type or decl argument. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9432c136e556d48adba14835a9588358013ace56;p=platform%2Fupstream%2Fgcc.git 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 From-SVN: r51788 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a115678..a8346bd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2002-04-02 Eric Botcazou + Richard Henderson + + 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 * protoize.c: Match include directory usage with cppdefault.c. diff --git a/gcc/function.c b/gcc/function.c index a17b249..5922712 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; } diff --git a/gcc/stmt.c b/gcc/stmt.c index 3f2d29c..9a72b87 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -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);