| 1 |
! { dg-do compile } |
| 2 |
! Tests the fix for PR20880, which was due to failure to the failure |
| 3 |
! to detect the USE association of a nameless interface for a |
| 4 |
! procedure with the same name as the encompassing scope. |
| 5 |
! |
| 6 |
! Contributed by Joost VandeVondele <[email protected]> |
| 7 |
! |
| 8 |
! Modified for PR fortran/34657 |
| 9 |
! |
| 10 |
module test_mod |
| 11 |
interface |
| 12 |
subroutine my_sub (a) |
| 13 |
real a |
| 14 |
end subroutine |
| 15 |
end interface |
| 16 |
interface |
| 17 |
function my_fun (a) |
| 18 |
real a, my_fun |
| 19 |
end function |
| 20 |
end interface |
| 21 |
end module |
| 22 |
|
| 23 |
module test_mod2 |
| 24 |
interface |
| 25 |
function my_fun (a) |
| 26 |
real a, my_fun |
| 27 |
end function |
| 28 |
end interface |
| 29 |
end module |
| 30 |
|
| 31 |
|
| 32 |
! This is the original PR, excepting that the error requires the symbol |
| 33 |
! to be referenced. |
| 34 |
subroutine my_sub (a) |
| 35 |
use test_mod ! { dg-error "is also the name of the current program unit" } |
| 36 |
real a |
| 37 |
call my_sub (a) ! { dg-error "ambiguous reference" } |
| 38 |
print *, a |
| 39 |
end subroutine |
| 40 |
|
| 41 |
integer function my_fun (a) |
| 42 |
use test_mod ! { dg-error "is also the name of the current program unit" } |
| 43 |
real a |
| 44 |
print *, a |
| 45 |
my_fun = 1 ! { dg-error "ambiguous reference" } |
| 46 |
end function |
| 47 |
|
| 48 |
! This was found whilst investigating => segfault |
| 49 |
subroutine thy_sub (a) |
| 50 |
interface |
| 51 |
subroutine thy_sub (a) ! { dg-error "enclosing procedure" } |
| 52 |
real a |
| 53 |
end subroutine |
| 54 |
end interface |
| 55 |
real a |
| 56 |
print *, a |
| 57 |
end subroutine |
| 58 |
|
| 59 |
subroutine thy_fun (a) |
| 60 |
use test_mod |
| 61 |
use test_mod2 ! OK because there is no reference to my_fun |
| 62 |
print *, a |
| 63 |
end subroutine thy_fun |
| 64 |
|
| 65 |
subroutine his_fun (a) |
| 66 |
use test_mod |
| 67 |
use test_mod2 |
| 68 |
print *, my_fun (a) ! { dg-error "ambiguous reference" } |
| 69 |
end subroutine his_fun |