AArch64: correct constraint on Upl early clobber alternatives
[official-gcc.git] / gcc / testsuite / gfortran.dg / submodule_10.f08
blob373b11c9f96965adff58bcd34e70749cb7a8ff04
1 ! { dg-do compile }
2 ! { dg-require-visibility "" }
4 ! Checks that PRIVATE enities are visible to submodules.
6 ! Contributed by Salvatore Filippone  <salvatore.filippone@uniroma2.it>
8 module const_mod
9   integer, parameter  :: ndig=8
10   integer, parameter  :: ipk_ = selected_int_kind(ndig)
11   integer, parameter  :: longndig=12
12   integer, parameter  :: long_int_k_ = selected_int_kind(longndig)
13   integer, parameter  :: mpik_ = kind(1)
15   integer(ipk_), parameter, public :: success_=0
17 end module const_mod
20 module error_mod
21   use const_mod
23   integer(ipk_), parameter, public :: act_ret_=0
24   integer(ipk_), parameter, public :: act_print_=1
25   integer(ipk_), parameter, public :: act_abort_=2
27   integer(ipk_), parameter, public ::  no_err_ = 0
29   public error, errcomm, get_numerr, &
30        & error_handler, &
31        & ser_error_handler, par_error_handler
34   interface error_handler
35     module subroutine ser_error_handler(err_act)
36       integer(ipk_), intent(inout) ::  err_act
37     end subroutine ser_error_handler
38     module subroutine par_error_handler(ictxt,err_act)
39       integer(mpik_), intent(in) ::  ictxt
40       integer(ipk_), intent(in) ::  err_act
41     end subroutine par_error_handler
42   end interface
44   interface error
45     module subroutine serror()
46     end subroutine serror
47     module subroutine perror(ictxt,abrt)
48       integer(mpik_), intent(in) ::  ictxt
49       logical, intent(in), optional  :: abrt
50     end subroutine perror
51   end interface
54   interface error_print_stack
55     module subroutine par_error_print_stack(ictxt)
56       integer(mpik_), intent(in) ::  ictxt
57     end subroutine par_error_print_stack
58     module subroutine ser_error_print_stack()
59     end subroutine ser_error_print_stack
60   end interface
62   interface errcomm
63     module subroutine errcomm(ictxt, err)
64       integer(mpik_), intent(in)   :: ictxt
65       integer(ipk_), intent(inout):: err
66     end subroutine errcomm
67   end interface errcomm
70   private
72   type errstack_node
74     integer(ipk_) ::   err_code=0
75     character(len=20)        ::   routine=''
76     integer(ipk_),dimension(5)     ::   i_err_data=0
77     character(len=40)        ::   a_err_data=''
78     type(errstack_node), pointer :: next
80   end type errstack_node
83   type errstack
84     type(errstack_node), pointer :: top => null()
85     integer(ipk_) :: n_elems=0
86   end type errstack
89   type(errstack), save  :: error_stack
90   integer(ipk_), save   :: error_status    = no_err_
91   integer(ipk_), save   :: verbosity_level = 1
92   integer(ipk_), save   :: err_action      = act_abort_
93   integer(ipk_), save   :: debug_level     = 0, debug_unit, serial_debug_level=0
95 contains
96 end module error_mod
98 submodule (error_mod) error_impl_mod
99   use const_mod
100 contains
101   ! checks whether an error has occurred on one of the processes in the execution pool
102   subroutine errcomm(ictxt, err)
103     integer(mpik_), intent(in)   :: ictxt
104     integer(ipk_), intent(inout):: err
107   end subroutine errcomm
109   subroutine ser_error_handler(err_act)
110     implicit none
111     integer(ipk_), intent(inout) ::  err_act
113     if (err_act /= act_ret_)     &
114          &  call error()
115     if (err_act == act_abort_) stop
117     return
118   end subroutine ser_error_handler
120   subroutine par_error_handler(ictxt,err_act)
121     implicit none
122     integer(mpik_), intent(in) ::  ictxt
123     integer(ipk_), intent(in) ::  err_act
125     if (err_act == act_print_)     &
126          &  call error(ictxt, abrt=.false.)
127     if (err_act == act_abort_)      &
128          &  call error(ictxt, abrt=.true.)
130     return
132   end subroutine par_error_handler
134   subroutine par_error_print_stack(ictxt)
135     integer(mpik_), intent(in) ::  ictxt
137     call error(ictxt, abrt=.false.)
139   end subroutine par_error_print_stack
141   subroutine ser_error_print_stack()
143     call error()
144   end subroutine ser_error_print_stack
146   subroutine serror()
148     implicit none
150   end subroutine serror
152   subroutine perror(ictxt,abrt)
153     use const_mod
154     implicit none
155     integer(mpik_), intent(in) :: ictxt
156     logical, intent(in), optional  :: abrt
158   end subroutine perror
160 end submodule error_impl_mod
162 program testlk
163   use error_mod
164   implicit none
166   call error()
168   stop
169 end program testlk