https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94690
--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Tobias Burnus from comment #0)
> * pr66199-9.f90 – gives an ICE in omp_add_variable
> (if 'lastprivate' is permitted, otherwise, it is rejected.)
Reduced test case (needs patch to permit lastprivate in
OMP_DISTRIBUTE_CLAUSES):
internal compiler error: in omp_add_variable, at gimplify.c:6958
integer function f2 ()
implicit none
integer :: d, a
! !$omp teams shared(d) shared(a)
!$omp distribute lastprivate(d)
do d = 1, 2
a = d * 5
end do
! !$omp end teams
f2 = d
end
["omp teams" is not needed for the ICE, but without the C testcase fails with:
"lastprivate variable ‘d’ is private in outer context"]
The problem is (original dump):
#pragma omp distribute private(d) lastprivate(d)
Mixing 'private' + 'lastprivate' is bad.
* * *
The private is added in gfc_trans_omp_do, as dovar_found == 0.
We have:
* clauses->lists[OMP_LIST_LASTPRIVATE]->sym->name
$41 = 0x7ffff78c0128 "d"
* clauses->lists[OMP_LIST_PRIVATE] == NULL
And the code (in gfc_trans_omp_do):
if (op != EXEC_OMP_DISTRIBUTE)
for (n = clauses->lists[(op == EXEC_OMP_SIMD && collapse == 1)
? OMP_LIST_LINEAR : OMP_LIST_LASTPRIVATE];
...
else if (n == NULL && op != EXEC_OMP_SIMD)
for (n = clauses->lists[OMP_LIST_PRIVATE]; n != NULL; n = n->next)