From: Janus Weil Date: Fri, 2 Jan 2015 16:31:52 +0000 (+0100) Subject: re PR fortran/57562 ([OOP] ICE due to extended derived type with PARAMETER attribute) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=74a1c62fca5ca93ae932ac76ca442660d9c78c3a;p=gcc.git re PR fortran/57562 ([OOP] ICE due to extended derived type with PARAMETER attribute) 2015-01-02 Janus Weil PR fortran/57562 * expr.c (find_component_ref): Deal with extended types. 2015-01-02 Janus Weil PR fortran/57562 * gfortran.dg/extends_16.f90: New. From-SVN: r219144 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index ea72687383f..9c88eb8ead6 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,8 @@ +2015-01-02 Janus Weil + + PR fortran/57562 + * expr.c (find_component_ref): Deal with extended types. + 2015-01-02 Tobias Burnus * trans-decl.c (gfc_build_qualified_array): Fix coarray tokens diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 51f527dad12..2d85092865f 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -1270,12 +1270,23 @@ depart: static gfc_constructor * find_component_ref (gfc_constructor_base base, gfc_ref *ref) { - gfc_component *comp; - gfc_component *pick; + gfc_component *pick = ref->u.c.component; gfc_constructor *c = gfc_constructor_first (base); - comp = ref->u.c.sym->components; - pick = ref->u.c.component; + gfc_symbol *dt = ref->u.c.sym; + int ext = dt->attr.extension; + + /* For extended types, check if the desired component is in one of the + * parent types. */ + while (ext > 0 && gfc_find_component (dt->components->ts.u.derived, + pick->name, true, true)) + { + dt = dt->components->ts.u.derived; + c = gfc_constructor_first (c->expr->value.constructor); + ext--; + } + + gfc_component *comp = dt->components; while (comp != pick) { comp = comp->next; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 095b09d80e3..5fc092e9acf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-02 Janus Weil + + PR fortran/57562 + * gfortran.dg/extends_16.f90: New. + 2015-01-02 Tobias Burnus * gfortran.dg/coarray/caf.exp (dg-compile-aux-modules): Add. @@ -12,7 +17,7 @@ 2015-01-02 Janus Weil PR fortran/60507 - * gfortran.dg/dummy_procedure_11: New. + * gfortran.dg/dummy_procedure_11.f90: New. Copyright (C) 2015 Free Software Foundation, Inc. diff --git a/gcc/testsuite/gfortran.dg/extends_16.f90 b/gcc/testsuite/gfortran.dg/extends_16.f90 new file mode 100644 index 00000000000..376fcaae49d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/extends_16.f90 @@ -0,0 +1,25 @@ +! { dg-do run } +! +! PR 57562: [OOP] ICE due to extended derived type with PARAMETER attribute +! +! Contributed by + + type :: Parent + integer :: member1 = 0 + end type + + type, extends(Parent) :: Child + integer :: member2 = 0 + end type + + type, extends(Child) :: Grandchild + integer :: member3 = 0 + end type + + type(Grandchild), parameter :: object = Grandchild(23, 42, -99) + + if (object%member1 /= 23) call abort + if (object%member2 /= 42) call abort + if (object%member3 /= -99) call abort + +end