OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [gfortran.dg/] [userdef_operator_1.f90] - Blame information for rev 149

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
! { dg-do compile }
2
! Testcase from PR 25396: User defined operators returning arrays.
3
module geometry
4
 
5
  implicit none
6
 
7
  interface operator(.cross.)
8
     module procedure cross
9
  end interface
10
 
11
contains
12
 
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
17
 
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
22
 
23
end module geometry
24
 
25
program opshape
26
  use geometry
27
 
28
  implicit none
29
 
30
  real :: t(3,3), a
31
 
32
  a = dot_product (t(:,1), t(:,2) .cross. t(:,3))
33
 
34
end program opshape
35
 
36
! { dg-final { cleanup-modules "geometry" } }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.