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
This commit is contained in:
parent
525b459f4d
commit
cb7a89619d
@ -1,3 +1,9 @@
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -1,3 +1,8 @@
|
||||
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>
|
||||
|
||||
PR fortran/40440
|
||||
|
20
gcc/testsuite/gfortran.dg/bounds_check_strlen_9.f90
Normal file
20
gcc/testsuite/gfortran.dg/bounds_check_strlen_9.f90
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user