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