From 42ff605a7b16220b75a640ff22a32f4acd62802e Mon Sep 17 00:00:00 2001 From: Janus Weil Date: Mon, 16 Apr 2012 10:48:11 +0200 Subject: [PATCH] re PR fortran/52968 ([OOP] Call to type-bound procedure wrongly rejected) 2012-04-16 Janus Weil PR fortran/52968 * class.c (gfc_build_class_symbol): Make sure the 'f2k_derived' namespace is present. 2012-04-16 Janus Weil PR fortran/52968 * gfortran.dg/typebound_call_23.f03: New test case. From-SVN: r186486 --- gcc/fortran/ChangeLog | 6 ++++ gcc/fortran/class.c | 5 +--- gcc/testsuite/ChangeLog | 5 ++++ .../gfortran.dg/typebound_call_23.f03 | 28 +++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/typebound_call_23.f03 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4db00bba59e..18e17cdabcb 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2012-04-16 Janus Weil + + PR fortran/52968 + * class.c (gfc_build_class_symbol): Make sure the 'f2k_derived' + namespace is present. + 2012-04-15 Janus Weil PR fortran/51082 diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c index a27513646c9..c71aa4a7c48 100644 --- a/gcc/fortran/class.c +++ b/gcc/fortran/class.c @@ -541,8 +541,7 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr, fclass->refs++; fclass->ts.type = BT_UNKNOWN; fclass->attr.abstract = ts->u.derived->attr.abstract; - if (ts->u.derived->f2k_derived) - fclass->f2k_derived = gfc_get_namespace (NULL, 0); + fclass->f2k_derived = gfc_get_namespace (NULL, 0); if (gfc_add_flavor (&fclass->attr, FL_DERIVED, NULL, &gfc_current_locus) == FAILURE) return FAILURE; @@ -579,8 +578,6 @@ gfc_build_class_symbol (gfc_typespec *ts, symbol_attribute *attr, c->attr.access = ACCESS_PRIVATE; c->attr.pointer = 1; } - else if (!fclass->f2k_derived) - fclass->f2k_derived = gfc_get_namespace (NULL, 0); /* Since the extension field is 8 bit wide, we can only have up to 255 extension levels. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 321adb379c4..9b35b60e1d7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-16 Janus Weil + + PR fortran/52968 + * gfortran.dg/typebound_call_23.f03: New test case. + 2012-04-15 Jason Merrill PR c++/47220 diff --git a/gcc/testsuite/gfortran.dg/typebound_call_23.f03 b/gcc/testsuite/gfortran.dg/typebound_call_23.f03 new file mode 100644 index 00000000000..5baa26179d4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_call_23.f03 @@ -0,0 +1,28 @@ +! { dg-do compile } +! +! PR 52968: [OOP] Call to type-bound procedure wrongly rejected +! +! Contributed by Reuben Budiardja + +module SolverModule + + type :: SolverType + class ( EquationTemplate ), pointer :: Equation + end type + + type :: EquationTemplate + contains + procedure, nopass :: Evaluate + end type + +contains + + subroutine Evaluate () + end subroutine + + subroutine Solve + type ( SolverType ) :: S + call S % Equation % Evaluate () + end subroutine + +end module -- 2.30.2