]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Attribute reference in subunit causes compiler Assertion_Error
authorSteve Baird <baird@adacore.com>
Wed, 13 May 2026 22:56:17 +0000 (15:56 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 4 Jun 2026 08:42:18 +0000 (10:42 +0200)
In the case of a separate subunit subprogram body, do not take a path that
is intended for the case where there is no enclosing declaration list.
The subunit's stub has an enclosing declaration list.

gcc/ada/ChangeLog:

* exp_attr.adb (Build_And_Insert_Type_Attr_Subp): Test for subunit case before
concluding that a subprogram body has no enclosing declaration list.

gcc/ada/exp_attr.adb

index 32b8297cd58000a9943886f57c4d81f1905ad96a..d1b9510ce1205c9fec93af0f9ac545fe5dfcddbd 100644 (file)
@@ -2197,6 +2197,7 @@ package body Exp_Attr is
                    (No (Insertion_Point)
                      or else List_Containing (Insertion_Point) /=
                        Declarations (Ancestor))
+                 and then Nkind (Parent (Ancestor)) /= N_Subunit
                then
                   Insertion_Point := First (Declarations (Ancestor));
                   Skip_Non_Source_Subps;