[flang-commits] [flang] b910cf9 - [flang] use 1-based dim in transformational runtime error msg
Jean Perier via flang-commits
flang-commits at lists.llvm.org
Thu May 5 01:34:06 PDT 2022
Author: Jean Perier
Date: 2022-05-05T10:33:14+02:00
New Revision: b910cf986ab953874c55cf2eb6981234abad9b76
URL: https://github.com/llvm/llvm-project/commit/b910cf986ab953874c55cf2eb6981234abad9b76
DIFF: https://github.com/llvm/llvm-project/commit/b910cf986ab953874c55cf2eb6981234abad9b76.diff
LOG: [flang] use 1-based dim in transformational runtime error msg
Flang transformational runtime was previously reporting conformity
issues in a zero based fashion to describe which dimension is non
conformant. This may confuse Fortran user, especially when the message
is about a dimension other than the first one.
Differential Revision: https://reviews.llvm.org/D124941
Added:
Modified:
flang/runtime/tools.cpp
flang/unittests/Runtime/RuntimeCrashTest.cpp
Removed:
################################################################################
diff --git a/flang/runtime/tools.cpp b/flang/runtime/tools.cpp
index f9b804e1ff1730..598083b5ab7ac4 100644
--- a/flang/runtime/tools.cpp
+++ b/flang/runtime/tools.cpp
@@ -98,7 +98,7 @@ void CheckConformability(const Descriptor &to, const Descriptor &x,
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);
}
}
}
diff --git a/flang/unittests/Runtime/RuntimeCrashTest.cpp b/flang/unittests/Runtime/RuntimeCrashTest.cpp
index 38fe1424bca958..34a8ff6d371131 100644
--- a/flang/unittests/Runtime/RuntimeCrashTest.cpp
+++ b/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 @@ TEST(TestIOCrash, OverwriteBufferIntegerTest) {
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");
+}
More information about the flang-commits
mailing list