Hi Jerry,
This patch fixes a problem with nested DO_CONCURRENT loops. In short,
shadow variables were not unique between the nested levels.
Regression tested on x86_64.
OK for mainline?
I have a couple of questions.
+ int nunderscore = 1;
+ name = (char *) alloca (strlen (v->symtree->name) + 32);
This restricts the number of underscores to 32, and will break if there
are more. I would suggest declaring a static counter which adds the
number to a string, like n_vars in frontend-passes.cc , which is then
used in create_vars.
The test case do_concurrent_typesspec_f90 has
+ s2 = 0
+ total = 0
+ do concurrent (integer :: i = 1:2)
+ s2 = s2 + i
+ do concurrent (integer(2) :: i = 1:3)
+ total = total + int (i, kind (total))
+ end do
+ end do
As far as I read the Fortran standard, the
do concurrent (integer :: i = 1:2)
s2 = s2 + i
is illegal because s2 has unspecified locality, and
11.1.7.5 Additional semantics for DO CONCURRENT constructs
states (paragraph 7)
If a variable has unspecified locality
if it is referenced in an iteration it shall either be previously
defined during that iteration, or shall not be defined or become
undefined during any other iteration; if it is defined or becomes
undefined by more than one iteration it becomes undefined when the loop
terminates;
[...]
Would the patch also work for the (slightly nonsensical, but also
legal, AFAIK)
do concurrent (integer :: i = 1:2)
do concurrent (integer(2) :: i = 1:3)
do concurrent (integer(8) :: i = 1:3)
And finally, I didn't dig deep enough into the standard to see if
do concurrent (integer :: i = 1:2)
do concurrent (integer(2) :: i = 1:3)
do concurrent (integer :: i = 1:3)
is legal or not, and what the compiler should do in this case.
Best regards
Thomas