From: burnus Date: Sat, 20 Jun 2009 18:07:10 +0000 (+0000) Subject: 2009-06-20 Tobias Burnus X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=be4be7714eee85c5ef4f585fae7435311a325bce 2009-06-20 Tobias Burnus PR fortran/40452 * trans-decl.c (add_argument_checking): Disable bounds check for allowed argument storage association. 2009-06-20 Tobias Burnus PR fortran/40452 * gfortran.dg/bounds_check_strlen_9.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148750 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c38b91ac6fd..0d88c4b9fa9 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-06-20 Tobias Burnus + + PR fortran/40452 + * trans-decl.c (add_argument_checking): Disable bounds check + for allowed argument storage association. + 2009-06-19 Paul Thomas PR fortran/40440 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 5af00a91a03..091d3946852 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -3835,7 +3835,11 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym) /* 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)) { @@ -3843,6 +3847,8 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym) 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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dcc2e53a5c4..210d2112e53 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-06-20 Tobias Burnus + + PR fortran/40452 + * gfortran.dg/bounds_check_strlen_9.f90: New test. + 2009-06-19 Paul Thomas PR fortran/40440 diff --git a/gcc/testsuite/gfortran.dg/bounds_check_strlen_9.f90 b/gcc/testsuite/gfortran.dg/bounds_check_strlen_9.f90 new file mode 100644 index 00000000000..89622e24967 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/bounds_check_strlen_9.f90 @@ -0,0 +1,20 @@ +! { 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