Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / abstract01.f90
blob42db4b42eff896474dba5ecfae525ab0b2dcf890
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! C911 - abstract derived type can be used only when polymorphic
3 program test
4 type, abstract :: abstract
5 integer :: j
6 end type
7 type, extends(abstract) :: concrete
8 integer :: k
9 class(concrete), allocatable :: a(:)
10 end type
11 type(concrete) :: x(2)
12 call sub1(x(1)) ! ok
13 call sub2(x) ! ok
14 call sub1(x(1)%a(1)) ! ok
15 call sub2(x(1)%a) ! ok
16 !ERROR: Reference to object with abstract derived type 'abstract' must be polymorphic
17 call sub1(x(1)%abstract) ! bad
18 !ERROR: Reference to object with abstract derived type 'abstract' must be polymorphic
19 call sub2(x%abstract) ! bad
20 !ERROR: Reference to object with abstract derived type 'abstract' must be polymorphic
21 call sub1(x(1)%a(1)%abstract) ! bad
22 !ERROR: Reference to object with abstract derived type 'abstract' must be polymorphic
23 call sub2(x(1)%a%abstract) ! bad
24 contains
25 subroutine sub1(d)
26 class(abstract) d
27 end subroutine
28 subroutine sub2(d)
29 class(abstract) d(:)
30 end subroutine
31 end