[fortran] Fix Bug 102430 - [13/14/15/16 Regression] ICE in fold_convert_loc, at fold-const.c
Commit Message
Hello all,
The attached patch resolves this by issueing a sorry error.
This fix is also relatively simple.
I will also commit this one later today.
Regression tested on x86_64.
I dont think this one is worth backporting later. Let me know if anyone thinks
otherwise.
Regards,
Jerry
---
commit 396a6f28d770b27844cb7a340249d78f3f391649 (HEAD -> master)
Author: Christopher Albert <albert@tugraz.at>
Date: Sun Dec 21 00:33:11 2025 +0100
fortran: Reject array/allocatable LINEAR on DO [PR102430]
The middle-end does not implement array/allocatable LINEAR for OpenMP
worksharing loops, which can ICE during OpenMP expansion. Diagnose this
case in the Fortran front end with a sorry message instead.
PR fortran/102430
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Reject array/allocatable LINEAR on
worksharing-loop constructs.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/pr102430.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
Comments
Hi Jerry,
I think that a "sorry" is better than an ICE on all the affected
branches. By all means push it to mainline and I will put it on the
schedule for backporting.
Thanks
Paul
On Tue, 7 Apr 2026 at 18:48, Jerry D <jvdelisle2@gmail.com> wrote:
>
> Hello all,
>
> The attached patch resolves this by issueing a sorry error.
>
> This fix is also relatively simple.
>
> I will also commit this one later today.
>
> Regression tested on x86_64.
>
> I dont think this one is worth backporting later. Let me know if anyone thinks
> otherwise.
>
> Regards,
>
> Jerry
> ---
>
> commit 396a6f28d770b27844cb7a340249d78f3f391649 (HEAD -> master)
> Author: Christopher Albert <albert@tugraz.at>
> Date: Sun Dec 21 00:33:11 2025 +0100
>
> fortran: Reject array/allocatable LINEAR on DO [PR102430]
>
> The middle-end does not implement array/allocatable LINEAR for OpenMP
> worksharing loops, which can ICE during OpenMP expansion. Diagnose this
> case in the Fortran front end with a sorry message instead.
>
> PR fortran/102430
>
> gcc/fortran/ChangeLog:
>
> * openmp.cc (resolve_omp_clauses): Reject array/allocatable LINEAR on
> worksharing-loop constructs.
>
> gcc/testsuite/ChangeLog:
>
> * gfortran.dg/gomp/pr102430.f90: New test.
>
> Signed-off-by: Christopher Albert <albert@tugraz.at>
From 5424fef298bff8b69a351dde8ab2a6b7c46af9ab Mon Sep 17 00:00:00 2001
From: Christopher Albert <albert@tugraz.at>
Date: Sun, 21 Dec 2025 00:33:11 +0100
Subject: [PATCH] fortran: Reject array/allocatable LINEAR on DO [PR102430]
The middle-end does not implement array/allocatable LINEAR for OpenMP
worksharing loops, which can ICE during OpenMP expansion. Diagnose this
case in the Fortran front end with a sorry message instead.
PR fortran/102430
gcc/fortran/ChangeLog:
* openmp.cc (resolve_omp_clauses): Reject array/allocatable LINEAR on
worksharing-loop constructs.
gcc/testsuite/ChangeLog:
* gfortran.dg/gomp/pr102430.f90: New test.
Signed-off-by: Christopher Albert <albert@tugraz.at>
---
gcc/fortran/openmp.cc | 35 +++++++++++++++++++++
gcc/testsuite/gfortran.dg/gomp/pr102430.f90 | 11 +++++++
2 files changed, 46 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr102430.f90
@@ -10435,6 +10435,41 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
}
break;
case OMP_LIST_LINEAR:
+ if (code)
+ {
+ bool is_worksharing_for = false;
+ switch (code->op)
+ {
+ case EXEC_OMP_DO:
+ case EXEC_OMP_PARALLEL_DO:
+ case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
+ case EXEC_OMP_TARGET_PARALLEL_DO:
+ case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
+ case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
+ is_worksharing_for = true;
+ break;
+ default:
+ break;
+ }
+
+ if (is_worksharing_for
+ && (n->sym->attr.dimension
+ || n->sym->attr.allocatable))
+ {
+ if (n->sym->attr.allocatable)
+ gfc_error ("Sorry, ALLOCATABLE object %qs in "
+ "LINEAR clause on worksharing-loop "
+ "construct at %L is not yet supported",
+ n->sym->name, &n->where);
+ else
+ gfc_error ("Sorry, array %qs in LINEAR clause "
+ "on worksharing-loop construct at %L "
+ "is not yet supported",
+ n->sym->name, &n->where);
+ break;
+ }
+ }
+
if (code
&& n->u.linear.op != OMP_LINEAR_DEFAULT
&& n->u.linear.op != linear_op)
new file mode 100644
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+! PR fortran/102430
+
+program p
+ integer :: a(2)
+ !$omp parallel do linear(a) ! { dg-error "Sorry, array" }
+ do i = 1, 8
+ a = a + 1
+ end do
+end program p
--
2.52.0