Empty "case" clauses that fall through to the "default" should be omitted (#5353)
* Empty "case" clauses that fall through to the "default" should be omitted * default throw exception * format
This commit is contained in:
parent
fffc3ed193
commit
bc392e55df
1 changed files with 43 additions and 11 deletions
|
@ -228,7 +228,6 @@ namespace ARMeilleure.Instructions
|
||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
|
@ -248,6 +247,9 @@ namespace ARMeilleure.Instructions
|
||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
|
@ -412,7 +414,6 @@ namespace ARMeilleure.Instructions
|
||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
|
@ -432,6 +433,9 @@ namespace ARMeilleure.Instructions
|
||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
|
@ -585,7 +589,6 @@ namespace ARMeilleure.Instructions
|
||||||
|
|
||||||
switch (context.Fpcr.GetRoundingMode())
|
switch (context.Fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
default:
|
|
||||||
case FPRoundingMode.ToNearest:
|
case FPRoundingMode.ToNearest:
|
||||||
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u));
|
||||||
overflowToInf = true;
|
overflowToInf = true;
|
||||||
|
@ -605,6 +608,9 @@ namespace ARMeilleure.Instructions
|
||||||
roundUp = false;
|
roundUp = false;
|
||||||
overflowToInf = false;
|
overflowToInf = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (roundUp)
|
if (roundUp)
|
||||||
|
@ -1433,11 +1439,24 @@ namespace ARMeilleure.Instructions
|
||||||
|
|
||||||
switch (fpcr.GetRoundingMode())
|
switch (fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
|
case FPRoundingMode.ToNearest:
|
||||||
|
overflowToInf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsPlusInfinity:
|
||||||
|
overflowToInf = !sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsMinusInfinity:
|
||||||
|
overflowToInf = sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsZero:
|
||||||
|
overflowToInf = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
|
||||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
|
||||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||||
|
@ -2845,11 +2864,24 @@ namespace ARMeilleure.Instructions
|
||||||
|
|
||||||
switch (fpcr.GetRoundingMode())
|
switch (fpcr.GetRoundingMode())
|
||||||
{
|
{
|
||||||
|
case FPRoundingMode.ToNearest:
|
||||||
|
overflowToInf = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsPlusInfinity:
|
||||||
|
overflowToInf = !sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsMinusInfinity:
|
||||||
|
overflowToInf = sign;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FPRoundingMode.TowardsZero:
|
||||||
|
overflowToInf = false;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case FPRoundingMode.ToNearest: overflowToInf = true; break;
|
throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\".");
|
||||||
case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break;
|
|
||||||
case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break;
|
|
||||||
case FPRoundingMode.TowardsZero: overflowToInf = false; break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign);
|
||||||
|
|
Reference in a new issue