[flang-commits] [flang] [Flang][OpenMP] Fix crash when block.end() is missed (PR #147519)

David Spickett via flang-commits flang-commits at lists.llvm.org
Tue Jul 8 06:44:46 PDT 2025


================
@@ -0,0 +1,75 @@
+! This reproducer hit an issue where when finding directive's, and end directive's would iterate over the block.end()
+! so Flang would crash. We should be able to parse this subroutine without flang crashing.
+! Reported in https://github.com/llvm/llvm-project/issues/147309 and https://github.com/llvm/llvm-project/pull/145917#issuecomment-3041570824
+
+!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=51 %s | FileCheck %s --check-prefix=CHECK-PARSE
+!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=51 %s | FileCheck %s --check-prefix=CHECK-UNPARSE
+
+subroutine loop_transformation_construct7
+implicit none
+real(kind=8), dimension(1:10, 2) :: a
+integer :: b,c
+
+!$omp target teams distribute parallel do collapse(2) private(b)
+do b = 1, 10
+  do c = 1, 10
+    a(b, 2) = a(c, 1)
+  end do
+end do
+end subroutine
----------------
DavidSpickett wrote:

Also, is it worth trying a few invalid examples like that to see if flang can handle them? Maybe this is caught earlier than what this test is checking.

Like would a missing `end do` be diagnosed before the code in this PR even runs? If so then no need to worry about that.

https://github.com/llvm/llvm-project/pull/147519


More information about the flang-commits mailing list