Merge from mainline
[official-gcc.git] / gcc / testsuite / gfortran.dg / userdef_operator_1.f90
blob5bf99d04acda832ebfc374333aea28872c003019
1 ! { dg-do compile }
2 ! Testcase from PR 25396: User defined operators returning arrays.
3 module geometry
5 implicit none
7 interface operator(.cross.)
8 module procedure cross
9 end interface
11 contains
13 ! Cross product between two 3d vectors.
14 pure function cross(a, b)
15 real, dimension(3), intent(in) :: a,b
16 real, dimension(3) :: cross
18 cross = (/ a(2) * b(3) - a(3) * b(2), &
19 a(3) * b(1) - a(1) * b(3), &
20 a(1) * b(2) - a(2) * b(1) /)
21 end function cross
23 end module geometry
25 program opshape
26 use geometry
28 implicit none
30 real :: t(3,3), a
32 a = dot_product (t(:,1), t(:,2) .cross. t(:,3))
34 end program opshape