Hello,

my name is Alessandro, I'm a newbie of GCC and helped by Tobias Burnus
and Paul Thomas I'll try to add support for final subroutines.

The patch is bootstrapped and tested on x86_64-unknown-linux-gnu - gcc
version 4.8.0 20120506 (experimental)

Best regards.


------------------------------------------------gcc/fortran/ChangeLog------------------------------------------------

2012-05-06  Alessandro Fanfarillo  <fanfarillo....@gmail.com>
            Paul Thomas  <pa...@gcc.gnu.org>
            Tobias Burnus  <bur...@net-b.de>

        PR fortran/52158
        * resolve.c (resolve_fl_derived0): Add a new condition in the if
        statement of the deferred-length character component error block.
        * trans-expr (gfc_conv_procedure_call): Add new checks in the if
        statement on component's attributes (regarding PR 45170).

------------------------------------------------gcc/testsuite/ChangeLog------------------------------------------------

2012-05-06  Alessandro Fanfarillo  <fanfarillo....@gmail.com>
                  Damian Rouson  <dam...@rouson.net>

        PR fortran/45170
        * gfortran.dg/deferred_type_param_3.f90: New.

------------------------------------------------Patch.diff------------------------------------------------

--- gcc-4.8/gcc/fortran/resolve.c       2012-05-06 19:29:21.794825508 +0200
+++ gcc-4.8-patched/gcc/fortran/resolve.c       2012-05-06 19:24:40.770831649 
+0200
@@ -11666,7 +11666,7 @@
   for ( ; c != NULL; c = c->next)
     {
       /* See PRs 51550, 47545, 48654, 49050, 51075 - and 45170.  */
-      if (c->ts.type == BT_CHARACTER && c->ts.deferred)
+      if (c->ts.type == BT_CHARACTER && c->ts.deferred && !c->attr.function)
        {
          gfc_error ("Deferred-length character component '%s' at %L is not "
                     "yet supported", c->name, &c->loc);
diff -urN gcc-4.8/gcc/fortran/trans-expr.c
gcc-4.8-patched/gcc/fortran/trans-expr.c
--- gcc-4.8/gcc/fortran/trans-expr.c    2012-05-06 19:29:21.878825505 +0200
+++ gcc-4.8-patched/gcc/fortran/trans-expr.c    2012-05-06 19:25:53.134830069 
+0200
@@ -4175,7 +4175,9 @@
             we take the character length of the first argument for the result.
             For dummies, we have to look through the formal argument list for
             this function and use the character length found there.*/
-         if (ts.deferred && (sym->attr.allocatable || sym->attr.pointer))
+         if (ts.deferred && ((!comp && (sym->attr.allocatable
+              || sym->attr.pointer)) || (comp && (comp->attr.allocatable
+              || comp->attr.pointer))))
            cl.backend_decl = gfc_create_var (gfc_charlen_type_node, "slen");
          else if (!sym->attr.dummy)
            cl.backend_decl = VEC_index (tree, stringargs, 0);
diff -urN gcc-4.8/gcc/testsuite/gfortran.dg/deferred_type_param_3.f90
gcc-4.8-patched/gcc/testsuite/gfortran.dg/deferred_type_param_3.f90
--- gcc-4.8/gcc/testsuite/gfortran.dg/deferred_type_param_3.f90 1970-01-01
01:00:00.000000000 +0100
+++ gcc-4.8-patched/gcc/testsuite/gfortran.dg/deferred_type_param_3.f90 
2012-05-06
19:26:29.498829273 +0200
@@ -0,0 +1,21 @@
+! { dg-do compile }
+!
+! PR fortran/45170
+!
+! Contributed by Damian Rouson
+
+module speaker_class
+  type speaker
+  contains
+    procedure :: speak
+  end type
+contains
+  function speak(this)
+    class(speaker) ,intent(in) :: this
+    character(:) ,allocatable :: speak
+  end function
+  subroutine say_something(somebody)
+    class(speaker) :: somebody
+    print *,somebody%speak()
+  end subroutine
+end module

Reply via email to