+2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/68151
+ * match.c (match_case_selector): Check for invalid type.
+
2015-11-06 David Malcolm <dmalcolm@redhat.com>
* cpp.c (cb_cpp_error): Convert parameter from location_t to
}
-/* 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)
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
{
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)
+2015-11-07 Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/68151
+ * gfortran.dg/pr68151.f90: New test.
+
2015-11-07 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/68235
--- /dev/null
+! { dg-do compile }
+! PR fortran/68151
+! Original code contribute by Gerhard Steinmetz
+! <gerhard dot steinmetz dot fortran at t-online dot de>
+!
+program p
+ integer :: k = 1
+ select case (k)
+ case (:huge(1._4)) ! { dg-error "Expression in CASE" }
+ case (:huge(2._8)) ! { dg-error "Expression in CASE" }
+ case ((1.0,2.0)) ! { dg-error "Expression in CASE" }
+ end select
+end