[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
diff --git a/flang/runtime/transformational.cpp b/flang/runtime/transformational.cpp
index fef4eac..aac6e61 100644
--- a/flang/runtime/transformational.cpp
+++ b/flang/runtime/transformational.cpp
@@ -525,12 +525,15 @@
}
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;