[flang-commits] [flang] [flang][OpenMP] Fix segfault on module USE cycle with -fopenmp (PR #228037)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Tue Oct 13 08:51:35 PDT 2026
================
@@ -13,3 +14,12 @@ module m2
module m3
use m1
end
+
+subroutine s()
+ use m1
+end subroutine s
+
+integer function f()
+ use m1
+ f = 0
+end function f
----------------
eugeneepshteyn wrote:
(This comment was generated with the help of AI)
Whichever way the aborted traversal ends up being handled, these shapes are worth pinning in tests, each in its own file or `split-file` case (the first crash would hide the rest). Two of them crash without OpenMP, so they need RUN lines without `-fopenmp`:
```fortran
module m1
use m2
end
module m2
use m1
end
print *, 'hi'
end
```
```console
$ flang -fsyntax-only cycle-print.f90
fatal internal error: SemanticsContext::FindScope(): invalid source location for 'print *, 'hi''
```
The same two modules followed by `function f()` / `f = 1.0` / `end` crash with `-x cuda`, in `CUDAChecker` (`FindScope(): invalid source location for 'f'`).
With `-fopenmp`, these still crash at this revision: a named main program, a named `block data`, an unnamed main program containing an interface body, and an unnamed main program containing `!$omp parallel do`. A file in which the submodule comes before the modules in the cycle is also worth a case.
https://github.com/llvm/llvm-project/pull/228037
More information about the flang-commits
mailing list