| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-std=f95" } |
| 3 |
! |
| 4 |
! PR20901 - Checks resolution of types in EQUIVALENCE statement when |
| 5 |
! f95 standard is imposed. |
| 6 |
! |
| 7 |
! Contributed by Paul Thomas <[email protected]> |
| 8 |
! |
| 9 |
type :: numeric_type |
| 10 |
sequence |
| 11 |
integer :: i |
| 12 |
real :: x |
| 13 |
real(kind=8) :: d |
| 14 |
complex :: z |
| 15 |
logical :: l |
| 16 |
end type numeric_type |
| 17 |
|
| 18 |
type (numeric_type) :: my_num, thy_num |
| 19 |
|
| 20 |
type :: numeric_type2 |
| 21 |
sequence |
| 22 |
integer :: i |
| 23 |
real :: x |
| 24 |
real(kind=8) :: d |
| 25 |
complex :: z |
| 26 |
logical :: l |
| 27 |
end type numeric_type2 |
| 28 |
|
| 29 |
type (numeric_type2) :: his_num |
| 30 |
|
| 31 |
type :: char_type |
| 32 |
sequence |
| 33 |
character(4) :: ch |
| 34 |
character(4) :: cha (6) |
| 35 |
end type char_type |
| 36 |
|
| 37 |
type (char_type) :: my_char |
| 38 |
|
| 39 |
type :: mixed_type |
| 40 |
sequence |
| 41 |
integer :: i(4) |
| 42 |
character(4) :: cha (6) |
| 43 |
end type mixed_type |
| 44 |
|
| 45 |
type (mixed_type) :: my_mixed, thy_mixed |
| 46 |
|
| 47 |
character(len=4) :: ch |
| 48 |
integer :: num |
| 49 |
integer(kind=8) :: non_def |
| 50 |
complex(kind=8) :: my_z, thy_z |
| 51 |
|
| 52 |
! Permitted: character with character sequence |
| 53 |
! numeric with numeric sequence |
| 54 |
! numeric sequence with numeric sequence |
| 55 |
! non-default of same type |
| 56 |
! mixed sequences of same type |
| 57 |
equivalence (ch, my_char) |
| 58 |
equivalence (num, my_num) |
| 59 |
equivalence (my_num, his_num, thy_num) |
| 60 |
equivalence (my_z, thy_z) |
| 61 |
equivalence (my_mixed, thy_mixed) |
| 62 |
|
| 63 |
! Not permitted by the standard - OK with -std=gnu |
| 64 |
equivalence (my_mixed, my_num) ! { dg-error "with mixed components in EQUIVALENCE" } |
| 65 |
equivalence (my_z, num) ! { dg-error "Non-default type object or sequence" } |
| 66 |
equivalence (my_char, my_num) ! { dg-error "in default CHARACTER EQUIVALENCE" } |
| 67 |
equivalence (ch, my_num) ! { dg-error "in default CHARACTER EQUIVALENCE" } |
| 68 |
equivalence (my_num, ch) ! { dg-error "in default NUMERIC EQUIVALENCE" } |
| 69 |
equivalence (num, my_char) ! { dg-error "in default NUMERIC EQUIVALENCE" } |
| 70 |
equivalence (my_char, num) ! { dg-error "in default CHARACTER EQUIVALENCE" } |
| 71 |
equivalence (non_def, ch) ! { dg-error "Non-default type object or sequence" } |
| 72 |
equivalence (my_z, ch) ! { dg-error "Non-default type object or sequence" } |
| 73 |
equivalence (my_z, num) ! { dg-error "Non-default type object or sequence" } |
| 74 |
END |