diff options
author | Harald Anlauf <anlauf@gmx.de> | 2021-12-06 23:15:11 +0100 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2021-12-07 18:23:25 +0100 |
commit | f47662204de27f7685699eeef89aa173ccf32d85 (patch) | |
tree | 50f62857e6444a803f9fe4c0b379dae5aaf74bf9 /gcc/fortran/match.c | |
parent | 8e836af61b7027c0819da62c12a8d18b7c46f3fc (diff) | |
download | gcc-f47662204de27f7685699eeef89aa173ccf32d85.zip gcc-f47662204de27f7685699eeef89aa173ccf32d85.tar.gz gcc-f47662204de27f7685699eeef89aa173ccf32d85.tar.bz2 |
Fortran: add check for type of upper bound in case range
gcc/fortran/ChangeLog:
PR fortran/103591
* match.c (match_case_selector): Check type of upper bound in case
range.
gcc/testsuite/ChangeLog:
PR fortran/103591
* gfortran.dg/select_9.f90: New test.
Diffstat (limited to 'gcc/fortran/match.c')
-rw-r--r-- | gcc/fortran/match.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 2bf2143..52bc5af 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -6075,6 +6075,15 @@ match_case_selector (gfc_case **cp) m = gfc_match_init_expr (&c->high); if (m == MATCH_ERROR) goto cleanup; + if (m == MATCH_YES + && 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)); + goto cleanup; + } /* MATCH_NO is fine. It's OK if nothing is there! */ } } |