re PR fortran/86408 (bogus error: ABSTRACT INTERFACE must not have an assumed charact...
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 5 Jul 2018 16:27:38 +0000 (16:27 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 5 Jul 2018 16:27:38 +0000 (16:27 +0000)
2018-07-05  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/86408
* resolve.c.c (resolve_contained_fntype): Reference to C418 is
in F2008 and not F2003.
(resolve_function): Ditto in error message. Also, exclude
deferred character length results from the error.

2018-07-05  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/86408
* gfortran.dg/deferred_character_20.f90: New test.

From-SVN: r262445

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/deferred_character_20.f90 [new file with mode: 0644]

index f810379aea5d1e6457beb1bcef8c804dc3120b1f..3134580fa5ab809a8cfd65787826dc4b9922a293 100644 (file)
@@ -1,3 +1,11 @@
+2018-07-05  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/86408
+       * resolve.c.c (resolve_contained_fntype): Reference to C418 is
+       in F2008 and not F2003.
+       (resolve_function): Ditto in error message. Also, exclude
+       deferred character length results from the error.
+
 2018-07-05  Fritz Reese  <fritzoreese@gmail.com>
 
        PR fortran/83183
index 2f5eebad5b59b508decba178d32a0338ea33f27e..9f88c26ee1a380da675b9542aa6dcc1e2cd97875 100644 (file)
@@ -601,7 +601,7 @@ resolve_contained_fntype (gfc_symbol *sym, gfc_namespace *ns)
        }
     }
 
-  /* Fortran 2003 Draft Standard, page 535, C418, on type-param-value
+  /* Fortran 2008 Draft Standard, page 535, C418, on type-param-value
      type, lists the only ways a character length value of * can be used:
      dummy arguments of procedures, named constants, function results and
      in allocate statements if the allocate_object is an assumed length dummy
@@ -3117,10 +3117,11 @@ resolve_function (gfc_expr *expr)
      cannot be an assumed length character (F2003: C418).  */
   if (sym && sym->attr.abstract && sym->attr.function
       && sym->result->ts.u.cl
-      && sym->result->ts.u.cl->length == NULL)
+      && sym->result->ts.u.cl->length == NULL
+      && !sym->result->ts.deferred)
     {
       gfc_error ("ABSTRACT INTERFACE %qs at %L must not have an assumed "
-                "character length result (F2003: C418)", sym->name,
+                "character length result (F2008: C418)", sym->name,
                 &sym->declared_at);
       return false;
     }
index a812b5082411fb61799900211356431bcbbec347..8496a38c291285e2e2c25057704f5c6a668a15e8 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-05  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/86408
+       * gfortran.dg/deferred_character_20.f90: New test.
+
 2018-07-05  Fritz Reese  <fritzoreese@gmail.com>
 
        PR fortran/83183
diff --git a/gcc/testsuite/gfortran.dg/deferred_character_20.f90 b/gcc/testsuite/gfortran.dg/deferred_character_20.f90
new file mode 100644 (file)
index 0000000..85e2a2c
--- /dev/null
@@ -0,0 +1,32 @@
+! { dg-do compile }
+!
+! Test the fix for PR86408.
+!
+! Contributed by Janus Weil  <janus@gcc.gnu.org>
+!
+module m
+
+   implicit none
+
+   type, abstract :: t
+   contains
+      procedure(ifc), deferred :: tbf
+      procedure :: tbs
+   end type
+
+   abstract interface
+      function ifc(x) result(str)
+         import :: t
+         class(t) :: x
+         character(len=:), allocatable :: str
+      end function
+   end interface
+
+contains
+
+   subroutine tbs(x)
+      class(t) :: x
+      print *, x%tbf()
+   end subroutine
+
+end