Skip to content

Commit

Permalink
2009-06-16 Tobias Burnus <[email protected]>
Browse files Browse the repository at this point in the history
        PR fortran/40383
        * trans-decl.c (create_function_arglist): Copy formal charlist
        * to
        have a proper passed_length for -fcheck=bounds.

2009-06-16  Tobias Burnus  <[email protected]>

        PR fortran/40383
        * gfortran.dg/bounds_check_strlen_8.f90: New test.



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148517 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
burnus committed Jun 16, 2009
1 parent fb35bae commit 6be7c32
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gcc/fortran/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2009-06-16 Tobias Burnus <[email protected]>

PR fortran/40383
* trans-decl.c (create_function_arglist): Copy formal charlist to
have a proper passed_length for -fcheck=bounds.

2009-06-12 Steven G. Kargl <[email protected]>

* arith.c (gfc_enum_initializer): Move function ...
Expand Down
16 changes: 16 additions & 0 deletions gcc/fortran/trans-decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,22 @@ create_function_arglist (gfc_symbol * sym)
gfc_finish_decl (length);

/* Remember the passed value. */
if (f->sym->ts.cl->passed_length != NULL)
{
/* This can happen if the same type is used for multiple
arguments. We need to copy cl as otherwise
cl->passed_length gets overwritten. */
gfc_charlen *cl, *cl2;
cl = f->sym->ts.cl;
f->sym->ts.cl = gfc_get_charlen();
f->sym->ts.cl->length = cl->length;
f->sym->ts.cl->backend_decl = cl->backend_decl;
f->sym->ts.cl->length_from_typespec = cl->length_from_typespec;
f->sym->ts.cl->resolved = cl->resolved;
cl2 = f->sym->ts.cl->next;
f->sym->ts.cl->next = cl;
cl->next = cl2;
}
f->sym->ts.cl->passed_length = length;

/* Use the passed value for assumed length variables. */
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2009-06-16 Tobias Burnus <[email protected]>

PR fortran/40383
* gfortran.dg/bounds_check_strlen_8.f90: New test.

2009-06-15 Ian Lance Taylor <[email protected]>

* gcc.dg/Wjump-misses-init-1.c: New testcase.
Expand Down
40 changes: 40 additions & 0 deletions gcc/testsuite/gfortran.dg/bounds_check_strlen_8.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
! { dg-do run }
! { dg-options "-fbounds-check" }
!
! PR fortran/40383
! Gave before a bogus out of bounds.
! Contributed by Joost VandeVondele.
!
MODULE M1
INTEGER, PARAMETER :: default_string_length=80
END MODULE M1
MODULE M2
USE M1
IMPLICIT NONE
CONTAINS
FUNCTION F1(a,b,c,d) RESULT(RES)
CHARACTER(LEN=default_string_length), OPTIONAL :: a,b,c,d
LOGICAL :: res
END FUNCTION F1
END MODULE M2

MODULE M3
USE M1
USE M2
IMPLICIT NONE
CONTAINS
SUBROUTINE S1
CHARACTER(LEN=default_string_length) :: a,b
LOGICAL :: L1
INTEGER :: i
DO I=1,10
L1=F1(a,b)
ENDDO
END SUBROUTINE
END MODULE M3

USE M3
CALL S1
END

! { dg-final { cleanup-modules "m1 m2 m3" } }

0 comments on commit 6be7c32

Please sign in to comment.