From 7966c683c288bbbf9d3f1b92b7cd72a3c971b510 Mon Sep 17 00:00:00 2001 From: pault Date: Sat, 25 Mar 2017 17:38:17 +0000 Subject: [PATCH] 2017-03-25 Paul Thomas PR fortran/80156 PR fortran/79382 * decl.c (access_attr_decl): Remove the error for an absent generic DTIO interface and ensure that symbol has the flavor FL_PROCEDURE. 2017-03-25 Paul Thomas PR fortran/80156 PR fortran/79382 * gfortran.dg/dtio_23.f90 : Remove the dg-error and add the testcase for PR80156. Add a main programme that tests that the typebound generic is accessible. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@246476 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 8 +++++++ gcc/fortran/decl.c | 20 +++++----------- gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gfortran.dg/dtio_23.f90 | 43 +++++++++++++++++++++++++++++++++-- 4 files changed, 63 insertions(+), 16 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 344798d49a7..20ad8578bfa 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,11 @@ +2017-03-25 Paul Thomas + + PR fortran/80156 + PR fortran/79382 + * decl.c (access_attr_decl): Remove the error for an absent + generic DTIO interface and ensure that symbol has the flavor + FL_PROCEDURE. + 2017-03-22 Dominique d'Humieres PR fortran/79838 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index a04f5a66ec3..5ca664e57a5 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -7570,23 +7570,15 @@ access_attr_decl (gfc_statement st) case INTERFACE_GENERIC: case INTERFACE_DTIO: - if (type == INTERFACE_DTIO - && gfc_current_ns->proc_name - && gfc_current_ns->proc_name->attr.flavor == FL_MODULE) - { - gfc_find_symbol (name, gfc_current_ns, 0, &sym); - if (sym == NULL) - { - gfc_error ("The GENERIC DTIO INTERFACE at %C is not " - "present in the MODULE %qs", - gfc_current_ns->proc_name->name); - return MATCH_ERROR; - } - } - if (gfc_get_symbol (name, NULL, &sym)) goto done; + if (type == INTERFACE_DTIO + && gfc_current_ns->proc_name + && gfc_current_ns->proc_name->attr.flavor == FL_MODULE + && sym->attr.flavor == FL_UNKNOWN) + sym->attr.flavor = FL_PROCEDURE; + if (!gfc_add_access (&sym->attr, (st == ST_PUBLIC) ? ACCESS_PUBLIC : ACCESS_PRIVATE, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 36a082a305c..8306a1c0c35 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-03-25 Paul Thomas + + PR fortran/80156 + PR fortran/79382 + * gfortran.dg/dtio_23.f90 : Remove the dg-error and add the + testcase for PR80156. Add a main programme that tests that + the typebound generic is accessible. + 2017-03-25 Bernd Schmidt PR rtl-optimization/80160 diff --git a/gcc/testsuite/gfortran.dg/dtio_23.f90 b/gcc/testsuite/gfortran.dg/dtio_23.f90 index 4ebddbbe854..bee9acbd6b5 100644 --- a/gcc/testsuite/gfortran.dg/dtio_23.f90 +++ b/gcc/testsuite/gfortran.dg/dtio_23.f90 @@ -1,8 +1,9 @@ ! { dg-do compile } ! -! Test fix for the original in PR79832. +! Test fix for the original in PR793822 and for PR80156. ! ! Contributed by Walt Brainerd +! and (PR80156) ! module dollar_mod @@ -16,7 +17,7 @@ module dollar_mod generic :: write(formatted) => Write_dollar end type dollar_type - PRIVATE :: write (formatted) ! { dg-error "is not present" } + PRIVATE :: write (formatted) ! This used to ICE contains @@ -35,3 +36,41 @@ subroutine Write_dollar & end subroutine Write_dollar end module dollar_mod + +module pr80156 + + implicit none + private + + type, public :: String + character(len=:), allocatable :: raw + end type + + public :: write(unformatted) ! Gave an error due to the first fix for PR79382. + interface write(unformatted) + module procedure writeUnformatted + end interface + +contains + + subroutine writeUnformatted(self, unit, iostat, iomsg) + class(String) , intent(in) :: self + integer , intent(in) :: unit + integer , intent(out) :: iostat + character(len=*), intent(inout) :: iomsg + + if (allocated(self%raw)) then + write (unit, iostat=iostat, iomsg=iomsg) self%raw + else + write (unit, iostat=iostat, iomsg=iomsg) '' + endif + + end subroutine + +end module + + use dollar_mod + type(dollar_type) :: money + money = dollar_type(50.0) + print '(DT)', money ! Make sure that the typebound generic is accessible. +end -- 2.11.4.GIT