* utils2.c (build_allocator): Test for SIZE overflow in array case too
authorRichard Kenner <kenner@gnat.com>
Tue, 30 Oct 2001 21:27:26 +0000 (21:27 +0000)
committerGeert Bosch <bosch@gcc.gnu.org>
Tue, 30 Oct 2001 21:27:26 +0000 (22:27 +0100)
From-SVN: r46653

gcc/ada/ChangeLog
gcc/ada/utils2.c

index a075fd9289fb99d8fd967faf1b9b42fc9838d20a..ea236fc614594002f58230397472dbbc868a6ee6 100644 (file)
@@ -1,3 +1,7 @@
+2001-10-30  Richard Kenner <kenner@gnat.com>
+
+       * utils2.c (build_allocator): Test for SIZE overflow in array case too
+
 2001-10-30  Geert Bosch <bosch@gnat.com>
 
        * ali-util.adb (Initialize_Checksum): Use out-mode instead of in out. 
index 7cc8a3f669a4a570239e2ce8d784ac31be02f117..a5363a71af341aa6081c249f5179c0c0ef7b2a06 100644 (file)
@@ -1855,6 +1855,11 @@ build_allocator (type, init, result_type, gnat_proc, gnat_pool)
          && contains_placeholder_p (size))
        size = build (WITH_RECORD_EXPR, sizetype, size, init);
 
+      /* If the size overflows, pass -1 so the allocator will raise
+        storage error.  */
+      if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
+       size = ssize_int (-1);
+
       storage = build_call_alloc_dealloc (NULL_TREE, size,
                                          TYPE_ALIGN (storage_type),
                                          gnat_proc, gnat_pool);