This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] assumed-rank some bound intrinsics support, fix failures and improve diagnostcs


On 26/07/2012 17:32, Tobias Burnus wrote:
> On 07/26/2012 05:12 PM, Mikael Morin wrote:
>> On 26/07/2012 16:53, Mikael Morin wrote:
>>> Here is a draft for those. Lightly tested with print *, ... 
> 
> Looks rather nice. The output for test1 is also  good:
> 
>   integer :: a(1:3,-2:5)
> gives
>   lbound(arg) == [1, 1]
>   ubound(arg) == [3, 8]
>   shape(arg) == [3, 8]
> 
> However, if the dummy is allocatable or a pointer, the result should be:
> 
>   lbound(arg) == [1, -2]
>   ubound(arg) == [3, 5]
>   shape(arg) == [3, 8]
> 
> which your second test case doesn't give.

Hello,

do you have a test case exhibiting the problem?
It seems fine to me.

$ ./test1
           1           1
           3           8
           3           8
           1           1
           3           8
           3           8
           1          -2
           3           5
           3           8
           1          -2
           3           5
           3           8

./test2
          11         101
          13         108
           3           8
          11          97
          12         106
           2          10
          13          99
          15         110
           3          12




program test

  integer :: a(1:3,-2:5)
  integer, allocatable :: b(:,:)

  call foo(a)

  allocate(b(1:3,-2:5))
  call foo(b)
  call bar(b)
  call baz(b)

contains
  subroutine foo(arg)
    integer :: arg(..)

    print *, lbound(arg)
    print *, ubound(arg)
    print *, shape(arg)
  end subroutine foo
  subroutine bar(arg)
    integer, allocatable :: arg(:,:)

    print *, lbound(arg)
    print *, ubound(arg)
    print *, shape(arg)
  end subroutine bar
  subroutine baz(arg)
    integer, allocatable :: arg(..)

    print *, lbound(arg)
    print *, ubound(arg)
    print *, shape(arg)
  end subroutine baz
end program test

program test

  integer              :: a(1:3,-2:5)
  integer, allocatable :: b(:,:)
  integer, allocatable :: c(:,:)
  integer, pointer     :: d(:,:)

  b = foo(a)
  print *,b(:,1)
  print *,b(:,2)
  print *,b(:,3)

  allocate(c(1:2,-3:6))
  b = bar(c)
  print *,b(:,1)
  print *,b(:,2)
  print *,b(:,3)

  allocate(d(3:5,-1:10))
  b = baz(d)
  print *,b(:,1)
  print *,b(:,2)
  print *,b(:,3)

contains
  function foo(arg) result(res)
    integer :: arg(..)
    integer, allocatable :: res(:,:)

    allocate(res(rank(arg), 3))
    
    res(:,1) = lbound(arg) + (/ 10, 100 /)
    res(:,2) = (/ 10, 100 /) + ubound(arg) 
    res(:,3) = shape(arg)

  end function foo
  function bar(arg) result(res)
    integer, allocatable :: arg(..)
    integer, allocatable :: res(:,:)

    allocate(res(rank(arg), 3))
    
    res(:,1) = lbound(arg) + (/ 10, 100 /)
    res(:,2) = (/ 10, 100 /) + ubound(arg) 
    res(:,3) = shape(arg)

  end function bar
  function baz(arg) result(res)
    integer, pointer     :: arg(..)
    integer, allocatable :: res(:,:)

    allocate(res(rank(arg), 3))
    
    res(:,1) = lbound(arg) + (/ 10, 100 /)
    res(:,2) = (/ 10, 100 /) + ubound(arg) 
    res(:,3) = shape(arg)

  end function baz
end program test

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]