1! RUN: %S/test_errors.sh %s %t %flang_fc1
2! REQUIRES: shell
3! C703 (R702) The derived-type-spec shall not specify an abstract type (7.5.7).
4! This constraint refers to the derived-type-spec in a type-spec.  A type-spec
5! can appear in an ALLOCATE statement, an ac-spec for an array constructor, and
6! in the type specifier of a TYPE GUARD statement
7!
8! C706 TYPE(derived-type-spec) shall not specify an abstract type (7.5.7).
9!   This is for a declaration-type-spec
10!
11! C796 (R756) The derived-type-spec shall not specify an abstract type (7.5.7).
12!
13! C705 (R703) In a declaration-type-spec that uses the CLASS keyword,
14! derived-type-spec shall specify an extensible type (7.5.7).
15subroutine s()
16  type, abstract :: abstractType
17  end type abstractType
18
19  type, extends(abstractType) :: concreteType
20  end type concreteType
21
22  ! declaration-type-spec
23  !ERROR: ABSTRACT derived type may not be used here
24  type (abstractType), allocatable :: abstractVar
25
26  ! ac-spec for an array constructor
27  !ERROR: ABSTRACT derived type may not be used here
28  type (abstractType), parameter :: abstractArray(*) = (/ abstractType :: /)
29
30  class(*), allocatable :: selector
31
32  ! Structure constructor
33  !ERROR: ABSTRACT derived type may not be used here
34  !ERROR: ABSTRACT derived type 'abstracttype' may not be used in a structure constructor
35  type (abstractType) :: abstractVar1 = abstractType()
36
37  ! Allocate statement
38  !ERROR: ABSTRACT derived type may not be used here
39  allocate(abstractType :: abstractVar)
40
41  select type(selector)
42    ! Type specifier for a type guard statement
43    !ERROR: ABSTRACT derived type may not be used here
44    type is (abstractType)
45  end select
46end subroutine s
47
48subroutine s1()
49  type :: extensible
50  end type
51  type, bind(c) :: inextensible
52  end type
53
54  ! This one's OK
55  class(extensible), allocatable :: y
56
57  !ERROR: Non-extensible derived type 'inextensible' may not be used with CLASS keyword
58  class(inextensible), allocatable :: x
59end subroutine s1
60
61subroutine s2()
62  type t
63    integer i
64  end type t
65  type, extends(t) :: t2
66    real x
67  end type t2
68contains
69  function f1(dummy)
70    class(*) dummy
71    type(t) f1(1)
72    !ERROR: Cannot have an unlimited polymorphic value in an array constructor
73    f1 = [ (dummy) ]
74  end function f1
75end subroutine s2
76