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
This commit is contained in:
Steven G. Kargl 2015-11-07 20:04:43 +00:00
parent bc05d49d10
commit 727cde644d
4 changed files with 42 additions and 1 deletions

View File

@ -1,3 +1,8 @@
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

View File

@ -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)

View File

@ -1,3 +1,8 @@
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

View File

@ -0,0 +1,13 @@
! { 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