File: resolve108.f90

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (73 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download | duplicates (17)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
! RUN: %python %S/test_errors.py %s %flang_fc1
! Tests attempts at forward references to local names in a FUNCTION prefix

! This case is not an error, but will elicit bogus errors if the
! result type of the function is badly resolved.
module m1
  type t1
    sequence
    integer not_m
  end type
 contains
  type(t1) function foo(n)
    integer, intent(in) :: n
    type t1
      sequence
      integer m
    end type
    foo%m = n
  end function
end module

subroutine s1
  use :: m1, only: foo
  type t1
    sequence
    integer m
  end type
  type(t1) x
  x = foo(234)
  print *, x
end subroutine

module m2
  integer, parameter :: k = kind(1.e0)
 contains
  real(kind=k) function foo(n)
    integer, parameter :: k = kind(1.d0)
    integer, intent(in) :: n
    foo = n
  end function
end module

subroutine s2
  use :: m2, only: foo
  !If we got the type of foo right, this declaration will fail
  !due to an attempted division by zero.
  !WARNING: INTEGER(4) division by zero
  !ERROR: Must be a constant value
  integer, parameter :: test = 1 / (kind(foo(1)) - kind(1.d0))
end subroutine

module m3
  real(kind=kind(1.0e0)) :: x
 contains
  real(kind=kind(x)) function foo(x)
    real(kind=kind(1.0d0)) x
    !WARNING: INTEGER(4) division by zero
    !ERROR: Must be a constant value
    integer, parameter :: test = 1 / (kind(foo) - kind(1.d0))
    foo = n
  end function
end module

module m4
 contains
  real(n) function foo(x)
    !ERROR: 'foo' is not an object that can appear in an expression
    integer, parameter :: n = kind(foo)
    real(n), intent(in) :: x
    !ERROR: 'x' is not an object that can appear in an expression
    foo = x
  end function
end module