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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [optional_absent_2.f90] - Blame information for rev 694

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 694 jeremybenn
! { dg-do run }
2
!
3
! PR fortran/51758
4
!
5
! Contributed by Mikael Morin
6
!
7
! Check whether passing NULL() to an elemental procedure works,
8
! where NULL() denotes an absent optional argument.
9
!
10
program p
11
 
12
  integer :: a(2)
13
  integer :: b
14
 
15
  a = 0
16
  a = foo((/ 1, 1 /), null())
17
!  print *, a
18
  if (any(a /= 2)) call abort
19
 
20
  a = 0
21
  a = bar((/ 1, 1 /), null())
22
!  print *, a
23
  if (any(a /= 2)) call abort
24
 
25
  b = 0
26
  b = bar(1, null())
27
!  print *, b
28
  if (b /= 2) call abort
29
 
30
contains
31
 
32
  function foo(a, b)
33
    integer           :: a(:)
34
    integer, optional :: b(:)
35
    integer           :: foo(size(a))
36
 
37
    if (present(b)) call abort
38
 
39
    foo = 2
40
  end function foo
41
 
42
  elemental function bar(a, b)
43
    integer, intent(in)           :: a
44
    integer, intent(in), optional :: b
45
    integer                       :: bar
46
 
47
    bar = 2
48
 
49
    if (present(b)) bar = 1
50
 
51
  end function bar
52
 
53
end program p

powered by: WebSVN 2.1.0

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