2011-05-23 Tom de Vries <tom@codesourcery.com>
[official-gcc.git] / gcc / testsuite / gfortran.dg / print_fmt_5.f90
blobfb37d753971040ced3cd950709fd725074114bcf
1 ! { dg-do compile }
2 ! print_fmt_5.f90
3 ! Test of fix for PR28237 and the last bit of PR23420. See
4 ! below for the description of the problem.
6 program r
7 character(12) :: for = '(i5)', left = '(i', right = ')'
8 integer :: i, j
9 integer :: h(4) &
10 = (/1h(, 1hi, 1h5, 1h)/)! { dg-warning "HOLLERITH|Hollerith" }
11 namelist /mynml/ i
12 i = fact ()
14 ! All these are "legal" things to do; note however the warnings
15 ! for extensions or obsolete features!
17 print *, fact()
18 print 100, fact()
19 print '(i5)', fact()
20 print mynml ! { dg-warning "is an extension" }
21 do i = 1, 5
22 print trim(left)//char(iachar('0') + i)//trim(right), i
23 end do
24 assign 100 to i ! { dg-warning "ASSIGN statement" }
25 print i, fact() ! { dg-warning "ASSIGNED variable" }
26 print h, fact () ! { dg-warning "Non-character in FORMAT" }
28 ! These are not and caused a segfault in trans-io:560
30 ! PR28237
31 print fact() ! { dg-error "not an ASSIGNED variable" }
32 ! original PR23420
33 print precision(1.2_8) ! { dg-error "type default CHARACTER" }
34 ! PR23420 points 4 and 5
35 print j + j ! { dg-error "not an ASSIGNED variable" }
36 ! An extension of the above, encountered in writing the fix
37 write (*, fact())! { dg-error "not an ASSIGNED variable" }
38 100 format (i5)
39 contains
40 function fact()
41 integer :: fact
42 fact = 1
43 end function fact
44 end