From: Janus Weil Date: Tue, 28 Dec 2010 21:21:53 +0000 (+0100) Subject: re PR fortran/45827 ([OOP] mio_component_ref(): Component not found) X-Git-Tag: upstream/12.2.0~87443 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9367d533746bca66659395d2af95bc2280b4037f;p=platform%2Fupstream%2Fgcc.git re PR fortran/45827 ([OOP] mio_component_ref(): Component not found) 2010-12-28 Janus Weil Daniel Franke PR fortran/45827 * module.c (mio_component_ref): Handle components of CLASS variables. 2010-12-28 Janus Weil PR fortran/45827 * gfortran.dg/class_32.f90: New. Co-Authored-By: Daniel Franke From-SVN: r168302 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 450d1df..e998899 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2010-12-28 Janus Weil + Daniel Franke + + PR fortran/45827 + * module.c (mio_component_ref): Handle components of CLASS variables. + 2010-12-27 Thomas Koenig * dump-parse-tree.c (show_typespec): Also show character kind. diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index f10e43b..f75e3fd 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2311,6 +2311,9 @@ mio_component_ref (gfc_component **cp, gfc_symbol *sym) { mio_internal_string (name); + if (sym && sym->attr.is_class) + sym = sym->components->ts.u.derived; + /* It can happen that a component reference can be read before the associated derived type symbol has been loaded. Return now and wait for a later iteration of load_needed. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 91d1c11..29ffa84 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-12-28 Janus Weil + + PR fortran/45827 + * gfortran.dg/class_32.f90: New. + 2010-12-28 H.J. Lu * gcc.target/i386/rdrand-1.c: Updated. diff --git a/gcc/testsuite/gfortran.dg/class_32.f90 b/gcc/testsuite/gfortran.dg/class_32.f90 new file mode 100644 index 0000000..b5857c1 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/class_32.f90 @@ -0,0 +1,41 @@ +! { dg-do compile } +! +! PR 45827: [4.6 Regression] [OOP] mio_component_ref(): Component not found +! +! Contributed by Daniel Franke + +MODULE m + + TYPE, ABSTRACT :: t + PRIVATE + INTEGER :: n + CONTAINS + PROCEDURE :: get + END TYPE + + ABSTRACT INTERFACE + SUBROUTINE create(this) + IMPORT t + CLASS(t) :: this + END SUBROUTINE + END INTERFACE + +CONTAINS + + FUNCTION get(this) + CLASS(t) :: this + REAL, DIMENSION(this%n) :: get + END FUNCTION + + SUBROUTINE destroy(this) + CLASS(t) :: this + END SUBROUTINE + +END MODULE + + +PROGRAM p + USE m +END + +! { dg-final { cleanup-modules "m" } }