diff options
author | Steven G. Kargl <kargl@gcc.gnu.org> | 2015-11-07 20:04:43 +0000 |
---|---|---|
committer | Steven G. Kargl <kargl@gcc.gnu.org> | 2015-11-07 20:04:43 +0000 |
commit | 727cde644d6175dcc5e22d4e1214bf3bac621efc (patch) | |
tree | d3d0d5880537429e6afae3fba5cc066553504f63 /gcc/fortran/match.c | |
parent | bc05d49d1064b7fb143c9786ca1fe6a1557163a2 (diff) | |
download | gcc-727cde644d6175dcc5e22d4e1214bf3bac621efc.zip gcc-727cde644d6175dcc5e22d4e1214bf3bac621efc.tar.gz gcc-727cde644d6175dcc5e22d4e1214bf3bac621efc.tar.bz2 |
re PR fortran/68151 (ICE on using select case with function of wrong type)
2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68151
* match.c (match_case_selector): Check for invalid type.
2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/68151
* gfortran.dg/pr68151.f90: New test.
From-SVN: r229938
Diffstat (limited to 'gcc/fortran/match.c')
-rw-r--r-- | gcc/fortran/match.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 7abb5de..2844262 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -5018,7 +5018,9 @@ gfc_free_case_list (gfc_case *p) } -/* Match a single case selector. */ +/* Match a single case selector. Combining the requirements of F08:C830 + and F08:C832 (R838) means that the case-value must have either CHARACTER, + INTEGER, or LOGICAL type. */ static match match_case_selector (gfc_case **cp) @@ -5036,6 +5038,14 @@ match_case_selector (gfc_case **cp) goto need_expr; if (m == MATCH_ERROR) goto cleanup; + + if (c->high->ts.type != BT_LOGICAL && c->high->ts.type != BT_INTEGER + && c->high->ts.type != BT_CHARACTER) + { + gfc_error ("Expression in CASE selector at %L cannot be %s", + &c->high->where, gfc_typename (&c->high->ts)); + goto cleanup; + } } else { @@ -5045,6 +5055,14 @@ match_case_selector (gfc_case **cp) if (m == MATCH_NO) goto need_expr; + if (c->low->ts.type != BT_LOGICAL && c->low->ts.type != BT_INTEGER + && c->low->ts.type != BT_CHARACTER) + { + gfc_error ("Expression in CASE selector at %L cannot be %s", + &c->low->where, gfc_typename (&c->low->ts)); + goto cleanup; + } + /* If we're not looking at a ':' now, make a range out of a single target. Else get the upper bound for the case range. */ if (gfc_match_char (':') != MATCH_YES) |