]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix compile-time failure due to duplicated attribute subprograms.
authorSteve Baird <baird@adacore.com>
Mon, 13 Jan 2025 22:18:26 +0000 (14:18 -0800)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 5 Jun 2025 08:18:33 +0000 (10:18 +0200)
commit755f3d9ba29953f2bee6e46644a5233b31ea2f4f
treee25407b874e7523087c09553b817f81900bae8bc
parent453724978e48cc0fb9854cbb961ba2cd96192ba8
ada: Fix compile-time failure due to duplicated attribute subprograms.

For a given type, and for certain attributes (the 4 streaming attributes
and, for Ada2022, the Put_Image attribute), the compiler needs to keep track
of whether a subprogram has already been generated for the given
type/attribute pair. In some cases this was being done incorrectly;
the compiler ended up generating duplicate subprograms (with the same
name), resulting in compilation failures. This could occur if the prefix
of an attribute reference denoted a subtype (more precisely, a non-first
subtype). This includes the case of a subtype declaration that is implicitly
introduced by the compiler to capture the binding between a formal type
in a generic and the corresponding actual type in an instantiation.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): When accessing the
maps declared in package Cached_Attribute_Ops, the key value
passed to Get or to Set should never be the entity node for a
subtype. Use the entity of the corresponding type declaration
instead.
gcc/ada/exp_attr.adb