2 ! PR33672 Additional runtime checks needed for namelist reads
3 ! Submitted by Jerry DeLisle <jvdelisle@gcc.gnu.org>
7 character(len
=2) :: ch(2) = (/"aa","bb"/)
10 integer :: i(2) = (/1,2/)
18 character(40) :: teststring
21 teststring
= " x(2)%m%ch(:)(2:2) = 'z','z',"
22 call writenml (teststring
)
23 teststring
= " x(2)%m(2)%ch(:)(2) = 'z','z',"
24 call writenml (teststring
)
25 teststring
= " x(2)%m(2)%ch(:)(:3) = 'z','z',"
26 call writenml (teststring
)
27 teststring
= " x(2)%m(2)%ch(1:2)(k:) = 'z','z',"
28 call writenml (teststring
)
32 subroutine writenml (astring
)
33 character(40), intent(in
) :: astring
34 character(300) :: errmessage
37 open (10, status
="scratch", delim
='apostrophe')
38 write (10, '(A)') "&MYNML"
39 write (10, '(A)') astring
42 read (10, nml
= mynml
, iostat
=ierror
, iomsg
=errmessage
)
43 if (ierror
== 0) call abort
44 print '(a)', trim(errmessage
)
47 end subroutine writenml
49 end program namelist_40
50 ! { dg-output "Multiple sub-objects with non-zero rank in namelist object x%m%ch(\n|\r\n|\r)" }
51 ! { dg-output "Missing colon in substring qualifier for namelist variable x%m%ch(\n|\r\n|\r)" }
52 ! { dg-output "Substring out of range for namelist variable x%m%ch(\n|\r\n|\r)" }
53 ! { dg-output "Bad character in substring qualifier for namelist variable x%m%ch(\n|\r\n|\r)" }