aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJanus Weil <janus@gcc.gnu.org>2011-01-31 19:11:32 +0100
committerJanus Weil <janus@gcc.gnu.org>2011-01-31 19:11:32 +0100
commitb6c77bcb57974ccbb49f5651f9ba0e443b864d1d (patch)
treeec55bdf179264755e2534d13a90560ef97a954d6 /gcc
parent0425d6f563d8b76eb4fcf2bf3ebb64cee85f6eca (diff)
downloadgcc-b6c77bcb57974ccbb49f5651f9ba0e443b864d1d.zip
gcc-b6c77bcb57974ccbb49f5651f9ba0e443b864d1d.tar.gz
gcc-b6c77bcb57974ccbb49f5651f9ba0e443b864d1d.tar.bz2
re PR fortran/47463 ([OOP] ICE in gfc_add_component_ref)
2011-01-31 Janus Weil <janus@gcc.gnu.org> PR fortran/47463 * resolve.c (resolve_typebound_subroutine): Bug fix for the case of an argument of a typebound assignment being a component. 2011-01-31 Janus Weil <janus@gcc.gnu.org> PR fortran/47463 * gfortran.dg/typebound_assignment_1.f03: New. From-SVN: r169443
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/resolve.c7
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/typebound_assignment_1.f0335
4 files changed, 49 insertions, 4 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index f787a97..e146d76 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2011-01-31 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/47463
+ * resolve.c (resolve_typebound_subroutine): Bug fix for the case of
+ an argument of a typebound assignment being a component.
+
2011-01-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* gfortranspec.c (add_arg_libgfortran) [HAVE_LD_STATIC_DYNAMIC] Use
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 20be0d1..2a0fc49 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -5877,14 +5877,12 @@ resolve_typebound_subroutine (gfc_code *code)
/* Deal with typebound operators for CLASS objects. */
expr = code->expr1->value.compcall.base_object;
- if (expr && expr->symtree->n.sym->ts.type == BT_CLASS
- && code->expr1->value.compcall.name)
+ if (expr && expr->ts.type == BT_CLASS && code->expr1->value.compcall.name)
{
/* Since the typebound operators are generic, we have to ensure
that any delays in resolution are corrected and that the vtab
is present. */
- ts = expr->symtree->n.sym->ts;
- declared = ts.u.derived;
+ declared = expr->ts.u.derived;
c = gfc_find_component (declared, "_vptr", true, true);
if (c->ts.u.derived == NULL)
c->ts.u.derived = gfc_find_derived_vtab (declared);
@@ -5895,6 +5893,7 @@ resolve_typebound_subroutine (gfc_code *code)
/* Use the generic name if it is there. */
name = name ? name : code->expr1->value.function.esym->name;
code->expr1->symtree = expr->symtree;
+ code->expr1->ref = gfc_copy_ref (expr->ref);
expr->symtree->n.sym->ts.u.derived = declared;
gfc_add_vptr_component (code->expr1);
gfc_add_component_ref (code->expr1, name);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9f8550e..0c17d83 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2011-01-31 Janus Weil <janus@gcc.gnu.org>
+
+ PR fortran/47463
+ * gfortran.dg/typebound_assignment_1.f03: New.
+
2011-01-31 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/47538
diff --git a/gcc/testsuite/gfortran.dg/typebound_assignment_1.f03 b/gcc/testsuite/gfortran.dg/typebound_assignment_1.f03
new file mode 100644
index 0000000..359572b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/typebound_assignment_1.f03
@@ -0,0 +1,35 @@
+! { dg-do compile }
+!
+! PR 47463: [OOP] ICE in gfc_add_component_ref
+!
+! Contributed by Rich Townsend <townsend@astro.wisc.edu>
+
+module hydro_state
+ type :: state_t
+ contains
+ procedure :: assign
+ generic :: assignment(=) => assign
+ end type state_t
+contains
+ subroutine assign (this, that)
+ class(state_t), intent(inout) :: this
+ class(state_t), intent(in) :: that
+ end subroutine assign
+end module hydro_state
+
+module hydro_flow
+ use hydro_state
+ type :: flow_t
+ class(state_t), allocatable :: st
+ end type flow_t
+contains
+ subroutine init_comps (this, st)
+ class(flow_t), intent(out) :: this
+ class(state_t), intent(in) :: st
+
+ allocate(state_t :: this%st)
+ this%st = st
+ end subroutine init_comps
+end module hydro_flow
+
+! { dg-final { cleanup-modules "hydro_state hydro_flow" } }