aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2022-01-12 21:24:49 +0100
committerHarald Anlauf <anlauf@gmx.de>2022-01-13 19:24:13 +0100
commit0b8464365b15ac108cd1d00d5bc56d229c1340de (patch)
tree9d08a0f4cecaf2bfa7ac8906a8926162b652d6b6 /gcc/fortran
parent386b15d6ef2db6bcca1369650f5456728e2d42f1 (diff)
downloadgcc-0b8464365b15ac108cd1d00d5bc56d229c1340de.zip
gcc-0b8464365b15ac108cd1d00d5bc56d229c1340de.tar.gz
gcc-0b8464365b15ac108cd1d00d5bc56d229c1340de.tar.bz2
Fortran: fix error recovery on bad structure constructor in DATA statement
gcc/fortran/ChangeLog: PR fortran/67804 * primary.c (gfc_match_structure_constructor): Recover from errors that occurred while checking for a valid structure constructor in a DATA statement. gcc/testsuite/ChangeLog: PR fortran/67804 * gfortran.dg/pr93604.f90: Adjust to changed diagnostics. * gfortran.dg/pr67804.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/primary.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index fd4d6af..3f01f67 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -3364,6 +3364,7 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result)
match m;
gfc_expr *e;
gfc_symtree *symtree;
+ bool t = true;
gfc_get_ha_sym_tree (sym->name, &symtree);
@@ -3394,10 +3395,18 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result)
in the structure constructor must be a constant. Try to reduce the
expression here. */
if (gfc_in_match_data ())
- gfc_reduce_init_expr (e);
+ t = gfc_reduce_init_expr (e);
- *result = e;
- return MATCH_YES;
+ if (t)
+ {
+ *result = e;
+ return MATCH_YES;
+ }
+ else
+ {
+ gfc_free_expr (e);
+ return MATCH_ERROR;
+ }
}