PR fortran/50069
PR fortran/55086
* trans-expr.c (gfc_conv_variable): Don't treat temporary variables
as function arguments.
* trans-stmt.c (forall_make_variable_temp,
generate_loop_for_temp_to_lhs, gfc_trans_assign_need_temp,
gfc_trans_forall_1): Don't adjust offset of forall temporary
for array sections, make forall temporaries work for substring
expressions, improve test coverage by adding -ftest-forall-temp
option to request usage of temporary array in forall code.
* lang.opt: Add -ftest-forall-temp option.
* invoke.texi: Add -ftest-forall-temp option.
There were problems with temporary arrays created to implement forall vs. substring expressions and array sections. One of the files included in PR50069 had problems with a temporary variable used to hold a function result.
There are two goals: Use temporaries as infrequently as possible, and make sure that when they have to be used, they work. To improve test coverage, I added an option, -ftest-forall-temp, to encourage the forall code to use a temporary if at all possible, and I've added a few test files with this option. The idea was to find problems sooner rather than wait for them to be reported later.
At the moment, check-fortran works with this option set by default with the exception of one test, forall_8.f90, whose purpose is to make sure that a particular forall statement doesn't use a temporary. Yes, it took a long time to get to that point.
The option is of course normally turned off.
I left a couple of TODO comments in the code.
Louis Krupp