Commit 28bc117f by Steven G. Kargl

re PR fortran/68224 (ICE on referencing parameter array with dimension null)

2015-11-08  Steven G. Kargl  <kargl@gc.gnu.org>

	PR fortran/68224
	* array.c (match_array_element_spec): Check of invalid NULL().
	While here, fix nearby comments.

2015-11-08  Steven G. Kargl  <kargl@gc.gnu.org>

	PR fortran/68224
	* gfortran.dg/pr68224.f90: New test.

From-SVN: r229955
parent 57905c2b
2015-11-08 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/68224
* array.c (match_array_element_spec): Check of invalid NULL().
While here, fix nearby comments.
2015-11-08 Paul Thomas <pault@gcc.gnu.org> 2015-11-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/68196 PR fortran/68196
......
...@@ -147,9 +147,9 @@ matched: ...@@ -147,9 +147,9 @@ matched:
} }
/* Match an array reference, whether it is the whole array or a /* Match an array reference, whether it is the whole array or particular
particular elements or a section. If init is set, the reference has elements or a section. If init is set, the reference has to consist
to consist of init expressions. */ of init expressions. */
match match
gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init, gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
...@@ -422,6 +422,13 @@ match_array_element_spec (gfc_array_spec *as) ...@@ -422,6 +422,13 @@ match_array_element_spec (gfc_array_spec *as)
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN; return AS_UNKNOWN;
if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN
&& (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0)
{
gfc_error ("Expecting a scalar INTEGER expression at %C");
return AS_UNKNOWN;
}
if (gfc_match_char (':') == MATCH_NO) if (gfc_match_char (':') == MATCH_NO)
{ {
*lower = gfc_get_int_expr (gfc_default_integer_kind, NULL, 1); *lower = gfc_get_int_expr (gfc_default_integer_kind, NULL, 1);
...@@ -442,13 +449,20 @@ match_array_element_spec (gfc_array_spec *as) ...@@ -442,13 +449,20 @@ match_array_element_spec (gfc_array_spec *as)
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false)) if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
return AS_UNKNOWN; return AS_UNKNOWN;
if ((*upper)->expr_type == EXPR_FUNCTION && (*upper)->ts.type == BT_UNKNOWN
&& (*upper)->symtree && strcmp ((*upper)->symtree->name, "null") == 0)
{
gfc_error ("Expecting a scalar INTEGER expression at %C");
return AS_UNKNOWN;
}
return AS_EXPLICIT; return AS_EXPLICIT;
} }
/* Matches an array specification, incidentally figuring out what sort /* Matches an array specification, incidentally figuring out what sort
it is. Match either a normal array specification, or a coarray spec it is. Match either a normal array specification, or a coarray spec
or both. Optionally allow [:] for coarrays. */ or both. Optionally allow [:] for coarrays. */
match match
gfc_match_array_spec (gfc_array_spec **asp, bool match_dim, bool match_codim) gfc_match_array_spec (gfc_array_spec **asp, bool match_dim, bool match_codim)
......
2015-11-08 Steven G. Kargl <kargl@gc.gnu.org>
PR fortran/68224
* gfortran.dg/pr68224.f90: New test.
2015-11-08 Paul Thomas <pault@gcc.gnu.org> 2015-11-08 Paul Thomas <pault@gcc.gnu.org>
PR fortran/68196 PR fortran/68196
......
! { dg-do compile }
! PR fortran/68224
! Original code contribute by Gerhard Steinmetz
! <gerhard dot steinmetz dot fortran at t-online dot de>
!
program p
integer, parameter :: a(null()) = [1, 2] ! { dg-error "scalar INTEGER expression" }
integer, parameter :: b(null():*) = [1, 2] ! { dg-error "scalar INTEGER expression" }
integer, parameter :: c(1:null()) = [1, 2] ! { dg-error "scalar INTEGER expression" }
end program p
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment