function.c (assign_temp): Accept either type or decl argument.
authorEric Botcazou <ebotcazou@multimania.com>
Wed, 3 Apr 2002 03:41:40 +0000 (03:41 +0000)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 3 Apr 2002 03:41:40 +0000 (19:41 -0800)
        * 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

gcc/ChangeLog
gcc/function.c
gcc/stmt.c

index a115678..a8346bd 100644 (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.
index a17b249..5922712 100644 (file)
@@ -845,7 +845,10 @@ assign_stack_temp (mode, size, keep)
   return assign_stack_temp_for_type (mode, size, keep, NULL_TREE);
 }
 \f
-/* 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;
     }
index 3f2d29c..9a72b87 100644 (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);