diff options
author | Harald Anlauf <anlauf@gmx.de> | 2022-05-28 22:02:20 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2022-05-30 22:31:34 +0200 |
commit | 871dbb6112e22ff92914613c332944fd19dd39a8 (patch) | |
tree | a7e1aefb4901b2e443d8858908331132950b0883 /gcc/fortran/trans.cc | |
parent | f1652e3343b1ec47035370801d9b9aca1f8b613f (diff) | |
download | gcc-871dbb6112e22ff92914613c332944fd19dd39a8.zip gcc-871dbb6112e22ff92914613c332944fd19dd39a8.tar.gz gcc-871dbb6112e22ff92914613c332944fd19dd39a8.tar.bz2 |
Fortran: improve runtime error message with ALLOCATE and ERRMSG= [PR91300]
ALLOCATE: generate different STAT,ERRMSG results for failures from
allocation of already allocated objects or insufficient virtual memory.
gcc/fortran/ChangeLog:
PR fortran/91300
* libgfortran.h: Define new error code LIBERROR_NO_MEMORY.
* trans-stmt.cc (gfc_trans_allocate): Generate code for setting
ERRMSG depending on result of STAT result of ALLOCATE.
* trans.cc (gfc_allocate_using_malloc): Use STAT value of
LIBERROR_NO_MEMORY in case of failed malloc.
gcc/testsuite/ChangeLog:
PR fortran/91300
* gfortran.dg/allocate_alloc_opt_15.f90: New test.
Diffstat (limited to 'gcc/fortran/trans.cc')
-rw-r--r-- | gcc/fortran/trans.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc index f0a5dfb..912a206 100644 --- a/gcc/fortran/trans.cc +++ b/gcc/fortran/trans.cc @@ -772,7 +772,7 @@ gfc_call_malloc (stmtblock_t * block, tree type, tree size) if (newmem == NULL) { if (stat) - *stat = LIBERROR_ALLOCATION; + *stat = LIBERROR_NO_MEMORY; else runtime_error ("Allocation would exceed memory limit"); } @@ -807,7 +807,7 @@ gfc_allocate_using_malloc (stmtblock_t * block, tree pointer, if (status != NULL_TREE) { tmp = fold_build2_loc (input_location, MODIFY_EXPR, status_type, status, - build_int_cst (status_type, LIBERROR_ALLOCATION)); + build_int_cst (status_type, LIBERROR_NO_MEMORY)); gfc_add_expr_to_block (&on_error, tmp); } else |