This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] PR32124 - Don't give a run-time error if stat= has been specified for ALLOCATE
- From: Tobias Burnus <burnus at net-b dot de>
- To: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 28 May 2007 15:11:38 +0200
- Subject: [patch, fortran] PR32124 - Don't give a run-time error if stat= has been specified for ALLOCATE
:ADDPATCH fortran:
As just reported by Salvertore.
Build and regtested on Linux x86-64.
Ok for the trunk? (Should this be backported to 4.2.1? This is no
regression.)
Tobias
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.
Index: libgfortran/runtime/memory.c
===================================================================
--- libgfortran/runtime/memory.c (Revision 125128)
+++ libgfortran/runtime/memory.c (Arbeitskopie)
@@ -144,7 +144,7 @@ allocate_size (size_t size, GFC_INTEGER_
{
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);
}