Debian Codegraph @

gcc/testsuite/gfortran.dg/c-interop/c407c-1.f90

raw
1 ! PR101333
2 ! { dg-do compile }
3 !
4 ! TS 29113
5 ! C407c An assumed-type actual argument that corresponds to an
6 ! assumed-rank dummy argument shall be assumed-shape or assumed-rank.
7 !
8 ! This constraint is renumbered C711 in the 2018 Fortran standard.
9
10 module m
11 interface
12 subroutine g (a, b)
13 implicit none
14 type(*) :: a(..)
15 integer :: b
16 end subroutine
17 end interface
18 end module
19
20 ! Check that assumed-shape works.
21
22 subroutine s0 (x)
23 use m
24 implicit none
25 type(*) :: x(:)
26
27 call g (x, 1)
28 end subroutine
29
30 ! Check that assumed-rank works.
31
32 subroutine s1 (x)
33 use m
34 implicit none
35 type(*) :: x(..)
36
37 call g (x, 1)
38 end subroutine
39
40 ! Check that assumed-size gives an error.
41
42 subroutine s2 (x)
43 use m
44 implicit none
45 type(*) :: x(*)
46
47 call g (x, 1) ! { dg-error "Assumed-type actual argument at .1. corresponding to assumed-rank dummy argument 'a' must be assumed-shape or assumed-rank" }
48 end subroutine
49
50 ! Check that a scalar gives an error.
51 subroutine s3 (x)
52 use m
53 implicit none
54 type(*) :: x
55
56 call g (x, 1) ! { dg-error "Assumed.type" }
57 end subroutine
58
59 ! Explicit-shape assumed-type actual arguments are forbidden implicitly
60 ! by c407a (C709 in the 2018 standard). They're not allowed as dummy
61 ! arguments, and assumed-type entities can only be declared as dummy
62 ! arguments, so there is no other way to construct one to pass as an
63 ! actual argument.