ada: Handle GNATcheck violations
commit105891ca1beda7aecb2b637cc62f5c8a3ac49386
authorSheri Bernstein <bernstein@adacore.com>
Tue, 1 Aug 2023 16:36:14 +0000 (1 16:36 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 5 Sep 2023 11:05:11 +0000 (5 13:05 +0200)
tree99c79874cb37f833c549af5d9b274e83c6e80687
parent8950360830f0d7f5f356ec447e8493be7b98c2cb
ada: Handle GNATcheck violations

For the GNATcheck rule "Improper_Returns", either use pragma Annotate
to exempt the violation with the rationale "early returns for performance",
or refactor the code by replacing multiple returns by a single return
statement with a conditional expression; this is more readable and
maintainable, and also conformant with a Highly Recommended design principle
of ISO 26262-6.  For the GNATcheck rule "Discriminated_Records", use pragma
Annotate to exempt the violation with the rationale "only variant records
are disallowed".

gcc/ada/

* libgnarl/a-reatim.adb (Time_Of): Add pragma to exempt
Discriminated_Records.
* libgnat/s-imguti.adb (Round, Set_Decimal_Digits): Likewise.
* libgnat/s-multip.adb (Number_Of_CPUs): Likewise.
* libgnarl/s-tpopsp__posix-foreign.adb (Self): Refactor multiple
returns.
gcc/ada/libgnarl/a-reatim.adb
gcc/ada/libgnarl/s-tpopsp__posix-foreign.adb
gcc/ada/libgnat/s-imguti.adb
gcc/ada/libgnat/s-multip.adb