c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / inquiry_type_ref_3.f90
blob7c1bf43785c5e7732b730ee634c6955060aeb551
1 ! { dg-do compile }
3 ! Test the implementation of inquiry part references (PR40196):
4 ! Check errors on invalid code.
6 ! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
8 program main
9 type :: t
10 complex :: z
11 character(6) :: a
12 end type
13 character(4) :: a
14 character(:), allocatable :: b
15 real :: z
16 integer :: i
17 type(t) :: s
18 b = "abcdefg"
19 a%kind = 2 ! { dg-error "Assignment to a constant expression" }
20 b%len = 2 ! { dg-error "parameter inquiry" }
21 i = a%kind ! OK
22 i = b%len ! OK
23 print *, z%re ! { dg-error "must be applied to a COMPLEX expression" }
24 print *, z%im ! { dg-error "must be applied to a COMPLEX expression" }
25 i%re = 2.0 ! { dg-error "must be applied to a COMPLEX expression" }
26 print *, i%len ! { dg-error "must be applied to a CHARACTER expression" }
27 print *, s%kind ! { dg-error "is not a member" }
28 print *, s%z%kind ! OK
29 print *, s%a%len ! OK
30 end