2012-04-16 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Apr 2012 08:48:11 +0000 (08:48 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 16 Apr 2012 08:48:11 +0000 (08:48 +0000)
PR fortran/52968
* class.c (gfc_build_class_symbol): Make sure the 'f2k_derived'
namespace is present.

2012-04-16  Janus Weil  <janus@gcc.gnu.org>

PR fortran/52968
* gfortran.dg/typebound_call_23.f03: New test case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186486 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/typebound_call_23.f03 [new file with mode: 0644]

index 4db00bb..18e17cd 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-16  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/52968
+       * class.c (gfc_build_class_symbol): Make sure the 'f2k_derived'
+       namespace is present.
+
 2012-04-15  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/51082
index a275136..c71aa4a 100644 (file)
@@ -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.  */
index 321adb3..9b35b60 100644 (file)
@@ -1,3 +1,8 @@
+2012-04-16  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/52968
+       * gfortran.dg/typebound_call_23.f03: New test case.
+
 2012-04-15  Jason Merrill  <jason@redhat.com>
 
        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 (file)
index 0000000..5baa261
--- /dev/null
@@ -0,0 +1,28 @@
+! { dg-do compile }
+!
+! PR 52968: [OOP] Call to type-bound procedure wrongly rejected
+!
+! Contributed by Reuben Budiardja <reubendb@gmail.com>
+
+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