This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[Patch, fortran] PR fortran/35681 elemental dependencies for expressions as actual arguments.


Hi all,

this is the final version of my patch.
What it adds is a flag in gfc_check_argument_var_dependency (and
callers) for the variable case, to know whether we should look for
dependencies (case of operators and elemental function calls as actual
argument) or not (case of variable references).
A warning is added in the latter case.
It also adds a recursive check for the cases above (operators and
elemental function calls) as those used to simply return zero (meaning
no dependency).

We don't need to bother about other cases (array constructors,
non-elemental function calls) as they will create a temporary anyway.

I took care of not changing the behavior of functions used elsewhere
(gfc_check_fncall_dependency and sub-called functions).


What could be improved is the handling of vector subscripts.
It is handled in the patch as normal array references (no special
handling, a warning in case of possible alias), because I didn't find
anything in the standard that was making it an expression.
I may be wrong however, as this is a very special case (non-definable,
meaning not valid as INTENT(OUT) arg, just like expressions).

Moreover, a temporary may be created to store the subscript.
This is not necessary in the elemental case, but I decided to leave it
as is, because it would be a very intrusive change (gfc_conv_loop_setup,
gfc_add_loop_ss_code, gfc_conv_expr_descriptor).
I added a TODO comment instead, as a reminder.
At least it is not wrong code.

Ok for trunk/4.3 ?

Thanks in advance for the review, even if late ;-)
Mikael


2008-11-14  Mikael Morin <mikael.morin@tele2.fr>

	PR fortran/35681
	* gfortran.dg/elemental_dependency_1.f90: New test.

2008-11-14  Mikael Morin <mikael.morin@tele2.fr>

	PR fortran/35681
	* dependency.c (gfc_check_argument_var_dependency): Add
	elemental check flag. Issue a warning if we find a dependency
	but don't generate a temporary. Add the case of an elemental
	function call as actual argument to an elemental procedure.
	Add the case of an operator expression as actual argument
	to an elemental procedure.
	(gfc_check_argument_dependency): Add elemental check flag.
	Update calls to gfc_check_argument_var_dependency.
	(gfc_check_fncall_dependency): Add elemental check flag.
	Update call to gfc_check_argument_dependency.
	* trans-stmt.c (gfc_trans_call): Make call to
	gfc_conv_elemental_dependency unconditional, but with a flag
	whether we should check dependencies between variables.
	(gfc_conv_elemental_dependency): Add elemental check flag.
	Update call to gfc_check_fncall_dependency.
	* trans-expr.c (gfc_trans_arrayfunc_assign): Update call to
	gfc_check_fncall_dependency.
	* resolve.c (find_noncopying_intrinsics): Update call to
	gfc_check_fncall_dependency.
	* dependency.h (enum gfc_dep_check): New enum.
	(gfc_check_fncall_dependency): Update prototype.

Attachment: pr35681_24.diff
Description: Text document


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