}
-/* Match an array reference, whether it is the whole array or a
- particular elements or a section. If init is set, the reference has
- to consist of init expressions. */
+/* Match an array reference, whether it is the whole array or particular
+ elements or a section. If init is set, the reference has to consist
+ of init expressions. */
match
gfc_match_array_ref (gfc_array_ref *ar, gfc_array_spec *as, int init,
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
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)
{
*lower = gfc_get_int_expr (gfc_default_integer_kind, NULL, 1);
if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
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;
}
/* Matches an array specification, incidentally figuring out what sort
- it is. Match either a normal array specification, or a coarray spec
- or both. Optionally allow [:] for coarrays. */
+ it is. Match either a normal array specification, or a coarray spec
+ or both. Optionally allow [:] for coarrays. */
match
gfc_match_array_spec (gfc_array_spec **asp, bool match_dim, bool match_codim)
--- /dev/null
+! { 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