Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / fmt_cache_2.f
blobf557a166c87660376f2c01bdbfcfa2bc42fcc1a2
1 ! { dg-do run }
2 ! PR42742 Handle very large format strings correctly
3 ! Test derived from example developed by Manfred Schwarb.
4 character(12) bufarr(74)
5 character(74*13+30) fmtstr,fmtstr2
6 character(1) delim
7 integer i,j,dat(5),pindx, loopcounter
8 character(983) big_string ! any less and this test fails.
10 do i=1,74
11 write(bufarr(i),'(i12)') i
12 enddo
14 delim=" "
15 dat(1)=2009
16 dat(2)=10
17 dat(3)=31
18 dat(4)=3
19 dat(5)=0
20 fmtstr="(i2,i6,4(a1,i2.2)"
21 open(10, status="scratch")
22 do j=1,74
23 fmtstr=fmtstr(1:len_trim(fmtstr))//",a1,a12"
24 fmtstr2=fmtstr(1:len_trim(fmtstr))//")"
25 c write(0,*) "interation ",j,": ",len_trim(fmtstr2)
26 do i=1,10
27 write(10,fmtstr2)
28 & i,dat(1),"-",dat(2),"-",dat(3),
29 & delim,dat(4),":",dat(5),
30 & (delim,bufarr(pindx),pindx=1,j)
31 enddo
32 loopcounter = j
33 enddo
34 close(10)
35 if (loopcounter /= 74) call abort
36 end