[PATCH] Debug support for Fortran 90 assumed shape and other descriptor using arrays (PR fortran/22244)

Jakub Jelinek jakub@redhat.com
Fri Nov 16 13:28:00 GMT 2007


On Fri, Nov 16, 2007 at 12:45:02PM +0100, Tobias Burnus wrote:
> I applied the GCC patch and tried the example with the Intel Debugger
> 10. Tested was "a4.f90" of
> http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00612.html.
> 
> Using ifort10, I get in "baz":
> 
> (idb) ptype varx
> type = REAL(4)(6)(11)(12)
> (idb) p varx
> $1 = {{{7, 6, 6, 6, 6, 6}, {6 ...

There is DW_AT_ordering attribute with { DW_ORD_col_major, DW_ORD_row_major }
possible values.  The standard says the default (if DW_AT_ordering is
missing) depends on the language, but I couldn't find the default values for each
language anywhere.  GCC outputs arrays in the same order for all languages
and GDB seems to default to DW_ORD_row_major if DW_AT_ordering is not
present.

Can you look at with idb on gfortran (vanilla or patched) generated MAIN__
x and y arrays after the bar subroutine returns and see if they are
displayed in the expected order or not?

Perhaps we should for all fortran multidimensional arrays output
DW_AT_ordering with DW_ORD_row_major?

	Jakub
-------------- next part --------------
subroutine baz
  real, target, allocatable :: varx (:, :, :)
  real, pointer :: varv (:, :, :)
  real, target :: varu (1, 2, 3)
  logical :: l
  allocate (varx (1:6, 5:15, 17:28))
  l = allocated (varx)
  varx(:, :, :) = 6
  varx(1, 5, 17) = 7
  varx(2, 6, 18) = 8
  varx(6, 15, 28) = 9
  varv => varx
  l = associated (varv)
  varv(3, 7, 19) = 10
  varv => null ()
  l = associated (varv)
  deallocate (varx)
  l = allocated (varx)
  varu(:, :, :) = 10
  allocate (varv (1:6, 5:15, 17:28))
  l = associated (varv)
  varv(:, :, :) = 6
  varv(1, 5, 17) = 7
  varv(2, 6, 18) = 8
  varv(6, 15, 28) = 9
  deallocate (varv)
  l = associated (varv)
  varv => varu
  varv(1, 1, 1) = 6
  varv(1, 2, 3) = 7
  l = associated (varv)
end subroutine baz
subroutine foo (vary, varw)
  real :: vary (:, :)
  real :: varw (:, :, :)
  vary(:, :) = 4
  vary(1, 1) = 8
  vary(2, 2) = 9
  vary(1, 3) = 10
  varw(:, :, :) = 5
  varw(1, 1, 1) = 6
  varw(2, 2, 2) = 7
end subroutine foo
subroutine bar (varz, vart)
  real :: varz (*)
  real :: vart (2:11, 7:*)
  varz(1:3) = 4
  varz(2) = 5
end subroutine bar
program test
  interface
    subroutine foo (vary, varw)
    real :: vary (:, :)
    real :: varw (:, :, :)
    end subroutine
  end interface
  interface
    subroutine bar (varz, vart)
    real :: varz (*)
    real :: vart (2:11, 7:*)
    end subroutine
  end interface
  real :: x (10, 10), y (5), z(8, 8, 8)
  x(:,:) = 1
  y(:) = 2
  z(:,:,:) = 3
  call baz
  call foo (x, z(2:6, 4:7, 6:8))
  call bar (y, x)
  if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
  if (x (1, 3) .ne. 10) call abort
  if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
  if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
  call foo (transpose (x), z)
  if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
  if (x (3, 1) .ne. 10) call abort
end


More information about the Gcc-patches mailing list