From 5e7bb2b9b1c145d426011d5807931e1bc7ab246f Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Sun, 29 May 2011 22:32:11 +0200 Subject: [PATCH] re PR fortran/47601 ([OOP] Internal Error: mio_component_ref(): Component not found) 2011-05-29 Janus Weil PR fortran/47601 * module.c (mio_component_ref): Handle components of extended types. * symbol.c (gfc_find_component): Return is sym is NULL. 2011-05-29 Janus Weil PR fortran/47601 * gfortran.dg/extends_13.f03: New. From-SVN: r174416 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/module.c | 10 +++----- gcc/fortran/symbol.c | 2 +- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gfortran.dg/extends_13.f03 | 30 ++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/extends_13.f03 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 5ffa5f673f9..da086438ab5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2011-05-29 Janus Weil + + PR fortran/47601 + * module.c (mio_component_ref): Handle components of extended types. + * symbol.c (gfc_find_component): Return is sym is NULL. + 2011-05-29 Tobias Burnus PR fortran/18918 diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index b6acca3a5f1..533246d0c8d 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -2356,14 +2356,10 @@ mio_component_ref (gfc_component **cp, gfc_symbol *sym) if (sym->components != NULL && p->u.pointer == NULL) { /* Symbol already loaded, so search by name. */ - for (q = sym->components; q; q = q->next) - if (strcmp (q->name, name) == 0) - break; - - if (q == NULL) - gfc_internal_error ("mio_component_ref(): Component not found"); + q = gfc_find_component (sym, name, true, true); - associate_integer_pointer (p, q); + if (q) + associate_integer_pointer (p, q); } /* Make sure this symbol will eventually be loaded. */ diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 4b4f75fe827..b761cdd47e8 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1996,7 +1996,7 @@ gfc_find_component (gfc_symbol *sym, const char *name, { gfc_component *p; - if (name == NULL) + if (name == NULL || sym == NULL) return NULL; sym = gfc_use_derived (sym); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0f2b1dc1fe2..9c9b6fb470e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-05-29 Janus Weil + + PR fortran/47601 + * gfortran.dg/extends_13.f03: New. + 2011-05-29 Jakub Jelinek PR rtl-optimization/49095 diff --git a/gcc/testsuite/gfortran.dg/extends_13.f03 b/gcc/testsuite/gfortran.dg/extends_13.f03 new file mode 100644 index 00000000000..5d986877df2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/extends_13.f03 @@ -0,0 +1,30 @@ +! { dg-do compile } +! +! PR 47601: [OOP] Internal Error: mio_component_ref(): Component not found +! +! Contributed by Rich Townsend + +module type_definitions + implicit none + type :: matching + integer :: n = -999 + end type + type, extends(matching) :: ellipse + end type +end module type_definitions + +module elliptical_elements + implicit none +contains + function line(e) result(a2n) + use type_definitions + type(ellipse), intent(in) :: e + complex, dimension(e%N) :: a2n ! <- change "e%N" to "10" + end function line +end module + + use type_definitions + use elliptical_elements +end + +! { dg-final { cleanup-modules "type_definitions elliptical_elements" } } -- 2.30.2