xref: /llvm-project/flang/test/Semantics/resolve73.f90 (revision 41a964cff0068ba417d355b499f10ecedd4a4636)
1! RUN: %python %S/test_errors.py %s %flang_fc1
2! C721 A type-param-value of * shall be used only
3! * to declare a dummy argument,
4! * to declare a named constant,
5! * in the type-spec of an ALLOCATE statement wherein each allocate-object is
6!   a dummy argument of type CHARACTER with an assumed character length,
7! * in the type-spec or derived-type-spec of a type guard statement (11.1.11),
8!   or
9! * in an external function, to declare the character length parameter of the function result.
10! Note also C795 for derived types (C721 applies to intrinsic types)
11subroutine s(arg)
12  character(len=*), pointer :: arg
13  character*(*), parameter  :: cvar1 = "abc"
14  character*4,  cvar2
15  character(len=4_4) :: cvar3
16  !ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
17  character(len=*) :: cvar4
18
19  type derived(param)
20    integer, len :: param
21    class(*), allocatable :: x
22  end type
23  type(derived(34)) :: a
24  interface
25    function fun()
26      character(len=4) :: fun
27    end function fun
28  end interface
29
30  type t(len)
31    integer, len :: len
32  end type
33  !ERROR: An assumed (*) type parameter may be used only for a (non-statement function) dummy argument, associate name, character named constant, or external function result
34  type(t(*)), parameter :: p2 = t(123)() ! C795
35
36  select type (ax => a%x)
37    type is (integer)
38      print *, "hello"
39    type is (character(len=*))
40      print *, "hello"
41    class is (derived(param=*))
42      print *, "hello"
43    class default
44      print *, "hello"
45  end select
46
47  allocate (character(len=*) :: arg)
48end subroutine s
49