+2009-06-20 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/40452
+ * trans-decl.c (add_argument_checking): Disable bounds check
+ for allowed argument storage association.
+
2009-06-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40440
/* For POINTER, ALLOCATABLE and assumed-shape dummy arguments, the
string lengths must match exactly. Otherwise, it is only required
- that the actual string length is *at least* the expected one. */
+ that the actual string length is *at least* the expected one.
+ Sequence association allows for a mismatch of the string length
+ if the actual argument is (part of) an array, but only if the
+ dummy argument is an array. (See "Sequence association" in
+ Section 12.4.1.4 for F95 and 12.4.1.5 for F2003.) */
if (fsym->attr.pointer || fsym->attr.allocatable
|| (fsym->as && fsym->as->type == AS_ASSUMED_SHAPE))
{
message = _("Actual string length does not match the declared one"
" for dummy argument '%s' (%ld/%ld)");
}
+ else if (fsym->as && fsym->as->rank != 0)
+ continue;
else
{
comparison = LT_EXPR;
--- /dev/null
+! { dg-do run }
+! { dg-options "-fbounds-check" }
+!
+! PR fortran/40452
+! The following program is valid Fortran 90 and later.
+! The storage-sequence association of the dummy argument
+! allows that the actual argument ["ab", "cd"] is mapped
+! to the dummy argument a(1) which perfectly fits.
+! (The dummy needs to be an array, however.)
+!
+
+program test
+ implicit none
+ call sub(["ab", "cd"])
+contains
+ subroutine sub(a)
+ character(len=4) :: a(1)
+ print *, a(1)
+ end subroutine sub
+end program test