diff options
author | Steve Kargl <kargls@comcast.net> | 2024-08-01 21:50:49 -0700 |
---|---|---|
committer | Jerry DeLisle <jvdelisle@gcc.gnu.org> | 2024-08-02 17:09:21 -0700 |
commit | a53c029bf855fd4250076a07d0d8150b9c39bc91 (patch) | |
tree | b3b671a7e60be686615faa204126ed643bcb1585 | |
parent | 5a7fd37d28c55f1f52612e57de250c4da168f982 (diff) | |
download | gcc-a53c029bf855fd4250076a07d0d8150b9c39bc91.zip gcc-a53c029bf855fd4250076a07d0d8150b9c39bc91.tar.gz gcc-a53c029bf855fd4250076a07d0d8150b9c39bc91.tar.bz2 |
Fortran: Fix ICE on invalid in gfc_format_decoder.
PR fortran/104626
gcc/fortran/ChangeLog:
* symbol.cc (gfc_add_save): Add checks for SAVE attribute
conflicts and duplicate SAVE attribute.
gcc/testsuite/ChangeLog:
* gfortran.dg/pr104626.f90: New test.
-rw-r--r-- | gcc/fortran/symbol.cc | 16 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/pr104626.f90 | 8 |
2 files changed, 18 insertions, 6 deletions
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc index a8479b8..b5143d9 100644 --- a/gcc/fortran/symbol.cc +++ b/gcc/fortran/symbol.cc @@ -1307,9 +1307,8 @@ gfc_add_save (symbol_attribute *attr, save_state s, const char *name, if (s == SAVE_EXPLICIT && gfc_pure (NULL)) { - gfc_error - ("SAVE attribute at %L cannot be specified in a PURE procedure", - where); + gfc_error ("SAVE attribute at %L cannot be specified in a PURE " + "procedure", where); return false; } @@ -1319,10 +1318,15 @@ gfc_add_save (symbol_attribute *attr, save_state s, const char *name, if (s == SAVE_EXPLICIT && attr->save == SAVE_EXPLICIT && (flag_automatic || pedantic)) { - if (!gfc_notify_std (GFC_STD_LEGACY, - "Duplicate SAVE attribute specified at %L", - where)) + if (!where) + { + gfc_error ("Duplicate SAVE attribute specified near %C"); return false; + } + + if (!gfc_notify_std (GFC_STD_LEGACY, "Duplicate SAVE attribute " + "specified at %L", where)) + return false; } attr->save = s; diff --git a/gcc/testsuite/gfortran.dg/pr104626.f90 b/gcc/testsuite/gfortran.dg/pr104626.f90 new file mode 100644 index 0000000..faff65a --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr104626.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +program p + procedure(g), save :: f ! { dg-error "PROCEDURE attribute conflicts" } + procedure(g), save :: f ! { dg-error "Duplicate SAVE attribute" } +contains + subroutine g + end +end |