aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/dec_parameter_2.f90
blob: 4586ff514ffae7b5d3fa0a17f9565ee33e85cb0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
! { dg-do run }
! { dg-options "-ffree-form -std=legacy" }
!
! Test DEC-style PARAMETER statements without parentheses in free form.
!

subroutine sub1(t, x, y)
  implicit real(8) (A-H,O-Z)
  parameter   (pi_1 = 3.141592654d0, f_1 = 3.d08)
  parameter    pi_2 = 3.141592654d0, f_2 = 3.d08 ! legacy PARAMETER
  ! Note that if the parameter statements above are matched
  ! incorrectly as assignments, the below specification
  ! statements will be considered out-of-order and we see
  ! 'unexpected specification statement'. A PARAMETER
  ! statement should still be a specification statement.

  real(8), intent(in) :: t
  real(8), intent(out) :: x, y

  real(8), volatile :: two
  two = 2.0d0
  x = two * pi_1 * f_1 * t
  y = two * pi_2 * f_2 * t
  return
end subroutine

subroutine sub2(t, x, y, z)
  implicit none
  real(8) :: pi_1, pi_2, f_1, f_2
           parameter   (pi_1 = 3.141592654d0, f_1 = 3.d08)
           parameter    pi_2 = 3.141592654d0, f_2 = 3.d08 ! legacy PARAMETER
  real(8), parameter :: pi_3 = 3.141592654d0, f_3 = 3.d08
  ! Ditto sub1

  real(8), intent(in) :: t
  real(8), intent(out) :: x, y, z

  real(8), volatile :: two
  two = 2.0d0
  x = two * pi_1 * f_1 * t
  y = two * pi_2 * f_2 * t
  z = two * pi_3 * f_3 * t
end subroutine

implicit none
real(8) :: x1, x2, y1, y2, z2
real(8), volatile :: t
t = 1.5e-6

call sub1(t, x1, y1)
call sub2(t, x2, y2, z2)

write(*,'(4D18.5)') t, x1, y1
write(*,'(4D18.5)') t, x2, y2, z2

if (x1 .ne. x2 .or. y1 .ne. y2 &
    .or. x1 .ne. y1 .or. x2 .ne. y2 &
    .or. y2 .ne. z2) then
  STOP 1
endif

end