]> git.ipfire.org Git - thirdparty/gcc.git/commit
Ada: Fix couple of small accessibility glitches
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 3 Feb 2026 07:45:23 +0000 (08:45 +0100)
committerEric Botcazou <ebotcazou@adacore.com>
Tue, 3 Feb 2026 07:45:23 +0000 (08:45 +0100)
commitbb4791c336e5f5c6be707a6219b128da0a0a184b
treed1308b737f9cfcfbc56a40f25132a444651d06b0
parentc88be070dcec3b8c6ea996f79466f24fe65c798f
Ada: Fix couple of small accessibility glitches

The first glitch is that the ACATS test c3a0025 does not pass in Ada 2005
because an accessibility check preempts a null access check.  The second
glitch is that there should be no differences in Ada 2012 and later for
the test, in other words there is a missing accessibility check failure.

The second glitch comes from a thinko in the new implementation of the
In_Return_Value predicate, which has incorrectly dropped the handling of
assignments to return objects.

The first glitch is fixed by swapping the order of null access checks and
accessibility checks for conversions, which requires adding a small guard
to Apply_Discriminant_Check.

gcc/ada/
* checks.adb (Apply_Discriminant_Check): Bail out for a source type
that is a class-wide type whose root type has no discriminants.
* exp_ch4.adb (Expand_N_Type_Conversion): If the target type is an
access type, emit null access checks before accessibility checks.
* sem_util.adb (In_Return_Value): Deal again with assignments to
return objects.
gcc/ada/checks.adb
gcc/ada/exp_ch4.adb
gcc/ada/sem_util.adb