| 1 |
! { dg-do compile } |
| 2 |
! |
| 3 |
! PR39630: Fortran 2003: Procedure pointer components. |
| 4 |
! |
| 5 |
! Probing some error messages. |
| 6 |
! |
| 7 |
! Contributed by Janus Weil <[email protected]> |
| 8 |
|
| 9 |
implicit none |
| 10 |
|
| 11 |
interface |
| 12 |
subroutine sub |
| 13 |
end subroutine |
| 14 |
end interface |
| 15 |
|
| 16 |
external :: aaargh |
| 17 |
|
| 18 |
type :: t |
| 19 |
procedure(), pointer, nopass :: ptr1 |
| 20 |
procedure(real), pointer, nopass :: ptr2 |
| 21 |
procedure(sub), pointer, nopass :: ptr3 |
| 22 |
procedure(), pointer, nopass ptr4 ! { dg-error "Expected '::'" } |
| 23 |
procedure(), pointer, nopass, pointer :: ptr5 ! { dg-error "Duplicate" } |
| 24 |
procedure, pointer, nopass :: ptr6 ! { dg-error "Syntax error" } |
| 25 |
procedure(), nopass :: ptr8 ! { dg-error "POINTER attribute is required" } |
| 26 |
procedure(pp), pointer, nopass :: ptr9 ! { dg-error "declared in a later PROCEDURE statement" } |
| 27 |
real :: y |
| 28 |
end type t |
| 29 |
|
| 30 |
type :: t2 |
| 31 |
procedure(aaargh), pointer, nopass :: ptr10 ! { dg-error "must be explicit" } |
| 32 |
end type |
| 33 |
|
| 34 |
type,bind(c) :: bct ! { dg-error "BIND.C. derived type" } |
| 35 |
procedure(), pointer,nopass :: ptr ! { dg-error "cannot be a member of|may not be C interoperable" } |
| 36 |
end type bct |
| 37 |
|
| 38 |
procedure(sub), pointer :: pp |
| 39 |
|
| 40 |
type(t) :: x |
| 41 |
|
| 42 |
x%ptr2 => x ! { dg-error "Invalid procedure pointer assignment" } |
| 43 |
|
| 44 |
x => x%ptr2 ! { dg-error "Non-POINTER in pointer association context" } |
| 45 |
|
| 46 |
print *, x%ptr1() ! { dg-error "attribute conflicts with" } |
| 47 |
call x%ptr2() ! { dg-error "attribute conflicts with" } |
| 48 |
print *,x%ptr3() ! { dg-error "attribute conflicts with" } |
| 49 |
|
| 50 |
call x%y ! { dg-error "Expected type-bound procedure or procedure pointer component" } |
| 51 |
|
| 52 |
end |