[Ada] Properly reject unsupported address specifications
authorSteve Baird <baird@adacore.com>
Tue, 25 Jan 2022 00:46:58 +0000 (16:46 -0800)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 11 May 2022 08:53:17 +0000 (08:53 +0000)
commit88e9690610c421a7ece2331828b9799755d7ddba
treea459437b4cc50bb31c1f5ed96c5034cebed0a04a
parentc48a779f64c68f73f50c5993c818ead9faf8d013
[Ada] Properly reject unsupported address specifications

In the case of an object declaration with an indefinite nominal subtype
(roughly speaking, that's an object that takes its bounds,
discriminants, and/or tag from its explicit initial value), GNAT does
not support address specifications unless the size of the object is
known at compile time.  In some cases, such unsupported address
specifications were not properly rejected. This could lead to either an
internal error during compilation or (in the class-wide case) to a
warning accompanied by raising Program_Error at run time.

gcc/ada/

* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Replace
the existing check for an address specification for an object of
a class-wide type with a more general check which rejects either
the class-wide case or the case where the FE would (if the
address specification were accepted) build a malformed
tree (specifically, an object renaming declaration with a
specified address). In the case where the check fails, reject
the construct at compile time instead of generating an
unconditional raise of Program_Error.
* doc/gnat_rm/representation_clauses_and_pragmas.rst: Update
documentation to reflect these changes.
* gnat_rm.texi: Regenerate.
gcc/ada/doc/gnat_rm/representation_clauses_and_pragmas.rst
gcc/ada/gnat_rm.texi
gcc/ada/sem_ch13.adb