2 ! { dg-shouldfail "Invalid Fortran 2003 code" }
3 ! { dg-options "-std=f2003 -fall-intrinsics" }
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
16 integer, pointer :: ap
17 protected
:: a
, at
, ap
25 protected
:: j
! { dg-error "only allowed in specification part of a module" }
26 a
= 43 ! { dg-error "variable definition context" }
27 ap
=> null() ! { dg-error "pointer association context" }
28 nullify(ap
) ! { dg-error "pointer association context" }
29 ap
=> at
! { dg-error "pointer association context" }
31 allocate(ap
) ! { dg-error "pointer association context" }
33 call increment(a
,at
) ! { dg-error "variable definition context" }
34 call pointer_assignments(ap
) ! { dg-error "pointer association context" }
35 asgnd
= pointer_check(ap
)
37 subroutine increment(a1
,a3
)
38 integer, intent(inout
) :: a1
, a3
41 end subroutine increment
42 subroutine pointer_assignments(p
)
43 integer, pointer,intent(out
) :: p
45 end subroutine pointer_assignments
46 function pointer_check(p
)
47 integer, pointer,intent(in
) :: p
48 logical :: pointer_check
49 pointer_check
= associated(p
)
50 end function pointer_check
55 protected
:: test
! { dg-error "MODULE attribute conflicts with PROTECTED" }