aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/namelist_77.f90
blob: 5cbfe3aad65a6e16ac9105bfc6a679ae56bd8485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
! { dg-do run }
!
! PR libfortran/51825 - Fortran runtime error: Cannot match namelist object name
! Test case derived from PR.

module local_mod

    type mytype1
        integer :: int1
    end type

    type mytype2
        integer :: n_x       
        integer :: n_px        
    end type

    type beam_init_struct
        character(16) :: chars(1) = ''                                  
        type (mytype1) dummy
        type (mytype2) grid(1)      
    end type

end module

program error_namelist

    use local_mod

    implicit none

    type (beam_init_struct) beam_init

    namelist / error_params / beam_init

    open (10, status='scratch')
    write (10, '(a)') "&error_params"
    write (10, '(a)') "  beam_init%chars(1)='JUNK'"
    write (10, '(a)') "  beam_init%grid(1)%n_x=3"
    write (10, '(a)') "  beam_init%grid(1)%n_px=2"
    write (10, '(a)') "/"
    rewind(10)
    read(10, nml=error_params)
    close (10)

    if (beam_init%chars(1) /= 'JUNK') call abort
    if (beam_init%grid(1)%n_x /= 3) call abort
    if (beam_init%grid(1)%n_px /= 2) call abort

end program