aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/match.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2019-09-23 09:19:10 +0000
committerPaul Thomas <pault@gcc.gnu.org>2019-09-23 09:19:10 +0000
commit158ab204321cfa5fe5466faa5a12b3c38c45125a (patch)
tree4f354f0a71b207100c814aa1f714f5f8d8d9927b /gcc/fortran/match.c
parentb7bb3d35804f1d50d7dcfa18aacf1f91d898bb1f (diff)
downloadgcc-158ab204321cfa5fe5466faa5a12b3c38c45125a.zip
gcc-158ab204321cfa5fe5466faa5a12b3c38c45125a.tar.gz
gcc-158ab204321cfa5fe5466faa5a12b3c38c45125a.tar.bz2
re PR fortran/91729 (ICE in gfc_match_select_rank, at fortran/match.c:6586)
2019-09-23 Paul Thomas <pault@gcc.gnu.org> PR fortran/91729 * match.c (gfc_match_select_rank): Initialise 'as' to NULL. Check for a symtree in the selector expression before trying to assign a value to 'as'. Revert to gfc_error and go to cleanup after setting a MATCH_ERROR. 2019-09-23 Paul Thomas <pault@gcc.gnu.org> PR fortran/91729 * gfortran.dg/select_rank_2.f90 : Add two more errors in foo2. * gfortran.dg/select_rank_3.f90 : New test. From-SVN: r276051
Diffstat (limited to 'gcc/fortran/match.c')
-rw-r--r--gcc/fortran/match.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 56d9af0..9b9dbf1 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -6510,7 +6510,7 @@ gfc_match_select_rank (void)
char name[GFC_MAX_SYMBOL_LEN];
gfc_symbol *sym, *sym2;
gfc_namespace *ns = gfc_current_ns;
- gfc_array_spec *as;
+ gfc_array_spec *as = NULL;
m = gfc_match_label ();
if (m == MATCH_ERROR)
@@ -6538,13 +6538,21 @@ gfc_match_select_rank (void)
}
sym = expr1->symtree->n.sym;
- sym2 = expr2->symtree->n.sym;
- as = sym2->ts.type == BT_CLASS ? CLASS_DATA (sym2)->as : sym2->as;
+ if (expr2->symtree)
+ {
+ sym2 = expr2->symtree->n.sym;
+ as = sym2->ts.type == BT_CLASS ? CLASS_DATA (sym2)->as : sym2->as;
+ }
+
if (expr2->expr_type != EXPR_VARIABLE
|| !(as && as->type == AS_ASSUMED_RANK))
- gfc_error_now ("The SELECT RANK selector at %C must be an assumed "
- "rank variable");
+ {
+ gfc_error ("The SELECT RANK selector at %C must be an assumed "
+ "rank variable");
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
if (expr2->ts.type == BT_CLASS)
{
@@ -6583,12 +6591,20 @@ gfc_match_select_rank (void)
return m;
}
- sym = expr1->symtree->n.sym;
- as = sym->ts.type == BT_CLASS ? CLASS_DATA (sym)->as : sym->as;
+ if (expr1->symtree)
+ {
+ sym = expr1->symtree->n.sym;
+ as = sym->ts.type == BT_CLASS ? CLASS_DATA (sym)->as : sym->as;
+ }
+
if (expr1->expr_type != EXPR_VARIABLE
|| !(as && as->type == AS_ASSUMED_RANK))
- gfc_error_now ("The SELECT RANK selector at %C must be an assumed "
- "rank variable");
+ {
+ gfc_error("The SELECT RANK selector at %C must be an assumed "
+ "rank variable");
+ m = MATCH_ERROR;
+ goto cleanup;
+ }
}
m = gfc_match (" )%t");