OSDN Git Service

* gfortran.h (struct gfc_symbol): Add equiv_built.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.fortran-torture / execute / elemental.f90
1 ! Program to test elemental functions.
2 program test_elemental
3    implicit none
4    integer(kind = 4), dimension (2, 4) :: a
5    integer(kind = 4), dimension (2, 4) :: b
6    integer(kind = 8), dimension(2) :: c
7
8    a = reshape ((/2, 3, 4, 5, 6, 7, 8, 9/), (/2, 4/))
9    b = 0
10    b(2, :) = e_fn (a(1, :), 1)
11    if (any (b .ne. reshape ((/0, 1, 0, 3, 0, 5, 0, 7/), (/2, 4/)))) call abort
12    a = e_fn (a(:, 4:1:-1), 1 + b)
13    if (any (a .ne. reshape ((/7, 7, 5, 3, 3, -1, 1, -5/), (/2, 4/)))) call abort
14    ! This tests intrinsic elemental conversion functions.
15    c = 2 * a(1, 1)
16    if (any (c .ne. 14)) call abort
17
18    ! This triggered bug due to building ss chains in the wrong order.
19    b = 0;
20    a = a - e_fn (a, b)
21    if (any (a .ne. 0)) call abort
22
23    ! Check expressions involving constants
24    a = e_fn (b + 1, 1)
25    if (any (a .ne. 0)) call abort
26 contains
27
28 elemental integer function e_fn (p, q)
29    integer, intent(in) :: p, q
30    e_fn = p - q
31 end function
32 end program