re PR fortran/32124 (Execution stops with stat= in ALLOCATE)
authorTobias Burnus <burnus@net-b.de>
Mon, 28 May 2007 16:39:35 +0000 (18:39 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Mon, 28 May 2007 16:39:35 +0000 (18:39 +0200)
2007-05-28  Tobias Burnus  <burnus@net-b.de>

PR fortran/32124
* runtime/memory.c (allocate_size): Use ERROR_ALLOCATION.
(allocate,allocate64): Use stat variable if present.

From-SVN: r125133

libgfortran/ChangeLog
libgfortran/runtime/memory.c

index 246eee50289f4b14a77dccc95a3aed06f5bcd83d..f0b012b38fbd3ce558e04f3f618f5095b89580cf 100644 (file)
@@ -1,3 +1,9 @@
+2007-05-28  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/32124
+       * runtime/memory.c (allocate_size): Use ERROR_ALLOCATION.
+       (allocate,allocate64): Use stat variable if present.
+
 2007-05-27  Janne Blomqvist  <jb@gcc.gnu.org>
 
        * runtime/string.c (compare0): Use gfc_charlen_type instead of
index fe76675c9ad0f9f038e5d402135eddb13ab5b32e..53643dc7ec6fdec576ef63850b3cd9a8dfe597a7 100644 (file)
@@ -144,7 +144,7 @@ allocate_size (size_t size, GFC_INTEGER_4 * stat)
     {
       if (stat)
        {
-         *stat = 1;
+         *stat = ERROR_ALLOCATION;
          return newmem;
        }
       else
@@ -164,8 +164,16 @@ void *
 allocate (GFC_INTEGER_4 size, GFC_INTEGER_4 * stat)
 {
   if (size < 0)
-    runtime_error ("Attempt to allocate negative amount of memory.  "
-                  "Possible integer overflow");
+    {
+      if (stat)
+       {
+         *stat = ERROR_ALLOCATION;
+         return NULL;
+       }
+      else
+       runtime_error ("Attempt to allocate negative amount of memory. "
+                      "Possible integer overflow");
+    }
 
   return allocate_size ((size_t) size, stat);
 }
@@ -177,8 +185,16 @@ void *
 allocate64 (GFC_INTEGER_8 size, GFC_INTEGER_4 * stat)
 {
   if (size < 0)
-    runtime_error ("ALLOCATE64: Attempt to allocate negative amount of "
-                  "memory. Possible integer overflow");
+    {
+      if (stat)
+       {
+         *stat = ERROR_ALLOCATION;
+         return NULL;
+       }
+      else
+       runtime_error ("ALLOCATE64: Attempt to allocate negative amount of "
+                      "memory. Possible integer overflow");
+    }
 
   return allocate_size ((size_t) size, stat);
 }