diff options
author | Asher Langton <langton2@llnl.gov> | 2011-06-02 21:41:12 +0000 |
---|---|---|
committer | Asher Langton <langton@gcc.gnu.org> | 2011-06-02 21:41:12 +0000 |
commit | cde3a7a96908f651a844fd43905a64651d42c5af (patch) | |
tree | f9006deff7edb39e13973983e95767c37b35e499 | |
parent | 11126dc093925fdfebfb0d3f9eff60a75d5e5a23 (diff) | |
download | gcc-cde3a7a96908f651a844fd43905a64651d42c5af.zip gcc-cde3a7a96908f651a844fd43905a64651d42c5af.tar.gz gcc-cde3a7a96908f651a844fd43905a64651d42c5af.tar.bz2 |
re PR fortran/49268 (Invalid code generated for assumed-size Cray pointee)
* trans-decl.c (gfc_trans_deferred_vars): Treat assumed-size Cray
pointees as AS_EXPLICIT.
* gfortran.dg/PR49268.f90: New test.
From-SVN: r174584
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/trans-decl.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/PR49268.f90 | 51 |
4 files changed, 67 insertions, 1 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fec047e..532a30b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,11 @@ 2011-06-02 Asher Langton <langton2@llnl.gov> + PR fortran/49268 + * trans-decl.c (gfc_trans_deferred_vars): Treat assumed-size Cray + pointees as AS_EXPLICIT. + +2011-06-02 Asher Langton <langton2@llnl.gov> + PR fortran/37039 * decl.c (variable_decl): Merge current_as before copying to cp_as. diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 27eca79..a225915 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -3465,7 +3465,11 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block) if (sym->attr.dimension || sym->attr.codimension) { - switch (sym->as->type) + /* Assumed-size Cray pointees need to be treated as AS_EXPLICIT. */ + array_type tmp = sym->as->type; + if (tmp == AS_ASSUMED_SIZE && sym->as->cp_was_assumed) + tmp = AS_EXPLICIT; + switch (tmp) { case AS_EXPLICIT: if (sym->attr.dummy || sym->attr.result) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2a45ec1..135087c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2011-06-02 Asher Langton <langton2@llnl.gov> + PR fortran/49268 + * gfortran.dg/PR49268.f90: New test. + +2011-06-02 Asher Langton <langton2@llnl.gov> + PR fortran/37039 * gfortran.dg/PR37039.f90: New test. diff --git a/gcc/testsuite/gfortran.dg/PR49268.f90 b/gcc/testsuite/gfortran.dg/PR49268.f90 new file mode 100644 index 0000000..5b274cf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/PR49268.f90 @@ -0,0 +1,51 @@ +! { dg-do run } +! { dg-options "-fcray-pointer" } + +! Test the fix for a runtime error +! Contributed by Mike Kumbera <kumbera1@llnl.gov> + + program bob + implicit none + integer*8 ipfoo + integer n,m,i,j + real*8 foo + + common /ipdata/ ipfoo + common /ipsize/ n,m + POINTER ( ipfoo, foo(3,7) ) + + n=3 + m=7 + + ipfoo=malloc(8*n*m) + do i=1,n + do j=1,m + foo(i,j)=1.d0 + end do + end do + call use_foo() + end program bob + + + subroutine use_foo() + implicit none + integer n,m,i,j + integer*8 ipfoo + common /ipdata/ ipfoo + common /ipsize/ n,m + real*8 foo,boo + + !fails if * is the last dimension + POINTER ( ipfoo, foo(n,*) ) + + !works if the last dimension is specified + !POINTER ( ipfoo, foo(n,m) ) + boo=0.d0 + do i=1,n + do j=1,m + boo=foo(i,j)+1.0 + if (abs (boo - 2.0) .gt. 1e-6) call abort + end do + end do + + end subroutine use_foo |