aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-04-23 15:13:48 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-04-23 15:13:48 +0000
commit6e0d7c6e0d8d744a57e2d111ab95a7ab8115ebf8 (patch)
treecd69678252d64187f28421f356008d5cce4dce95
parenta8a423360bf1e0e8dffac6087084a129d9251dc4 (diff)
downloadgcc-6e0d7c6e0d8d744a57e2d111ab95a7ab8115ebf8.zip
gcc-6e0d7c6e0d8d744a57e2d111ab95a7ab8115ebf8.tar.gz
gcc-6e0d7c6e0d8d744a57e2d111ab95a7ab8115ebf8.tar.bz2
re PR fortran/31630 (ICE on nasty derived types code)
2007-04-23 Paul Thomas <pault@gcc.gnu.org> PR fortran/31630 * resolve.c (resolve_symbol): Allow resolution of formal namespaces nested within formal namespaces coming from modules. PR fortran/31620 * trans-expr.c (gfc_trans_assignment): Make the call to gfc_trans_zero_assign conditional on the lhs array ref being the only reference. 2007-04-23 Paul Thomas <pault@gcc.gnu.org> PR fortran/31630 * gfortran.dg/used_types_17.f90: New test. PR fortran/31620 * gfortran.dg/zero_array_components_1.f90: New test. From-SVN: r124069
-rw-r--r--gcc/fortran/ChangeLog11
-rw-r--r--gcc/fortran/resolve.c9
-rw-r--r--gcc/fortran/trans-expr.c1
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gfortran.dg/used_types_17.f9050
-rw-r--r--gcc/testsuite/gfortran.dg/zero_array_components_1.f9017
6 files changed, 93 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1a6d9f8..70919a4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,14 @@
+2007-04-23 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/31630
+ * resolve.c (resolve_symbol): Allow resolution of formal
+ namespaces nested within formal namespaces coming from modules.
+
+ PR fortran/31620
+ * trans-expr.c (gfc_trans_assignment): Make the call to
+ gfc_trans_zero_assign conditional on the lhs array ref being
+ the only reference.
+
2007-04-23 Tobias Burnus <burnus@net-b.de>
* primary.c (match_integer_constant): Mention -fno-range-check
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 7ad4f55..c759f69 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -6339,12 +6339,15 @@ resolve_symbol (gfc_symbol *sym)
formal_arg_flag = 0;
- /* Resolve formal namespaces. */
-
+ /* Resolve formal namespaces. The symbols in formal namespaces that
+ themselves are from procedures in formal namespaces will not stand
+ resolution, except when they are use associated.
+ TODO: Fix the symbols in formal namespaces so that resolution can
+ be done unconditionally. */
if (formal_ns_flag && sym != NULL && sym->formal_ns != NULL)
{
formal_ns_save = formal_ns_flag;
- formal_ns_flag = 0;
+ formal_ns_flag = sym->attr.use_assoc ? 1 : 0;
gfc_resolve (sym->formal_ns);
formal_ns_flag = formal_ns_save;
}
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 498cc71..182ec19 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -3943,6 +3943,7 @@ gfc_trans_assignment (gfc_expr * expr1, gfc_expr * expr2, bool init_flag)
if (expr1->expr_type == EXPR_VARIABLE
&& expr1->rank > 0
&& expr1->ref
+ && expr1->ref->next == NULL
&& gfc_full_array_ref_p (expr1->ref)
&& is_zero_initializer_p (expr2))
{
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5561dfd..22b6f46b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2007-04-23 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/31630
+ * gfortran.dg/used_types_17.f90: New test.
+
+ PR fortran/31620
+ * gfortran.dg/zero_array_components_1.f90: New test.
+
2007-04-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR fortran/31616
diff --git a/gcc/testsuite/gfortran.dg/used_types_17.f90 b/gcc/testsuite/gfortran.dg/used_types_17.f90
new file mode 100644
index 0000000..964f371
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/used_types_17.f90
@@ -0,0 +1,50 @@
+! { dg do-compile }
+! Tests the fix for PR31630, in which the association of the argument
+! of 'cmp' did not work.
+!
+! Contributed by Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
+!
+module box_module
+ type box
+ integer :: m = 0
+ end type box
+end module box_module
+
+module sort_box_module
+contains
+
+ subroutine heapsort_box(cmp)
+ interface
+ subroutine cmp(a)
+ use box_module
+ type(box) :: a
+ end subroutine cmp
+ end interface
+ optional :: cmp
+ end subroutine heapsort_box
+
+end module sort_box_module
+
+
+module boxarray_module
+ use box_module
+ implicit none
+
+ type boxarray
+ type(box), allocatable :: bxs(:)
+ end type boxarray
+contains
+
+ subroutine boxarray_build_l(ba)
+ type(boxarray) :: ba
+ allocate(ba%bxs(1))
+ end subroutine boxarray_build_l
+
+ subroutine boxarray_sort()
+ use sort_box_module
+ call heapsort_box
+ end subroutine boxarray_sort
+
+end module boxarray_module
+
+! { dg-final { cleanup-modules "box_module sort_box_module boxarray_module" } }
diff --git a/gcc/testsuite/gfortran.dg/zero_array_components_1.f90 b/gcc/testsuite/gfortran.dg/zero_array_components_1.f90
new file mode 100644
index 0000000..514f90c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/zero_array_components_1.f90
@@ -0,0 +1,17 @@
+! { dg do-run }
+! Tests the fix for PR31620, in which zeroing the component a for the array,
+! would zero all the components of the array.
+!
+! David Ham <David@ham.dropbear.id.au>
+!
+program test_assign
+ type my_type
+ integer :: a
+ integer :: b
+ end type my_type
+ type(my_type), dimension(1) :: mine ! note that MINE is an array
+ mine%b=4
+ mine%a=1
+ mine%a=0
+ if (any (mine%b .ne. 4)) call abort ()
+end program test_assign