public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: PATCH ATTACHED Re: [PATCH, Fortran] PR78659 Spurious "requires DTIO" reported against namelist statement
@ 2017-05-13 11:56 Dominique d'Humières
  2017-05-13 16:31 ` Jerry DeLisle
  0 siblings, 1 reply; 4+ messages in thread
From: Dominique d'Humières @ 2017-05-13 11:56 UTC (permalink / raw)
  To: jvdelisle; +Cc: gfortran, gcc-patches

Dear Jerry,

> And the actual patch ...

Are you sure this the right patch? It seems mostly applied on trunk. 

TIA

Dominique

PS I saw some ‘return 1;’ which should probably ‘return true;’

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [PATCH, Fortran] PR78659 Spurious "requires DTIO" reported against namelist statement
@ 2017-05-11 15:35 Jerry DeLisle
  2017-05-11 15:46 ` PATCH ATTACHED " Jerry DeLisle
  0 siblings, 1 reply; 4+ messages in thread
From: Jerry DeLisle @ 2017-05-11 15:35 UTC (permalink / raw)
  To: fortran; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 1193 bytes --]

Hi all,

The attached patch fixes this issue by moving the DTIO namelist checks from 
namelist resolution to READ/WRITE statement resolution.  This allows the checks 
to be specific to the io_kind. The dtio_procs_present function is moved and 
modified to accept the io_kind as an argument and check for the specific DTIO 
procedure.

The original dtio_procs_present function also had a segfault for one of the test 
cases because in the particular case the accessed structures do not exist. This 
is prevented by adding the appropriate guarding to avoid memory accesses to 
never never land.

Several new test cases added.  Regression tested on x86-64.

OK for trunk.  I would like to recommend back porting to 7 after allowing some 
time for testing.

Regards,

Jerry

2017-05-11  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/78659
	* io.c (dtio_procs_present): Add new function to check for DTIO
	procedures relative to I/O statement READ or WRITE.
	(gfc_resolve_dt): Add namelist checks using the new function.
	* resolve.c (dtio_procs_present): Remove function and related
	namelist checks. (resolve_fl_namelist): Add check specific to
	Fortran 95 restriction on namelist objects.

[-- Attachment #2: namelist_91.f90 --]
[-- Type: text/x-fortran, Size: 195 bytes --]

! { dg-do compile }
! PR78659 Spurious "requires DTIO" reported against namelist statement
program p
   type t
     integer :: k
   end type
   class(t), allocatable :: x
   namelist /nml/ x
end

[-- Attachment #3: namelist_92.f90 --]
[-- Type: text/x-fortran, Size: 488 bytes --]

! { dg-do compile }
! PR78659 Spurious "requires DTIO" reported against namelist statement
MODULE ma
  IMPLICIT NONE
  TYPE :: ta
    INTEGER, allocatable :: array(:)
  END TYPE ta
END MODULE ma

PROGRAM p
  USE ma
  type(ta):: x
  NAMELIST /nml/ x
  WRITE (*, nml) ! { dg-error "has ALLOCATABLE or POINTER components and thus requires a defined input/output" }
  READ (*, nml) ! { dg-error "has ALLOCATABLE or POINTER components and thus requires a defined input/output" }
END PROGRAM p

[-- Attachment #4: namelist_93.f90 --]
[-- Type: text/x-fortran, Size: 466 bytes --]

! { dg-do compile }
! PR78659 Spurious "requires DTIO" reported against namelist statement
MODULE ma
  IMPLICIT NONE
  TYPE :: ta
    INTEGER, allocatable :: array(:)
  END TYPE ta
END MODULE ma

PROGRAM p
  USE ma
  class(ta), allocatable :: x
  NAMELIST /nml/ x
  WRITE (*, nml)! { dg-error "is polymorphic and requires a defined input/output procedure" }
  READ (*, nml) ! { dg-error "is polymorphic and requires a defined input/output procedure" }
END PROGRAM p

[-- Attachment #5: namelist_94.f90 --]
[-- Type: text/x-fortran, Size: 866 bytes --]

! { dg-do compile }
! PR78659 Spurious "requires DTIO" reported against namelist statement
MODULE m
  IMPLICIT NONE
  TYPE :: t
    CHARACTER :: c
  CONTAINS
    PROCEDURE :: write_formatted
    GENERIC :: WRITE(FORMATTED) => write_formatted
  END TYPE
CONTAINS
  SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg)
    CLASS(t), INTENT(IN) :: dtv
    INTEGER, INTENT(IN) :: unit
    CHARACTER(*), INTENT(IN) :: iotype
    INTEGER, INTENT(IN) :: v_list(:)
    INTEGER, INTENT(OUT) :: iostat
    CHARACTER(*), INTENT(INOUT) :: iomsg
    WRITE (unit, "(A)", IOSTAT=iostat, IOMSG=iomsg) dtv%c
    print *, "what"
  END SUBROUTINE
END MODULE

PROGRAM p
  USE m
  IMPLICIT NONE
  class(t), allocatable :: x
  NAMELIST /nml/ x
  x = t('a')
  WRITE (*, nml)
  READ (*, nml) ! { dg-error "is polymorphic and requires a defined input/output procedure" }
END

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-13 15:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-13 11:56 PATCH ATTACHED Re: [PATCH, Fortran] PR78659 Spurious "requires DTIO" reported against namelist statement Dominique d'Humières
2017-05-13 16:31 ` Jerry DeLisle
  -- strict thread matches above, loose matches on Subject: below --
2017-05-11 15:35 Jerry DeLisle
2017-05-11 15:46 ` PATCH ATTACHED " Jerry DeLisle
2017-05-11 17:23   ` Paul Richard Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).