Files
TheRock/compiler/amd-llvm/flang/test/Semantics/modfile71.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

123 lines
4.4 KiB
Fortran

!RUN: rm -rf %t && mkdir -p %t
!RUN: %flang_fc1 -fsyntax-only -fhermetic-module-files -DSTEP=1 -J%t %s
!RUN: %flang_fc1 -fsyntax-only -DSTEP=2 -J%t %s
!RUN: not %flang_fc1 -fsyntax-only -pedantic -J%t %s 2>&1 | FileCheck %s
! Tests that a module captured in a hermetic module file is compatible when
! USE'd with a module of the same name USE'd directly.
#if STEP == 1
module modfile71a
! not errors
integer, parameter :: good_named_const = 123
integer :: good_var = 1
type :: good_derived
integer component
end type
procedure(), pointer :: good_proc_ptr
generic :: gen => bad_subroutine
! bad, but okay if unused
integer, parameter :: unused_bad_named_const = 123
integer :: unused_bad_var = 1
type :: unused_bad_derived
integer component
end type
procedure(), pointer :: unused_bad_proc_ptr
! errors
integer, parameter :: bad_named_const = 123
integer :: bad_var = 1
type :: bad_derived
integer component
end type
procedure(), pointer :: bad_proc_ptr
contains
subroutine good_subroutine
end
subroutine unused_bad_subroutine(x)
integer x
end
subroutine bad_subroutine(x)
integer x
end
end
module modfile71b
use modfile71a ! capture hermetically
end
#elif STEP == 2
module modfile71a
! not errors
integer, parameter :: good_named_const = 123
integer :: good_var = 1
type :: good_derived
integer component
end type
procedure(), pointer :: good_proc_ptr
generic :: gen => bad_subroutine
! bad, but okay if unused
integer, parameter :: unused_bad_named_const = 666
real :: unused_bad_var = 1.
type :: unused_bad_derived
real component
end type
real, pointer :: unused_bad_proc_ptr
! errors
integer, parameter :: bad_named_const = 666
real :: bad_var = 1.
type :: bad_derived
real component
end type
real, pointer :: bad_proc_ptr
contains
subroutine good_subroutine
end
subroutine unused_bad_subroutine(x)
real x
end
subroutine bad_subroutine(x)
real x
end
end
#else
!CHECK: warning: 'bad_derived' is use-associated from 'bad_derived' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_named_const' is use-associated from 'bad_named_const' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_proc_ptr' is use-associated from 'bad_proc_ptr' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_subroutine' is use-associated from 'bad_subroutine' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'bad_var' is use-associated from 'bad_var' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_derived' is use-associated from 'good_derived' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_named_const' is use-associated from 'good_named_const' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_proc_ptr' is use-associated from 'good_proc_ptr' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_subroutine' is use-associated from 'good_subroutine' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'good_var' is use-associated from 'good_var' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_derived' is use-associated from 'unused_bad_derived' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_named_const' is use-associated from 'unused_bad_named_const' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_proc_ptr' is use-associated from 'unused_bad_proc_ptr' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_subroutine' is use-associated from 'unused_bad_subroutine' in two distinct instances of module 'modfile71a'
!CHECK: warning: 'unused_bad_var' is use-associated from 'unused_bad_var' in two distinct instances of module 'modfile71a'
!CHECK: error: Reference to 'bad_derived' is ambiguous
!CHECK: error: Reference to 'bad_named_const' is ambiguous
!CHECK: error: Reference to 'bad_var' is ambiguous
!CHECK: error: Reference to 'bad_proc_ptr' is ambiguous
!CHECK: error: Reference to 'bad_subroutine' is ambiguous
!CHECK-NOT: error:
!CHECK-NOT: warning:
program main
use modfile71a
use modfile71b
type(good_derived) goodx
type(bad_derived) badx
print *, good_named_const
good_var = 1
good_proc_ptr => null()
call good_subroutine
print *, bad_named_const
print *, bad_var
bad_proc_ptr => null()
call bad_subroutine(1)
end
#endif