[Ada] Avoid unwanted warnings for statically-known-successful assertions
authorSteve Baird <baird@adacore.com>
Tue, 24 May 2022 21:09:14 +0000 (14:09 -0700)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 4 Jul 2022 07:45:54 +0000 (07:45 +0000)
commitf7c05e82037356ac4610e9e5d1365b345a17d0f7
treefcc31852c5d7045342defa872ea420dc03c937cf
parente7428fff12ca000b59185c71dee511ac0c886089
[Ada] Avoid unwanted warnings for statically-known-successful assertions

The -gnatwc switch enables warnings for test condition outcomes that are
known at compile time. Such warnings are unlikely to be useful in the
case of an assertion expression (or a subexpression thereof), so do not
generate them in that case.

gcc/ada/

* sem_warn.adb (Warn_On_Constant_Valid_Condition): Do not
generate a warning if the expression in question is an assertion
expression, or a subexpression thereof. But do call
Test_Comparison so that it can generate warnings for the cases
that it generates warnings for.
* sem_prag.ads: Modify Assertion_Expression_Pragma constant so
that the predicate Sem_Util.In_Assertion_Expression_Pragma
returns True for the expression of a Compile_Time_Error pragma.
gcc/ada/sem_prag.ads
gcc/ada/sem_warn.adb