brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · 7f32eb1 Raw
123 lines · plain
1!RUN: rm -rf %t && mkdir -p %t2!RUN: %flang_fc1 -fsyntax-only -fhermetic-module-files -DSTEP=1 -J%t %s3!RUN: %flang_fc1 -fsyntax-only -DSTEP=2 -J%t %s4!RUN: not %flang_fc1 -fsyntax-only -pedantic -J%t %s 2>&1 | FileCheck %s5 6! Tests that a module captured in a hermetic module file is compatible when7! USE'd with a module of the same name USE'd directly.8 9#if STEP == 110module modfile71a11  ! not errors12  integer, parameter :: good_named_const = 12313  integer :: good_var = 114  type :: good_derived15    integer component16  end type17  procedure(), pointer :: good_proc_ptr18  generic :: gen => bad_subroutine19  ! bad, but okay if unused20  integer, parameter :: unused_bad_named_const = 12321  integer :: unused_bad_var = 122  type :: unused_bad_derived23    integer component24  end type25  procedure(), pointer :: unused_bad_proc_ptr26  ! errors27  integer, parameter :: bad_named_const = 12328  integer :: bad_var = 129  type :: bad_derived30    integer component31  end type32  procedure(), pointer :: bad_proc_ptr33 contains34  subroutine good_subroutine35  end36  subroutine unused_bad_subroutine(x)37    integer x38  end39  subroutine bad_subroutine(x)40    integer x41  end42end43 44module modfile71b45  use modfile71a ! capture hermetically46end47 48#elif STEP == 249module modfile71a50  ! not errors51  integer, parameter :: good_named_const = 12352  integer :: good_var = 153  type :: good_derived54    integer component55  end type56  procedure(), pointer :: good_proc_ptr57  generic :: gen => bad_subroutine58  ! bad, but okay if unused59  integer, parameter :: unused_bad_named_const = 66660  real :: unused_bad_var = 1.61  type :: unused_bad_derived62    real component63  end type64  real, pointer :: unused_bad_proc_ptr65  ! errors66  integer, parameter :: bad_named_const = 66667  real :: bad_var = 1.68  type :: bad_derived69    real component70  end type71  real, pointer :: bad_proc_ptr72 contains73  subroutine good_subroutine74  end75  subroutine unused_bad_subroutine(x)76    real x77  end78  subroutine bad_subroutine(x)79    real x80  end81end82 83#else84 85!CHECK: warning: 'bad_derived' is use-associated from 'bad_derived' in two distinct instances of module 'modfile71a'86!CHECK: warning: 'bad_named_const' is use-associated from 'bad_named_const' in two distinct instances of module 'modfile71a'87!CHECK: warning: 'bad_proc_ptr' is use-associated from 'bad_proc_ptr' in two distinct instances of module 'modfile71a'88!CHECK: warning: 'bad_subroutine' is use-associated from 'bad_subroutine' in two distinct instances of module 'modfile71a'89!CHECK: warning: 'bad_var' is use-associated from 'bad_var' in two distinct instances of module 'modfile71a'90!CHECK: warning: 'good_derived' is use-associated from 'good_derived' in two distinct instances of module 'modfile71a'91!CHECK: warning: 'good_named_const' is use-associated from 'good_named_const' in two distinct instances of module 'modfile71a'92!CHECK: warning: 'good_proc_ptr' is use-associated from 'good_proc_ptr' in two distinct instances of module 'modfile71a'93!CHECK: warning: 'good_subroutine' is use-associated from 'good_subroutine' in two distinct instances of module 'modfile71a'94!CHECK: warning: 'good_var' is use-associated from 'good_var' in two distinct instances of module 'modfile71a'95!CHECK: warning: 'unused_bad_derived' is use-associated from 'unused_bad_derived' in two distinct instances of module 'modfile71a'96!CHECK: warning: 'unused_bad_named_const' is use-associated from 'unused_bad_named_const' in two distinct instances of module 'modfile71a'97!CHECK: warning: 'unused_bad_proc_ptr' is use-associated from 'unused_bad_proc_ptr' in two distinct instances of module 'modfile71a'98!CHECK: warning: 'unused_bad_subroutine' is use-associated from 'unused_bad_subroutine' in two distinct instances of module 'modfile71a'99!CHECK: warning: 'unused_bad_var' is use-associated from 'unused_bad_var' in two distinct instances of module 'modfile71a'100!CHECK: error: Reference to 'bad_derived' is ambiguous101!CHECK: error: Reference to 'bad_named_const' is ambiguous102!CHECK: error: Reference to 'bad_var' is ambiguous103!CHECK: error: Reference to 'bad_proc_ptr' is ambiguous104!CHECK: error: Reference to 'bad_subroutine' is ambiguous105!CHECK-NOT: error:106!CHECK-NOT: warning:107 108program main109  use modfile71a110  use modfile71b111  type(good_derived) goodx112  type(bad_derived) badx113  print *, good_named_const114  good_var = 1115  good_proc_ptr => null()116  call good_subroutine117  print *, bad_named_const118  print *, bad_var119  bad_proc_ptr => null()120  call bad_subroutine(1)121end122#endif123