Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Fortran/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
add_subdirectory(hello)
add_subdirectory(assign-goto)
add_subdirectory(cray_pointers_2)
add_subdirectory(defined_io)
add_subdirectory(execute_command_line)
add_subdirectory(fcvs21_f95) # NIST Fortran Compiler Validation Suite
add_subdirectory(finalization)
Expand Down
3 changes: 3 additions & 0 deletions Fortran/UnitTests/defined_io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
llvm_singlesource()

file(COPY lit.local.cfg DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
2 changes: 2 additions & 0 deletions Fortran/UnitTests/defined_io/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.traditional_output = True
config.single_source = True
65 changes: 65 additions & 0 deletions Fortran/UnitTests/defined_io/llvm-project-issue-154979.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
! A verbatim copy of test case from https://github.com/llvm/llvm-project/issues/154979
module llvm_project_issue_154979_m
type base
real, allocatable :: data(:)
complex, allocatable :: cx(:)

contains

procedure :: readBaseFmtd
generic :: read(formatted) => readBaseFmtd
end type

contains

!! read in the array size before allocating dtv's components
subroutine readBaseFmtd (dtv, unit, iotype, v_list, iostat, iomsg)
class(base), intent(inout) :: dtv
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
integer, intent(out) :: iostat
character(*), intent(inout) :: iomsg

integer isize

read (unit, *, iostat = iostat, iomsg=iomsg) isize

if (allocated(dtv%data)) deallocate (dtv%data)

allocate (dtv%data(isize))

read (unit, *, iostat=iostat, iomsg=iomsg) dtv%data
read (unit, *, iostat = iostat, iomsg=iomsg) isize
if (allocated(dtv%cx)) deallocate (dtv%cx)

allocate (dtv%cx(isize))

read (unit, *, iostat=iostat, iomsg=iomsg) dtv%cx
end subroutine
end module

program llvm_project_issue_154979
use llvm_project_issue_154979_m
integer currentPos, ss

type(base) :: b1(2)


open (1, access='stream', form='formatted', decimal='Comma', status='scratch')

write (1, '(i4, 10(g15.7))', pos=1, decimal='Point') 10, (i*1.0, i=1, 10)

inquire (1, pos=currentPos)

write(1, *, pos=currentPos, decimal='point') 12, (cmplx(i*1.0, i*2.0), i=-12, -1)

write (1, *) 20, (i*1.22, i=1,20)
write (1, *, sign='plus') 22, (cmplx(i*1.1, i*2.2), i=-10,11)

allocate (b1(1)%cx(3), b1(2)%data(1000))
read (1, '(dp, dt, dc, dt)', pos=1) b1

print*, size(b1(1)%data)
print*, size(b1(1)%cx)
end program
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
10
12
exit 0