interface_3.f90

来自「用于进行gcc测试」· F90 代码 · 共 70 行

F90
70
字号
! { dg-do compile }! Tests the fix for PR20880, which was due to failure to the failure! to detect the USE association of a nameless interface for a! procedure with the same name as the encompassing scope.!! Contributed by Joost VandeVondele  <jv244@cam.ac.uk>!module test_modinterface  subroutine my_sub (a)    real a  end subroutineend interfaceinterface  function my_fun (a)    real a, my_fun  end functionend interfaceend modulemodule test_mod2interface  function my_fun (a)    real a, my_fun  end functionend interfaceend module! This is the original PR, excepting that the error requires the symbol! to be referenced.subroutine my_sub (a)  use test_mod  real a  call my_sub (a)  ! { dg-error "ambiguous reference" }  print *, aend subroutineinteger function my_fun (a)  use test_mod  real a  print *, a  my_fun = 1  ! { dg-error "ambiguous reference" }end function! This was found whilst investigating => segfaultsubroutine thy_sub (a)  interface     subroutine thy_sub (a) ! { dg-error "enclosing procedure" }      real a    end subroutine  end interface  real a  print *, aend subroutinesubroutine thy_fun (a)  use test_mod  use test_mod2  ! OK because there is no reference to my_fun  print *, aend subroutine thy_funsubroutine his_fun (a)  use test_mod  use test_mod2  print *, my_fun (a)  ! { dg-error "ambiguous reference" }end subroutine his_fun! { dg-final { cleanup-modules "test_mod test_mod2" } }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?