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] PR34796 - Actual/Formal arg checking: Fix regression, add check


Tobias Burnus wrote:
Hi all,

my patch for actual/formal argument checking (PR 34665) caused a
regression. Fortran allows since the old days to pass an array element
to an array dummy argument, which allows one to access the elements from
that element onwards.

The main condition which needs to be fulfilled to make this work is that
array is contiguous, which is the reason behind most of the checks added
in previous patch. An array can be non-contiguous in memory if it has
strides. Thus if I pass an array to a function, the assumed-shape array
(= dummy argument) may have strides. However, if I allocate a
deferred-shape array in the subroutine itself, the memory is contiguous.

With my previous patch, elements of deferred arrays were wrongly
rejected (which caused a regression in octopus [tddft.org]); I removed
this restriction and replaced it with a check for the pointer attribute.
[Excerpt from the standard, see PR.]


I took also the opportunity to add a warning if the passed array is smaller than the storage size of the dummy argument. Before there was no check for passing an array element (PR 32616 tracks this), now there is a check for a special case: For pointers to arrays and assumed-shape arrays the memory is - in general - not contiguous (see above); therefore the storage size of the actual argument is simply its size. (In the other case, one has to do rather complicated arithmetics for multi-dimensional arrays; if one includes substrings it even gets more complicated and thus I postponed its implementation [PR 32616].)

Build on x86-64-linux and tested:
- testsuite/gfortran* (-m32 and -m64)
- libgomp (-m32 and -m64)
- octopus recompiled
- CP2K recompiled
- Unicomp Fortran Testuite (Lite) run

(The tree also included Paul's patch, which thus at least works with
those tests.)

OK for the trunk?

This is OK.

Jerry


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