[flang-commits] [PATCH] D124941: [flang] use 1-based dim in transformational runtime error msg

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu May 5 01:34:11 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGb910cf986ab9: [flang] use 1-based dim in transformational runtime error msg (authored by jeanPerier).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124941/new/

https://reviews.llvm.org/D124941

Files:
  flang/runtime/tools.cpp
  flang/unittests/Runtime/RuntimeCrashTest.cpp


Index: flang/unittests/Runtime/RuntimeCrashTest.cpp
===================================================================
--- flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ flang/unittests/Runtime/RuntimeCrashTest.cpp
@@ -11,12 +11,15 @@
 //
 //===----------------------------------------------------------------------===//
 #include "CrashHandlerFixture.h"
+#include "tools.h"
 #include "../../runtime/terminator.h"
 #include "flang/Runtime/io-api.h"
+#include "flang/Runtime/transformational.h"
 #include <gtest/gtest.h>
 
 using namespace Fortran::runtime;
 using namespace Fortran::runtime::io;
+using Fortran::common::TypeCategory;
 
 //------------------------------------------------------------------------------
 /// Test crashes through direct calls to terminator methods
@@ -155,3 +158,23 @@
   ASSERT_DEATH(IONAME(OutputInteger64)(cookie, 0xdeadbeef),
       "Internal write overran available records");
 }
+
+//------------------------------------------------------------------------------
+/// Test conformity issue reports in transformational intrinsics
+//------------------------------------------------------------------------------
+struct TestIntrinsicCrash : CrashHandlerFixture {};
+
+TEST(TestIntrinsicCrash, ConformityErrors) {
+  // ARRAY(2,3) and MASK(2,4) should trigger a runtime error.
+  auto array{MakeArray<TypeCategory::Integer, 4>(
+      std::vector<int>{2, 3}, std::vector<std::int32_t>{1, 2, 3, 4, 5, 6})};
+  auto mask{MakeArray<TypeCategory::Logical, 1>(std::vector<int>{2, 4},
+      std::vector<std::uint8_t>{
+          false, true, true, false, false, true, true, true})};
+  StaticDescriptor<1, true> statDesc;
+  Descriptor &result{statDesc.descriptor()};
+
+  ASSERT_DEATH(RTNAME(Pack)(result, *array, *mask, nullptr, __FILE__, __LINE__),
+      "Incompatible array arguments to PACK: dimension 2 of ARRAY= has extent "
+      "3 but MASK= has extent 4");
+}
Index: flang/runtime/tools.cpp
===================================================================
--- flang/runtime/tools.cpp
+++ flang/runtime/tools.cpp
@@ -98,7 +98,7 @@
       if (xExtent != toExtent) {
         terminator.Crash("Incompatible array arguments to %s: dimension %d of "
                          "%s has extent %" PRId64 " but %s has extent %" PRId64,
-            funcName, j, toName, toExtent, xName, xExtent);
+            funcName, j + 1, toName, toExtent, xName, xExtent);
       }
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124941.427239.patch
Type: text/x-patch
Size: 2422 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220505/393accd1/attachment-0001.bin>


More information about the flang-commits mailing list