mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 22:00:10 +00:00
[flang] Detect output field width overflow for Inf/NaN
The output editing code paths for F and E/D output that handle IEEE-754 infinities and NaNs fail to check for overflow of the output field, which should cause the field to be filled with asterisks instead. Catch these cases. Differential Revision: https://reviews.llvm.org/D151738
This commit is contained in:
parent
a88f496f8f
commit
763e036cc9
@ -320,8 +320,12 @@ bool RealOutputEditing<KIND>::EditEorDOutput(const DataEdit &edit) {
|
||||
decimal::ConversionToDecimalResult converted{
|
||||
Convert(significantDigits, edit.modes.round, flags)};
|
||||
if (IsInfOrNaN(converted)) {
|
||||
return EmitPrefix(edit, converted.length, editWidth) &&
|
||||
EmitAscii(io_, converted.str, converted.length) && EmitSuffix(edit);
|
||||
return editWidth > 0 &&
|
||||
converted.length > static_cast<std::size_t>(editWidth)
|
||||
? EmitRepeated(io_, '*', editWidth)
|
||||
: EmitPrefix(edit, converted.length, editWidth) &&
|
||||
EmitAscii(io_, converted.str, converted.length) &&
|
||||
EmitSuffix(edit);
|
||||
}
|
||||
if (!IsZero()) {
|
||||
converted.decimalExponent -= scale;
|
||||
@ -415,8 +419,12 @@ bool RealOutputEditing<KIND>::EditFOutput(const DataEdit &edit) {
|
||||
decimal::ConversionToDecimalResult converted{
|
||||
Convert(extraDigits + fracDigits, rounding, flags)};
|
||||
if (IsInfOrNaN(converted)) {
|
||||
return EmitPrefix(edit, converted.length, editWidth) &&
|
||||
EmitAscii(io_, converted.str, converted.length) && EmitSuffix(edit);
|
||||
return editWidth > 0 &&
|
||||
converted.length > static_cast<std::size_t>(editWidth)
|
||||
? EmitRepeated(io_, '*', editWidth)
|
||||
: EmitPrefix(edit, converted.length, editWidth) &&
|
||||
EmitAscii(io_, converted.str, converted.length) &&
|
||||
EmitSuffix(edit);
|
||||
}
|
||||
int expo{converted.decimalExponent + edit.modes.scale /*kP*/};
|
||||
int signLength{*converted.str == '-' || *converted.str == '+' ? 1 : 0};
|
||||
|
Loading…
Reference in New Issue
Block a user