[to-be-committed] [RISC-V] Use Zbkb for general 64 bit constants when profitable
[official-gcc.git] / gcc / testsuite / gfortran.dg / protected_5.f90
blob410dbdf9001ff62fdae9f6f8ac274c6e354dfaff
1 ! { dg-do compile }
2 ! { dg-shouldfail "Invalid Fortran 2003 code" }
3 ! { dg-options "-std=f2003" }
4 ! PR fortran/23994
6 ! Test PROTECTED attribute. Within the module everything is allowed.
7 ! Outside (use-associated): For pointers, their association status
8 ! may not be changed. For nonpointers, their value may not be changed.
10 ! Test of a invalid code
12 module good1
13 implicit none
14 integer :: a
15 integer :: b,c
16 protected :: c
17 equivalence (a,c) ! { dg-error "Either all or none of the objects in the EQUIVALENCE" }
18 end module good1
21 module bad1
22 implicit none
23 integer, protected :: a
24 integer :: b,c
25 protected :: c
26 equivalence (a,b) ! { dg-error "Either all or none of the objects in the EQUIVALENCE" }
27 end module bad1
29 module bad2
30 implicit none
31 integer, protected :: a
32 integer :: b,c,d
33 protected :: c
34 common /one/ a,b ! { dg-error "PROTECTED attribute conflicts with COMMON" }
35 common /two/ c,d ! { dg-error "PROTECTED attribute conflicts with COMMON" }
36 end module bad2
38 module good2
39 implicit none
40 type myT
41 integer :: j
42 integer, pointer :: p
43 real, allocatable, dimension(:) :: array
44 end type myT
45 type(myT), save :: t
46 protected :: t
47 end module good2
49 program main
50 use good2
51 implicit none
52 t%j = 15 ! { dg-error "variable definition context" }
53 nullify(t%p) ! { dg-error "pointer association context" }
54 allocate(t%array(15))! { dg-error "variable definition context" }
55 end program main