From 99d2293dbfa03ddc5b0308858412ddded4c832a8 Mon Sep 17 00:00:00 2001 From: Paul Thomas Date: Thu, 5 Jul 2018 16:27:38 +0000 Subject: [PATCH] re PR fortran/86408 (bogus error: ABSTRACT INTERFACE must not have an assumed character length result (F2003: C418)) 2018-07-05 Paul Thomas 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 PR fortran/86408 * gfortran.dg/deferred_character_20.f90: New test. From-SVN: r262445 --- gcc/fortran/ChangeLog | 8 +++++ gcc/fortran/resolve.c | 7 ++-- gcc/testsuite/ChangeLog | 5 +++ .../gfortran.dg/deferred_character_20.f90 | 32 +++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/deferred_character_20.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f810379aea5..3134580fa5a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2018-07-05 Paul Thomas + + 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 PR fortran/83183 diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2f5eebad5b5..9f88c26ee1a 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a812b508241..8496a38c291 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-07-05 Paul Thomas + + PR fortran/86408 + * gfortran.dg/deferred_character_20.f90: New test. + 2018-07-05 Fritz Reese 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 index 00000000000..85e2a2ca6c4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/deferred_character_20.f90 @@ -0,0 +1,32 @@ +! { dg-do compile } +! +! Test the fix for PR86408. +! +! Contributed by Janus Weil +! +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 -- 2.30.2