Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

163 lines
3.2 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
integer :: y
procedure() :: a
procedure(real) :: b
call a ! OK - can be function or subroutine
!ERROR: Cannot call subroutine 'a' like a function
c = a()
!ERROR: Cannot call function 'b' like a subroutine
call b
!ERROR: Cannot call function 'y' like a subroutine
call y
call x
!ERROR: Cannot call subroutine 'x' like a function
z = x()
end
subroutine s
!ERROR: Cannot call function 'f' like a subroutine
call f
!ERROR: Cannot call subroutine 's' like a function
i = s()
contains
function f()
end
end
subroutine s2
! subroutine vs. function is determined by use
external :: a, b
call a()
!ERROR: Cannot call subroutine 'a' like a function
x = a()
x = b()
!ERROR: Cannot call function 'b' like a subroutine
call b()
end
subroutine s3
! subroutine vs. function is determined by use, even in internal subprograms
external :: a
procedure() :: b
contains
subroutine s3a()
x = a()
call b()
end
subroutine s3b()
!ERROR: Cannot call function 'a' like a subroutine
call a()
!ERROR: Cannot call subroutine 'b' like a function
x = b()
end
end
module m1
!Function vs subroutine in a module is resolved to a subroutine if
!no other information.
external :: exts, extf, extunk
procedure() :: procs, procf, procunk
contains
subroutine s
call exts()
call procs()
x = extf()
x = procf()
end
end
module m2
use m1
contains
subroutine test
call exts() ! ok
call procs() ! ok
call extunk() ! ok
call procunk() ! ok
x = extf() ! ok
x = procf() ! ok
!ERROR: Cannot call subroutine 'extunk' like a function
!ERROR: Function result characteristics are not known
x = extunk()
!ERROR: Cannot call subroutine 'procunk' like a function
!ERROR: Function result characteristics are not known
x = procunk()
end
end
module modulename
end
! Call to entity in global scope, even with IMPORT, NONE
subroutine s4
block
import, none
integer :: i
!ERROR: 'modulename' is not a callable procedure
call modulename()
end block
end
! Call to entity in global scope, even with IMPORT, NONE
subroutine s5
block
import, none
integer :: i
i = foo()
!ERROR: Cannot call function 'foo' like a subroutine
call foo()
end block
end
subroutine s6
call a6()
end
!ERROR: 'a6' was previously called as a subroutine
function a6()
a6 = 0.0
end
subroutine s7
x = a7()
end
!ERROR: 'a7' was previously called as a function
subroutine a7()
end
!OK: use of a8 and b8 is consistent
subroutine s8
call a8()
x = b8()
end
subroutine a8()
end
function b8()
b8 = 0.0
end
subroutine s9
type t
procedure(), nopass, pointer :: p1, p2
end type
type(t) x
!ERROR: Function result characteristics are not known
print *, x%p1()
call x%p2 ! ok
call x%p1 ! ok
!ERROR: Function result characteristics are not known
print *, x%p2()
end subroutine
subroutine s10
call a10
!ERROR: Actual argument for 'a=' may not be a procedure
print *, abs(a10)
end
subroutine s11
real, pointer :: p(:)
!ERROR: A NULL() pointer is not allowed for 'a=' intrinsic argument
print *, rank(null())
print *, rank(null(mold=p)) ! ok
end