| 1 |
! { dg-do compile } |
| 2 |
! |
| 3 |
! Tests the fix for PR25087, in which the following invalid code |
| 4 |
! was not detected. |
| 5 |
! |
| 6 |
! Contributed by Joost VandeVondele <[email protected]> |
| 7 |
! |
| 8 |
! Modified by Tobias Burnus to fix PR fortran/41235. |
| 9 |
! |
| 10 |
FUNCTION a() |
| 11 |
CHARACTER(len=10) :: a |
| 12 |
a = '' |
| 13 |
END FUNCTION a |
| 14 |
|
| 15 |
SUBROUTINE s(n) |
| 16 |
CHARACTER(LEN=n), EXTERNAL :: a ! { dg-error "declared with a constant character length" } |
| 17 |
CHARACTER(LEN=n), EXTERNAL :: d ! { dg-error "declared with a constant character length" } |
| 18 |
interface |
| 19 |
function b (m) ! This is OK |
| 20 |
integer :: m |
| 21 |
CHARACTER(LEN=m) :: b |
| 22 |
end function b |
| 23 |
function e (m) ! { dg-warning "Possible character length mismatch" } |
| 24 |
integer :: m |
| 25 |
CHARACTER(LEN=m) :: e |
| 26 |
end function e |
| 27 |
end interface |
| 28 |
write(6,*) a() |
| 29 |
write(6,*) b(n) |
| 30 |
write(6,*) c() |
| 31 |
write(6,*) d() |
| 32 |
write(6,*) e(n) |
| 33 |
contains |
| 34 |
function c () ! This is OK |
| 35 |
CHARACTER(LEN=n):: c |
| 36 |
c = "" |
| 37 |
end function c |
| 38 |
END SUBROUTINE s |
| 39 |
|
| 40 |
FUNCTION d() |
| 41 |
CHARACTER(len=99) :: d |
| 42 |
d = '' |
| 43 |
END FUNCTION d |
| 44 |
|
| 45 |
function e(k) ! { dg-warning "Possible character length mismatch" } |
| 46 |
integer :: k |
| 47 |
character(len=k+1-1) :: e |
| 48 |
e = '' |
| 49 |
end function e |