74 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Tests attempts at forward references to local names in a FUNCTION prefix3 4! This case is not an error, but will elicit bogus errors if the5! result type of the function is badly resolved.6module m17 type t18 sequence9 integer not_m10 end type11 contains12 type(t1) function foo(n)13 integer, intent(in) :: n14 type t115 sequence16 integer m17 end type18 foo%m = n19 end function20end module21 22subroutine s123 use :: m1, only: foo24 type t125 sequence26 integer m27 end type28 type(t1) x29 x = foo(234)30 print *, x31end subroutine32 33module m234 integer, parameter :: k = kind(1.e0)35 contains36 real(kind=k) function foo(n)37 integer, parameter :: k = kind(1.d0)38 integer, intent(in) :: n39 foo = n40 end function41end module42 43subroutine s244 use :: m2, only: foo45 !If we got the type of foo right, this declaration will fail46 !due to an attempted division by zero.47 !WARNING: INTEGER(4) division by zero [-Wfolding-exception]48 !ERROR: Must be a constant value49 integer, parameter :: test = 1 / (kind(foo(1)) - kind(1.d0))50end subroutine51 52module m353 real(kind=kind(1.0e0)) :: x54 contains55 real(kind=kind(x)) function foo(x)56 real(kind=kind(1.0d0)) x57 !WARNING: INTEGER(4) division by zero [-Wfolding-exception]58 !ERROR: Must be a constant value59 integer, parameter :: test = 1 / (kind(foo) - kind(1.d0))60 foo = n61 end function62end module63 64module m465 contains66 real(n) function foo(x)67 !ERROR: 'foo' is not an object that can appear in an expression68 integer, parameter :: n = kind(foo)69 real(n), intent(in) :: x70 !ERROR: 'x' is not an object that can appear in an expression71 foo = x72 end function73end module74