https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103591

--- Comment #2 from anlauf at gcc dot gnu.org ---
Untested fix:

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 2bf21434a42..52bc5af7542 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!  */
        }
     }

Reply via email to