xref: /llvm-project/flang/test/Semantics/resolve46.f90 (revision 1c91d9bdea3b6c38e8fbce46ec8181a9c0aa26f8)
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
2! C1030 - assignment of pointers to intrinsic procedures
3! C1515 - interface definition for procedure pointers
4! C1519 - initialization of pointers to intrinsic procedures
5program main
6  intrinsic :: cos ! a specific & generic intrinsic name
7  intrinsic :: alog10 ! a specific intrinsic name, not generic
8  intrinsic :: null ! a weird special case
9  intrinsic :: bessel_j0 ! generic intrinsic, not specific
10  intrinsic :: amin0
11  intrinsic :: mod
12  intrinsic :: llt
13  !ERROR: 'haltandcatchfire' is not a known intrinsic procedure
14  intrinsic :: haltandcatchfire
15
16  abstract interface
17     logical function chrcmp(a,b)
18       character(*), intent(in) :: a
19       character(*), intent(in) :: b
20     end function chrcmp
21  end interface
22
23  !PORTABILITY: Procedure pointer 'p' should not have an ELEMENTAL intrinsic as its interface
24  procedure(sin), pointer :: p => cos
25  !ERROR: Intrinsic procedure 'amin0' is not an unrestricted specific intrinsic permitted for use as the definition of the interface to procedure pointer 'q'
26  procedure(amin0), pointer :: q
27  !ERROR: Intrinsic procedure 'bessel_j0' is not an unrestricted specific intrinsic permitted for use as the definition of the interface to procedure pointer 'r'
28  procedure(bessel_j0), pointer :: r
29  !ERROR: Intrinsic procedure 'llt' is not an unrestricted specific intrinsic permitted for use as the initializer for procedure pointer 's'
30  procedure(chrcmp), pointer :: s => llt
31  !ERROR: Intrinsic procedure 'bessel_j0' is not an unrestricted specific intrinsic permitted for use as the initializer for procedure pointer 't'
32  !PORTABILITY: Procedure pointer 't' should not have an ELEMENTAL intrinsic as its interface
33  procedure(cos), pointer :: t => bessel_j0
34  procedure(chrcmp), pointer :: u
35  p => alog ! valid use of an unrestricted specific intrinsic
36  p => alog10 ! ditto, but already declared intrinsic
37  p => cos ! ditto, but also generic
38  p => tan ! a generic & an unrestricted specific, not already declared
39  !ERROR: Function pointer 'p' associated with incompatible function designator 'mod': function results have distinct types: REAL(4) vs INTEGER(4)
40  p => mod
41  !ERROR: Function pointer 'p' associated with incompatible function designator 'index': function results have distinct types: REAL(4) vs INTEGER(4)
42  p => index
43  !ERROR: 'bessel_j0' is not an unrestricted specific intrinsic procedure
44  p => bessel_j0
45  !ERROR: 'llt' is not an unrestricted specific intrinsic procedure
46  u => llt
47end program main
48