RISC-V: Regenerate opt urls.
[official-gcc.git] / gcc / testsuite / gfortran.dg / protected_6.f90
blobb386dcf5f1bcf39dcab6430cb5644f084f35e818
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 protmod
13 implicit none
14 integer, Protected :: a
15 integer, protected, target :: at
16 integer, protected, pointer :: ap
17 end module protmod
19 program main
20 use protmod
21 implicit none
22 a = 43 ! { dg-error "variable definition context" }
23 ap => null() ! { dg-error "pointer association context" }
24 nullify(ap) ! { dg-error "pointer association context" }
25 ap => & ! { dg-error "pointer association context" }
26 & at ! { dg-error "Pointer assignment target has PROTECTED attribute" }
27 ap = 3 ! OK
28 allocate(ap) ! { dg-error "pointer association context" }
29 ap = 73 ! OK
30 call increment(a,at) ! { dg-error "variable definition context" }
31 call pointer_assignments(ap) ! { dg-error "pointer association context" }
32 contains
33 subroutine increment(a1,a3)
34 integer, intent(inout) :: a1, a3
35 a1 = a1 + 1
36 a3 = a3 + 1
37 end subroutine increment
38 subroutine pointer_assignments(p)
39 integer, pointer,intent (inout) :: p
40 p => null()
41 end subroutine pointer_assignments
42 end program main
44 module prot2
45 implicit none
46 contains
47 subroutine bar
48 real, protected :: b ! { dg-error "only allowed in specification part of a module" }
49 end subroutine bar
50 end module prot2