3 ! Test the most important constraints unlimited polymorphic entities
\r
5 ! Contributed by Paul Thomas <pault@gcc.gnu.org>
\r
6 ! and Tobias Burnus <burnus@gcc.gnu.org>
\r
8 CHARACTER(:), allocatable, target :: chr ! { dg-error "TODO: Deferred character length variable" }
\r
12 class(*), pointer :: u1, u2(:) ! { dg-error "cannot appear in COMMON" }
\r
16 allocate (u1) ! { dg-error "requires either a type-spec or SOURCE tag" }
\r
17 allocate (real :: u1)
\r
18 Allocate (u1, source = 1.0)
\r
21 u2 = [u1] ! { dg-error "shall not be unlimited polymorphic" }
\r
23 i = u2 ! { dg-error "Can\\'t convert CLASS\\(\\*\\)" }
\r
25 ! Repeats same_type_as_1.f03 for unlimited polymorphic u2
\r
26 flag = same_type_as (i, u2) ! { dg-error "cannot be of type INTEGER" }
\r
27 flag = extends_type_of (i, u2) ! { dg-error "cannot be of type INTEGER" }
\r
31 ! C717 (R735) If data-target is unlimited polymorphic,
\r
32 ! data-pointer-object shall be unlimited polymorphic, of a sequence
\r
33 ! derived type, or of a type with the BIND attribute.
\r
42 type(sq), target :: x
\r
43 class(*), pointer :: y
\r
44 integer, pointer :: tgt
\r
50 y => tgt ! This is OK, of course.
\r
51 tgt => y ! { dg-error "must be unlimited polymorphic" }
\r
53 select type (y) ! This is the correct way to accomplish the previous
\r
62 class(*), pointer, intent(in) :: tgt
\r
68 type(t), pointer :: ptr
\r
70 ptr => tgt ! C717 allows this.
\r
73 ! F03:C815 or F08:C839
\r
74 type is (t) ! { dg-error "shall not specify a sequence derived type" }
\r
75 ptr => tgt ! { dg-error "Expected TYPE IS" }
\r