Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/flang
diff options
context:
space:
mode:
authorPeter Steinfeld <psteinfeld@nvidia.com>2022-03-12 01:01:07 +0300
committerPeter Steinfeld <psteinfeld@nvidia.com>2022-03-13 02:15:56 +0300
commite3550f1903d21d0355a37dc481b94e073609a5b3 (patch)
tree367793479aa6e35ec9a4eb0b720a8a7c66d17ece /flang
parent7b8fbb796c4d80a75e90ace31ce9047d2e05bc08 (diff)
[flang] Improve runtime crash messages
Where possible, I added additional information to the messages to help programmers figure out what went wrong. I also removed all uses of the word "bad" from the messages since (to me) that implies a moral judgement rather than a programming error. I replaced it with either "invalid" or "unsupported" where appropriate. Differential Revision: https://reviews.llvm.org/D121493
Diffstat (limited to 'flang')
-rw-r--r--flang/runtime/descriptor-io.h2
-rw-r--r--flang/runtime/extrema.cpp4
-rw-r--r--flang/runtime/findloc.cpp4
-rw-r--r--flang/runtime/inquiry.cpp6
-rw-r--r--flang/runtime/io-api.cpp7
-rw-r--r--flang/runtime/io-stmt.cpp2
-rw-r--r--flang/runtime/iostat.cpp2
-rw-r--r--flang/runtime/random.cpp2
-rw-r--r--flang/runtime/reduction-templates.h9
-rw-r--r--flang/runtime/reduction.cpp2
-rw-r--r--flang/runtime/transformational.cpp9
-rw-r--r--flang/runtime/unit.cpp5
12 files changed, 31 insertions, 23 deletions
diff --git a/flang/runtime/descriptor-io.h b/flang/runtime/descriptor-io.h
index 1e78a826f04d..f6528762795a 100644
--- a/flang/runtime/descriptor-io.h
+++ b/flang/runtime/descriptor-io.h
@@ -480,7 +480,7 @@ static bool DescriptorIO(IoStatementState &io, const Descriptor &descriptor) {
return FormattedDerivedTypeIO<DIR>(io, descriptor);
}
}
- handler.Crash("DescriptorIO: Bad type code (%d) in descriptor",
+ handler.Crash("DescriptorIO: bad type code (%d) in descriptor",
static_cast<int>(descriptor.type().raw()));
return false;
}
diff --git a/flang/runtime/extrema.cpp b/flang/runtime/extrema.cpp
index 3e471b3c09c1..c68caec52ea3 100644
--- a/flang/runtime/extrema.cpp
+++ b/flang/runtime/extrema.cpp
@@ -176,7 +176,7 @@ inline void TypedMaxOrMinLoc(const char *intrinsic, Descriptor &result,
break;
default:
terminator.Crash(
- "%s: Bad data type code (%d) for array", intrinsic, x.type().raw());
+ "%s: bad data type code (%d) for array", intrinsic, x.type().raw());
}
}
@@ -262,7 +262,7 @@ inline void TypedPartialMaxOrMinLoc(const char *intrinsic, Descriptor &result,
break;
default:
terminator.Crash(
- "%s: Bad data type code (%d) for array", intrinsic, x.type().raw());
+ "%s: bad data type code (%d) for array", intrinsic, x.type().raw());
}
}
diff --git a/flang/runtime/findloc.cpp b/flang/runtime/findloc.cpp
index f268d462b43b..6a3aaef88207 100644
--- a/flang/runtime/findloc.cpp
+++ b/flang/runtime/findloc.cpp
@@ -248,7 +248,7 @@ void RTNAME(Findloc)(Descriptor &result, const Descriptor &x,
break;
default:
terminator.Crash(
- "FINDLOC: Bad data type code (%d) for array", x.type().raw());
+ "FINDLOC: bad data type code (%d) for array", x.type().raw());
}
}
} // extern "C"
@@ -335,7 +335,7 @@ void RTNAME(FindlocDim)(Descriptor &result, const Descriptor &x,
break;
default:
terminator.Crash(
- "FINDLOC: Bad data type code (%d) for array", x.type().raw());
+ "FINDLOC: bad data type code (%d) for array", x.type().raw());
}
}
} // extern "C"
diff --git a/flang/runtime/inquiry.cpp b/flang/runtime/inquiry.cpp
index 1f67020f2caf..5dc692c9a384 100644
--- a/flang/runtime/inquiry.cpp
+++ b/flang/runtime/inquiry.cpp
@@ -23,7 +23,8 @@ std::int64_t RTNAME(LboundDim)(
const Descriptor &array, int dim, const char *sourceFile, int line) {
if (dim < 1 || dim > array.rank()) {
Terminator terminator{sourceFile, line};
- terminator.Crash("SIZE: bad DIM=%d", dim);
+ terminator.Crash(
+ "SIZE: bad DIM=%d for ARRAY with rank=%d", dim, array.rank());
}
const Dimension &dimension{array.GetDimension(dim - 1)};
return static_cast<std::int64_t>(dimension.LowerBound());
@@ -68,7 +69,8 @@ std::int64_t RTNAME(SizeDim)(
const Descriptor &array, int dim, const char *sourceFile, int line) {
if (dim < 1 || dim > array.rank()) {
Terminator terminator{sourceFile, line};
- terminator.Crash("SIZE: bad DIM=%d", dim);
+ terminator.Crash(
+ "SIZE: bad DIM=%d for ARRAY with rank=%d", dim, array.rank());
}
const Dimension &dimension{array.GetDimension(dim - 1)};
return static_cast<std::int64_t>(dimension.Extent());
diff --git a/flang/runtime/io-api.cpp b/flang/runtime/io-api.cpp
index e097867518c7..8733463e6308 100644
--- a/flang/runtime/io-api.cpp
+++ b/flang/runtime/io-api.cpp
@@ -564,7 +564,7 @@ bool IONAME(SetPos)(Cookie cookie, std::int64_t pos) {
unit->SetPosition(pos - 1, handler);
return true;
}
- io.GetIoErrorHandler().Crash("SetPos() on internal unit");
+ io.GetIoErrorHandler().Crash("SetPos() called on internal unit");
return false;
}
@@ -937,7 +937,7 @@ bool IONAME(GetNewUnit)(Cookie cookie, int &unit, int kind) {
}
std::int64_t result{open->unit().unitNumber()};
if (!SetInteger(unit, kind, result)) {
- open->SignalError("GetNewUnit(): Bad INTEGER kind(%d) or out-of-range "
+ open->SignalError("GetNewUnit(): bad INTEGER kind(%d) or out-of-range "
"value(%jd) for result",
kind, static_cast<std::intmax_t>(result));
}
@@ -1209,7 +1209,8 @@ bool IONAME(InquireInteger64)(
return true;
}
io.GetIoErrorHandler().SignalError(
- "InquireInteger64(): Bad INTEGER kind(%d) or out-of-range value(%jd) "
+ "InquireInteger64(): bad INTEGER kind(%d) or out-of-range "
+ "value(%jd) "
"for result",
kind, static_cast<std::intmax_t>(n));
}
diff --git a/flang/runtime/io-stmt.cpp b/flang/runtime/io-stmt.cpp
index b86559631d1d..9415029201ea 100644
--- a/flang/runtime/io-stmt.cpp
+++ b/flang/runtime/io-stmt.cpp
@@ -78,7 +78,7 @@ bool IoStatementBase::Inquire(InquiryKeywordHash, std::int64_t &) {
void IoStatementBase::BadInquiryKeywordHashCrash(InquiryKeywordHash inquiry) {
char buffer[16];
const char *decode{InquiryKeywordHashDecode(buffer, sizeof buffer, inquiry)};
- Crash("bad InquiryKeywordHash 0x%x (%s)", inquiry,
+ Crash("Bad InquiryKeywordHash 0x%x (%s)", inquiry,
decode ? decode : "(cannot decode)");
}
diff --git a/flang/runtime/iostat.cpp b/flang/runtime/iostat.cpp
index f1d20c1a23b0..994af4f2a4f7 100644
--- a/flang/runtime/iostat.cpp
+++ b/flang/runtime/iostat.cpp
@@ -30,7 +30,7 @@ const char *IostatErrorString(int iostat) {
case IostatInternalWriteOverrun:
return "Internal write overran available records";
case IostatErrorInFormat:
- return "Invalid FORMAT";
+ return "Bad FORMAT";
case IostatErrorInKeyword:
return "Bad keyword argument value";
case IostatEndfileDirect:
diff --git a/flang/runtime/random.cpp b/flang/runtime/random.cpp
index f42504623521..a2753da70af1 100644
--- a/flang/runtime/random.cpp
+++ b/flang/runtime/random.cpp
@@ -108,7 +108,7 @@ void RTNAME(RandomNumber)(
break;
#endif
default:
- terminator.Crash("RANDOM_NUMBER(): unsupported REAL kind %d", kind);
+ terminator.Crash("RANDOM_NUMBER(): bad REAL kind %d", kind);
}
}
diff --git a/flang/runtime/reduction-templates.h b/flang/runtime/reduction-templates.h
index 11b491a6466a..93e987a04e5c 100644
--- a/flang/runtime/reduction-templates.h
+++ b/flang/runtime/reduction-templates.h
@@ -44,8 +44,8 @@ inline void DoTotalReduction(const Descriptor &x, int dim,
const Descriptor *mask, ACCUMULATOR &accumulator, const char *intrinsic,
Terminator &terminator) {
if (dim < 0 || dim > 1) {
- terminator.Crash(
- "%s: bad DIM=%d for argument with rank %d", intrinsic, dim, x.rank());
+ terminator.Crash("%s: bad DIM=%d for ARRAY argument with rank %d",
+ intrinsic, dim, x.rank());
}
SubscriptValue xAt[maxRank];
x.GetLowerBounds(xAt);
@@ -166,7 +166,8 @@ static void CreatePartialReductionResult(Descriptor &result,
TypeCode typeCode) {
int xRank{x.rank()};
if (dim < 1 || dim > xRank) {
- terminator.Crash("%s: bad DIM=%d for rank %d", intrinsic, dim, xRank);
+ terminator.Crash(
+ "%s: bad DIM=%d for ARRAY with rank %d", intrinsic, dim, xRank);
}
int zeroBasedDim{dim - 1};
SubscriptValue resultExtent[maxRank];
@@ -295,7 +296,7 @@ inline void TypedPartialNumericReduction(Descriptor &result,
intrinsic);
break;
default:
- terminator.Crash("%s: invalid type code %d", intrinsic, x.type().raw());
+ terminator.Crash("%s: bad type code %d", intrinsic, x.type().raw());
}
}
diff --git a/flang/runtime/reduction.cpp b/flang/runtime/reduction.cpp
index dea25cf8dc76..c828f06d5227 100644
--- a/flang/runtime/reduction.cpp
+++ b/flang/runtime/reduction.cpp
@@ -228,7 +228,7 @@ inline auto GetTotalLogicalReduction(const Descriptor &x, const char *source,
typename ACCUMULATOR::Type {
Terminator terminator{source, line};
if (dim < 0 || dim > 1) {
- terminator.Crash("%s: bad DIM=%d", intrinsic, dim);
+ terminator.Crash("%s: bad DIM=%d for ARRAY with rank=1", intrinsic, dim);
}
SubscriptValue xAt[maxRank];
x.GetLowerBounds(xAt);
diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index fef4eacc508f..aac6e61ce9dd 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -525,12 +525,15 @@ void RTNAME(Unpack)(Descriptor &result, const Descriptor &vector,
}
mask.GetLowerBounds(maskAt);
field.GetLowerBounds(fieldAt);
- SubscriptValue vectorLeft{vector.GetDimension(0).Extent()};
+ SubscriptValue vectorElements{vector.GetDimension(0).Extent()};
+ SubscriptValue vectorLeft{vectorElements};
for (std::size_t n{result.Elements()}; n-- > 0;) {
if (IsLogicalElementTrue(mask, maskAt)) {
if (vectorLeft-- == 0) {
- terminator.Crash("UNPACK: VECTOR= argument has fewer elements than "
- "MASK= has .TRUE. entries");
+ terminator.Crash(
+ "UNPACK: VECTOR= argument has fewer elements (%d) than "
+ "MASK= has .TRUE. entries",
+ vectorElements);
}
CopyElement(result, resultAt, vector, &vectorAt, terminator);
++vectorAt;
diff --git a/flang/runtime/unit.cpp b/flang/runtime/unit.cpp
index cef971d00c74..87b11820609a 100644
--- a/flang/runtime/unit.cpp
+++ b/flang/runtime/unit.cpp
@@ -48,7 +48,7 @@ ExternalFileUnit &ExternalFileUnit::LookUpOrCrash(
int unit, const Terminator &terminator) {
ExternalFileUnit *file{LookUp(unit)};
if (!file) {
- terminator.Crash("Not an open I/O unit number: %d", unit);
+ terminator.Crash("%d is not an open I/O unit number", unit);
}
return *file;
}
@@ -855,7 +855,8 @@ bool ExternalFileUnit::CheckDirectAccess(IoErrorHandler &handler) {
if (access == Access::Direct) {
RUNTIME_CHECK(handler, openRecl);
if (!directAccessRecWasSet_) {
- handler.SignalError("No REC= was specified for a data transfer with ACCESS='DIRECT'");
+ handler.SignalError(
+ "No REC= was specified for a data transfer with ACCESS='DIRECT'");
return false;
}
}