Files
TheRock/compiler/amd-llvm/flang/test/Semantics/bind-c19.f90
T
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

118 lines
3.0 KiB
Fortran

! RUN: %python %S/test_errors.py %s %flang_fc1
! Check for C1807: A procedure defined in a submodule shall not have a
! binding label unless its interface is declared in the ancestor module.
module m1
implicit none
end module
! Submodule with BIND(C) procedures that have no interface in the ancestor
! module - these violate C1807.
submodule(m1) sm1
implicit none
contains
!ERROR: A procedure defined in a submodule shall not have a binding label unless its interface is declared in the ancestor module
subroutine sub1() bind(c)
end subroutine
!ERROR: A procedure defined in a submodule shall not have a binding label unless its interface is declared in the ancestor module
subroutine sub2() bind(c, name="my_sub2")
end subroutine
!ERROR: A procedure defined in a submodule shall not have a binding label unless its interface is declared in the ancestor module
function func1() bind(c)
use, intrinsic :: iso_c_binding, only: c_int
integer(c_int) :: func1
func1 = 0
end function
end submodule
! Valid: interfaces declared in ancestor module.
module m2
implicit none
interface
module subroutine sub3() bind(c, name="sub3")
end subroutine
module function func2() bind(c) result(res)
use, intrinsic :: iso_c_binding, only: c_int
integer(c_int) :: res
end function
end interface
end module
submodule(m2) sm2
implicit none
contains
module subroutine sub3() bind(c, name="sub3")
end subroutine
module function func2() bind(c) result(res)
use, intrinsic :: iso_c_binding, only: c_int
integer(c_int) :: res
res = 0
end function
end submodule
! Valid: BIND(C,NAME="") gives no binding label.
module m3
implicit none
end module
submodule(m3) sm3
implicit none
contains
subroutine sub4() bind(c, name="")
end subroutine
end submodule
! Valid: BIND(C,NAME=" ") gives no binding label (blanks are discarded).
module m4
implicit none
end module
submodule(m4) sm4
implicit none
contains
subroutine sub5() bind(c, name=" ")
end subroutine
end submodule
! Invalid: interface declared in a parent submodule, not the ancestor module.
! C1807 requires the interface be in the ancestor module.
module m5
implicit none
end module
submodule(m5) sm5parent
implicit none
interface
module subroutine sub6() bind(c, name="sub6")
end subroutine
end interface
end submodule
submodule(m5:sm5parent) sm5child
implicit none
contains
!ERROR: A procedure defined in a submodule shall not have a binding label unless its interface is declared in the ancestor module
module subroutine sub6() bind(c, name="sub6")
end subroutine
end submodule
! Valid: interface declared in the ancestor module, definition in a child
! submodule - C1807 is satisfied because the interface is in the module.
module m6
implicit none
interface
module subroutine sub7() bind(c, name="sub7")
end subroutine
end interface
end module
submodule(m6) sm6parent
end submodule
submodule(m6:sm6parent) sm6child
implicit none
contains
module subroutine sub7() bind(c, name="sub7")
end subroutine
end submodule