[fortran, 4.5] Implement errmsg for [de]allocate

Tobias Burnus burnus@net-b.de
Wed Dec 3 19:29:00 GMT 2008


Hi Steve,

Steve Kargl wrote:
> The attached patch implements the F2003 feature of ERRMSG= in
> the [DE]ALLOCATE statements.  The current patch makes use of
> the infrastructure for STAT= to determine if a failure occurs.
>   
Somehow it does not work if one additionally requests a STAT= variable:

  deallocate(x, stat=i, errmsg=err)
                     1
Error: Syntax error in DEALLOCATE statement at (1)

(Ditto for: errmsg=..., stat=...)


Additionally: Can we add a -Wsurprising which checks for the presence of
STAT= when ERRMSG= is given? NAG f95 prints:

Warning: hfjgf.f90, line 6: ERRMSG= is useless without STAT=


>   deallocate(x, x, errmsg=err)
>   print *, err
There are several issues:
a) "deallocate(x, x)" is invalid, which can be compile-time diagnosable
(as e.g. ifort does), better place it in two lines
b) "print *, err" is invalid - it always prints uninitialized value (in
case of success). In case of a failure, it does not print anything as
DEALLOCATE aborts

"If an error condition occurs during execution of an ALLOCATE statement
that does not contain the STAT= specifier, execution of the program is
terminated."


I will review the patch itself later.

Tobias



More information about the Gcc-patches mailing list