Commit cb7a8961 by Tobias Burnus Committed by Tobias Burnus

re PR fortran/40452 (-fbounds-check: False positive due to ignoring storage association)

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-20  Tobias Burnus  <burnus@net-b.de>

        PR fortran/40452
        * gfortran.dg/bounds_check_strlen_9.f90: New test.

From-SVN: r148750
parent 525b459f
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> 2009-06-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40440 PR fortran/40440
......
...@@ -3835,7 +3835,11 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym) ...@@ -3835,7 +3835,11 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym)
/* For POINTER, ALLOCATABLE and assumed-shape dummy arguments, the /* For POINTER, ALLOCATABLE and assumed-shape dummy arguments, the
string lengths must match exactly. Otherwise, it is only required 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 if (fsym->attr.pointer || fsym->attr.allocatable
|| (fsym->as && fsym->as->type == AS_ASSUMED_SHAPE)) || (fsym->as && fsym->as->type == AS_ASSUMED_SHAPE))
{ {
...@@ -3843,6 +3847,8 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym) ...@@ -3843,6 +3847,8 @@ add_argument_checking (stmtblock_t *block, gfc_symbol *sym)
message = _("Actual string length does not match the declared one" message = _("Actual string length does not match the declared one"
" for dummy argument '%s' (%ld/%ld)"); " for dummy argument '%s' (%ld/%ld)");
} }
else if (fsym->as && fsym->as->rank != 0)
continue;
else else
{ {
comparison = LT_EXPR; comparison = LT_EXPR;
......
2009-06-20 Tobias Burnus <burnus@net-b.de>
PR fortran/40452
* gfortran.dg/bounds_check_strlen_9.f90: New test.
2009-06-19 Paul Thomas <pault@gcc.gnu.org> 2009-06-19 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40440 PR fortran/40440
......
! { 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
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