| 1 |
!==================initialization_1.f90====================== |
| 2 |
|
| 3 |
! { dg-do compile } |
| 4 |
! Tests fix for PR25018 in which an ICE resulted from using a |
| 5 |
! variable in a parameter initialization expression. In the course |
| 6 |
! of developing the fix, various other constraints and limitations |
| 7 |
! were tested. |
| 8 |
! |
| 9 |
! Contributed by Paul Thomas <[email protected]> |
| 10 |
! |
| 11 |
module const |
| 12 |
! The next line is the original error |
| 13 |
real(8), parameter :: g = - sqrt(2._8) * Gf ! { dg-error "not been declared or is a variable" } |
| 14 |
contains |
| 15 |
subroutine foo(ch1, x, y) |
| 16 |
character(*) :: ch1 |
| 17 |
|
| 18 |
! This is OK because it is a restricted expression. |
| 19 |
character(len(ch1)) :: ch2 |
| 20 |
|
| 21 |
real(8) :: x (1:2, *) |
| 22 |
real(8) :: y (0:,:) |
| 23 |
integer :: i |
| 24 |
real :: z(2, 2) |
| 25 |
|
| 26 |
! However, this gives a warning because it is an initialization expression. |
| 27 |
integer :: l1 = len (ch1) ! { dg-error "Assumed or deferred character length variable" } |
| 28 |
|
| 29 |
! These are warnings because they are gfortran extensions. |
| 30 |
integer :: m3 = size (x, 1) ! { dg-error "Assumed size array" } |
| 31 |
integer :: m4(2) = shape (z) |
| 32 |
|
| 33 |
! This does not depend on non-constant properties. |
| 34 |
real(8) :: big = huge (x) |
| 35 |
|
| 36 |
end subroutine foo |
| 37 |
end module const |