+2020-03-23 Mark Eggleston <mark.eggleston@codethink.com>
+ Steven G. Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/93600
+ * expr.c (simplify_parameter_variable): Check whether the ref
+ chain contains INQUIRY_LEN or INQUIRY_KIND and set inquiry
+ boolean. When an empty array has been identified and a new
+ new EXPR_ARRAY expression has been created only return that
+ expression if inquiry is not set. This allows the new
+ expression to drop through to be simplified into a
+ EXPR_CONSTANT representing %kind or %len.
+ * matc.c (gfc_match_assignment): If lvalue doesn't have a
+ symtree free both lvalue and rvalue expressions and return
+ an error.
+ * resolv.c (gfc_resolve_ref): Ensure that code to handle
+ INQUIRY_LEN is only performed for arrays with deferred types.
+
2020-03-18 Jakub Jelinek <jakub@redhat.com>
* class.c (generate_finalization_wrapper): Fix up duplicated word
}
gfc_expression_rank (p);
+ /* Is this an inquiry? */
+ bool inquiry = false;
+ gfc_ref* ref = p->ref;
+ while (ref)
+ {
+ if (ref->type == REF_INQUIRY)
+ break;
+ ref = ref->next;
+ }
+ if (ref && ref->type == REF_INQUIRY)
+ inquiry = ref->u.i == INQUIRY_LEN || ref->u.i == INQUIRY_KIND;
+
if (gfc_is_size_zero_array (p))
{
if (p->expr_type == EXPR_ARRAY)
e->value.constructor = NULL;
e->shape = gfc_copy_shape (p->shape, p->rank);
e->where = p->where;
- gfc_replace_expr (p, e);
- return true;
+ /* If %kind and %len are not used then we're done, otherwise
+ drop through for simplification. */
+ if (!inquiry)
+ {
+ gfc_replace_expr (p, e);
+ return true;
+ }
}
+ else
+ {
+ e = gfc_copy_expr (p->symtree->n.sym->value);
+ if (e == NULL)
+ return false;
- e = gfc_copy_expr (p->symtree->n.sym->value);
- if (e == NULL)
- return false;
-
- e->rank = p->rank;
+ e->rank = p->rank;
+ }
if (e->ts.type == BT_CHARACTER && e->ts.u.cl == NULL)
e->ts.u.cl = gfc_new_charlen (gfc_current_ns, p->ts.u.cl);
gfc_actual_arglist *ap;
gfc_intrinsic_sym* isym = NULL;
-
if (p == NULL)
return true;
return m;
}
+ if (!lvalue->symtree)
+ {
+ gfc_free_expr (lvalue);
+ gfc_free_expr (rvalue);
+ return MATCH_ERROR;
+ }
+
+
gfc_set_sym_referenced (lvalue->symtree->n.sym);
new_st.op = EXEC_ASSIGN;
case REF_INQUIRY:
/* Implement requirement in note 9.7 of F2018 that the result of the
LEN inquiry be a scalar. */
- if (ref->u.i == INQUIRY_LEN && array_ref)
+ if (ref->u.i == INQUIRY_LEN && array_ref && expr->ts.deferred)
{
array_ref->u.ar.type = AR_ELEMENT;
expr->rank = 0;
+2020-03-23 Mark Eggleston <mark.eggleston@codethink.com>
+
+ PR fortran/93365
+ PR fortran/93600
+ * gfortran.dg/pr93365.f90: New test.
+ * gfortran.dg/pr93600_1.f90: New test.
+ * gfortran.dg/pr93600_2.f90: New test.
+
2020-03-23 Tobias Burnus <tobias@codesourcery.com>
* lib/target-supports.exp (check_effective_target_offload_gcn):
--- /dev/null
+! { dg-do run }
+
+program p
+ logical, parameter :: a(0) = .true.
+ real, parameter :: b(0) = 0
+ complex, parameter :: c(0) = 0
+ integer :: d
+ data d /a%kind/
+ data e /b%kind/
+ data f /c%kind/
+ if (d .ne. kind(a)) stop 1
+ if (e .ne. kind(b)) stop 2
+ if (f .ne. kind(c)) stop 3
+end
+
--- /dev/null
+! { dg-do compile }
+
+program p
+ integer, parameter :: a(0) = 0
+ character(0), parameter :: b(0) = ''
+ a%kind = 1 ! { dg-error "Assignment to a constant expression" }
+ b%len = 'a' ! { dg-error "Assignment to a constant expression" }
+end program
+
--- /dev/null
+! { dg-do run }
+
+program p
+ integer, parameter :: a(0) = 0
+ character(0), parameter :: b(0) = ''
+ integer :: c
+ if (a%kind.ne.kind(c)) stop 1
+ if (b%len.ne.0) stop 2
+end program
+