]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix spurious warning on representation clause for private discriminated type
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 1 Nov 2024 19:47:57 +0000 (20:47 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 14 Nov 2024 13:54:31 +0000 (14:54 +0100)
commit8d25e228915d43fc0c005a1e3864de1017ce7fa5
treef86e3c9c1c8e8f5e24f49138f9e40ef28cda4189
parentc3db7e37a74680b98bcd8c582f0ef3f8778b4dde
ada: Fix spurious warning on representation clause for private discriminated type

This is the warning enabled by -gnatw.h for holes in record types that are
declared with a representation clause for their components.

When a discriminated type has a private declaration that also declares its
discriminants, the sibling discriminants present on the full declaration
are essentially ignored and, therefore, cannot be used in the computation
performed to give the warning.

gcc/ada/ChangeLog:

* sem_ch13.adb (Record_Hole_Check): Deal consistently with the base
type throughout the processing.  Return if its declaration is not a
full type declaration.  Assert that its record definition is either
a derived type definition or a record definition.  If the type has a
private declaration that does not specify unknown discriminants, use
it as the source of discriminant specifications, if any.
(Check_Component_List): Process every N_Discriminant_Specification
but assert that its defining identifier is really a discriminant.
gcc/ada/sem_ch13.adb