aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2008-03-16 19:14:17 +0000
committerPaul Thomas <pault@gcc.gnu.org>2008-03-16 19:14:17 +0000
commitc52938ec21193c37f7c1e76d0517dfe22620be94 (patch)
tree633db8190966c3533cf3b0b7a952b68a444f85c7
parent41ff0d66b3825f5efbc5bb0135c0348b5ff01244 (diff)
downloadgcc-c52938ec21193c37f7c1e76d0517dfe22620be94.zip
gcc-c52938ec21193c37f7c1e76d0517dfe22620be94.tar.gz
gcc-c52938ec21193c37f7c1e76d0517dfe22620be94.tar.bz2
re PR fortran/35470 (Valid pointer assigment code gives compilation errors)
2008-03-16 Paul Thomas <pault@gcc.gnu.org> PR fortran/35470 * resolve.c (check_assumed_size_reference): Only visit the first reference and look directly at the highest dimension. 2008-03-16 Paul Thomas <pault@gcc.gnu.org> PR fortran/35470 * gfortran.dg/subref_array_pointer_3.f90 : New test. From-SVN: r133279
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/subref_array_pointer_3.f9015
4 files changed, 29 insertions, 11 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 3757220..08f1a8c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-16 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/35470
+ * resolve.c (check_assumed_size_reference): Only visit the
+ first reference and look directly at the highest dimension.
+
2008-03-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/35184
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index f8cd803..3d8fd3c 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -954,20 +954,12 @@ static int need_full_assumed_size = 0;
static bool
check_assumed_size_reference (gfc_symbol *sym, gfc_expr *e)
{
- gfc_ref *ref;
- int dim;
- int last = 1;
-
if (need_full_assumed_size || !(sym->as && sym->as->type == AS_ASSUMED_SIZE))
return false;
- for (ref = e->ref; ref; ref = ref->next)
- if (ref->type == REF_ARRAY)
- for (dim = 0; dim < ref->u.ar.as->rank; dim++)
- last = (ref->u.ar.end[dim] == NULL)
- && (ref->u.ar.type == DIMEN_ELEMENT);
-
- if (last)
+ if ((e->ref->u.ar.end[e->ref->u.ar.as->rank - 1] == NULL)
+ && (e->ref->u.ar.as->type == AS_ASSUMED_SIZE)
+ && (e->ref->u.ar.type == DIMEN_ELEMENT))
{
gfc_error ("The upper bound in the last dimension must "
"appear in the reference to the assumed size "
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d6c830a..10ead70 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-03-16 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/35470
+ * gfortran.dg/subref_array_pointer_3.f90 : New test.
+
2008-03-16 Richard Guenther <rguenther@suse.de>
PR middle-end/35607
diff --git a/gcc/testsuite/gfortran.dg/subref_array_pointer_3.f90 b/gcc/testsuite/gfortran.dg/subref_array_pointer_3.f90
new file mode 100644
index 0000000..b345c9d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/subref_array_pointer_3.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! Tests the fix for PR35470, in which the pointer assignment would fail
+! because the assumed size 'arr' would get mixed up with the component
+! 'p' in the check for the upper bound of an assumed size array.
+!
+! Contributed by Antony Lewis <antony@cosmologist.info>
+!
+subroutine sub(arr)
+ type real_pointer
+ real, pointer :: p(:)
+ end type real_pointer
+ type(real_pointer), dimension(*) :: arr
+ real, pointer :: p(:)
+ p => arr(1)%p
+end subroutine