Merge from mainline.
[official-gcc.git] / gcc / testsuite / gfortran.dg / equiv_constraint_2.f90
blobd721f967137deda435ae9b84f2b614c211574110
1 ! { dg-do compile }
2 ! { dg-options "-std=f95" }
4 ! PR20901 - Checks resolution of types in EQUIVALENCE statement when
5 ! f95 standard is imposed.
7 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
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
18 type (numeric_type) :: my_num, thy_num
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
29 type (numeric_type2) :: his_num
31 type :: char_type
32 sequence
33 character*4 :: ch
34 character*4 :: cha (6)
35 end type char_type
37 type (char_type) :: my_char
39 type :: mixed_type
40 sequence
41 integer :: i(4)
42 character*4 :: cha (6)
43 end type mixed_type
45 type (mixed_type) :: my_mixed, thy_mixed
47 character(len=4) :: ch
48 integer :: num
49 integer(kind=8) :: non_def
50 complex(kind=8) :: my_z, thy_z
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)
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