OSDN Git Service

fortran/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / import2.f90
1 ! { dg-do compile }
2 ! { dg-options "-std=f95" }
3 ! { dg-shouldfail "Fortran 2003 feature with -std=f95" }
4 ! Test whether import does not work with -std=f95
5 ! PR fortran/29601
6
7 subroutine test(x)
8   type myType3
9     sequence
10     integer :: i
11   end type myType3
12   type(myType3) :: x
13   if(x%i /= 7) call abort()
14   x%i = 1
15 end subroutine test
16
17
18 subroutine bar(x)
19   type myType
20     sequence
21     integer :: i
22   end type myType
23   type(myType) :: x
24   if(x%i /= 2) call abort()
25   x%i = 5
26 end subroutine bar
27
28
29 program foo
30   type myType
31     sequence
32     integer :: i
33   end type myType
34   type myType3
35     sequence
36     integer :: i
37   end type myType3
38   interface
39     subroutine bar(x)
40       import ! { dg-error "Fortran 2003: IMPORT statement" }
41       type(myType) :: x ! { dg-error "not been declared within the interface" }
42     end subroutine bar
43     subroutine test(x)
44       import :: myType3 ! { dg-error "Fortran 2003: IMPORT statement" }
45       import myType3 ! { dg-error "Fortran 2003: IMPORT statement" }
46       type(myType3) :: x ! { dg-error "not been declared within the interface" }
47     end subroutine test
48   end interface
49
50   type(myType) :: y
51   type(myType3) :: z
52   y%i = 2
53   call bar(y) ! { dg-error "Type/rank mismatch in argument" }
54   if(y%i /= 5) call abort()
55   z%i = 7
56   call test(z) ! { dg-error "Type/rank mismatch in argument" }
57   if(z%i /= 1) call abort()
58 end program foo