gcc/fortran/ChangeLog:
PR fortran/103776
* match.c (match_case_selector): Reject expressions in CASE
selector which are not scalar.
gcc/testsuite/ChangeLog:
PR fortran/103776
* gfortran.dg/select_10.f90: New test.
}
}
+ if (c->low && c->low->rank != 0)
+ {
+ gfc_error ("Expression in CASE selector at %L must be scalar",
+ &c->low->where);
+ goto cleanup;
+ }
+ if (c->high && c->high->rank != 0)
+ {
+ gfc_error ("Expression in CASE selector at %L must be scalar",
+ &c->high->where);
+ goto cleanup;
+ }
+
*cp = c;
return MATCH_YES;
--- /dev/null
+! { dg-do compile }
+! PR fortran/103776 - ICE in gfc_compare_string
+! Contributed by G.Steinmetz
+
+program p
+ integer :: n
+ select case (n)
+ case ([1]) ! { dg-error "must be scalar" }
+ end select
+ select case (n)
+ case (:[2]) ! { dg-error "must be scalar" }
+ end select
+ select case (n)
+ case (['1']) ! { dg-error "must be scalar" }
+ end select
+ select case (n)
+ case (['1']:2) ! { dg-error "must be scalar" }
+ end select
+ select case (n)
+ case(['1']:['2']) ! { dg-error "must be scalar" }
+ end select
+ select case (n)
+ case(1:['2']) ! { dg-error "must be scalar" }
+ end select
+end