diff options
author | Marco Carvalho <marcolucio27@gmail.com> | 2023-06-24 09:06:58 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-24 12:06:58 +0000 |
commit | bc392e55dfd0eed72ce30a550e91fa480eba1ef9 (patch) | |
tree | 2fe4e8c8fd2acf5e9ba441b35e0327e9966ef1f2 /src | |
parent | fffc3ed19308ba5a5139add55af8cb4918bc5378 (diff) |
Empty "case" clauses that fall through to the "default" should be omitted (#5353)1.1.907
* Empty "case" clauses that fall through to the "default" should be omitted
* default throw exception
* format
Diffstat (limited to 'src')
-rw-r--r-- | src/ARMeilleure/Instructions/SoftFloat.cs | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/src/ARMeilleure/Instructions/SoftFloat.cs b/src/ARMeilleure/Instructions/SoftFloat.cs index 9e3db68d..4af73c6d 100644 --- a/src/ARMeilleure/Instructions/SoftFloat.cs +++ b/src/ARMeilleure/Instructions/SoftFloat.cs @@ -228,7 +228,6 @@ namespace ARMeilleure.Instructions switch (context.Fpcr.GetRoundingMode()) { - default: case FPRoundingMode.ToNearest: roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u)); overflowToInf = true; @@ -248,6 +247,9 @@ namespace ARMeilleure.Instructions roundUp = false; overflowToInf = false; break; + + default: + throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\"."); } if (roundUp) @@ -412,7 +414,6 @@ namespace ARMeilleure.Instructions switch (context.Fpcr.GetRoundingMode()) { - default: case FPRoundingMode.ToNearest: roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u)); overflowToInf = true; @@ -432,6 +433,9 @@ namespace ARMeilleure.Instructions roundUp = false; overflowToInf = false; break; + + default: + throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\"."); } if (roundUp) @@ -585,7 +589,6 @@ namespace ARMeilleure.Instructions switch (context.Fpcr.GetRoundingMode()) { - default: case FPRoundingMode.ToNearest: roundUp = (error > 0.5d || (error == 0.5d && (intMant & 1u) == 1u)); overflowToInf = true; @@ -605,6 +608,9 @@ namespace ARMeilleure.Instructions roundUp = false; overflowToInf = false; break; + + default: + throw new ArgumentException($"Invalid rounding mode \"{context.Fpcr.GetRoundingMode()}\"."); } if (roundUp) @@ -1433,11 +1439,24 @@ namespace ARMeilleure.Instructions 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: - case FPRoundingMode.ToNearest: overflowToInf = true; break; - case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break; - case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break; - case FPRoundingMode.TowardsZero: overflowToInf = false; break; + throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\"."); } result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign); @@ -2845,11 +2864,24 @@ namespace ARMeilleure.Instructions 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: - case FPRoundingMode.ToNearest: overflowToInf = true; break; - case FPRoundingMode.TowardsPlusInfinity: overflowToInf = !sign; break; - case FPRoundingMode.TowardsMinusInfinity: overflowToInf = sign; break; - case FPRoundingMode.TowardsZero: overflowToInf = false; break; + throw new ArgumentException($"Invalid rounding mode \"{fpcr.GetRoundingMode()}\"."); } result = overflowToInf ? FPInfinity(sign) : FPMaxNormal(sign); |