[flang-commits] [flang] 91b49fc - [flang][openacc] Fix unparsing of combined construct (bug 47659)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 1 07:35:15 PDT 2020


Author: Valentin Clement
Date: 2020-10-01T10:35:06-04:00
New Revision: 91b49fc2571c3d0ac33d447629cfb7789a7fde0d

URL: https://github.com/llvm/llvm-project/commit/91b49fc2571c3d0ac33d447629cfb7789a7fde0d
DIFF: https://github.com/llvm/llvm-project/commit/91b49fc2571c3d0ac33d447629cfb7789a7fde0d.diff

LOG: [flang][openacc] Fix unparsing of combined construct (bug 47659)

This patch fixes the bug report in https://bugs.llvm.org/show_bug.cgi?id=47659

Reviewed By: sameeranjoshi

Differential Revision: https://reviews.llvm.org/D88597

Added: 
    flang/test/Parser/acc-unparse.f90

Modified: 
    flang/lib/Parser/unparse.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index ab94aa2e00c2..b558bee41dbc 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -1903,8 +1903,8 @@ class UnparseVisitor {
     EndOpenACC();
     Walk(std::get<std::optional<DoConstruct>>(x.t));
     BeginOpenACC();
-    Walk("!$ACC END ", std::get<std::optional<DoConstruct>>(x.t));
-    Put("\n");
+    Walk("!$ACC END ", std::get<std::optional<AccEndCombinedDirective>>(x.t),
+        "\n");
     EndOpenACC();
   }
   void Unparse(const OpenACCRoutineConstruct &x) {

diff  --git a/flang/test/Parser/acc-unparse.f90 b/flang/test/Parser/acc-unparse.f90
new file mode 100644
index 000000000000..cb0edee2b6d4
--- /dev/null
+++ b/flang/test/Parser/acc-unparse.f90
@@ -0,0 +1,19 @@
+! RUN: %f18 -fopenacc -funparse %s | FileCheck %s
+
+! Test unparse does not crash with OpenACC directives.
+
+! Test bug 47659
+program bug47659
+  integer :: i, j
+  label1: do i = 1, 10
+    !$acc parallel loop
+    do j = 1, 10
+      if (j == 2) then
+        exit label1
+      end if
+    end do
+  end do label1
+end program
+
+!CHECK-LABEL: PROGRAM bug47659
+!CHECK: !$ACC PARALLEL LOOP


        


More information about the flang-commits mailing list