diff options
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r-- | gcc/ada/sem_attr.adb | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index c0be95d..cd7691f 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -1358,13 +1358,23 @@ package body Sem_Attr is -- appear on a subprogram renaming, when the renamed entity is an -- attribute reference. - if not Nkind_In (Subp_Decl, N_Abstract_Subprogram_Declaration, - N_Entry_Declaration, - N_Generic_Subprogram_Declaration, - N_Subprogram_Body, - N_Subprogram_Body_Stub, - N_Subprogram_Declaration, - N_Subprogram_Renaming_Declaration) + -- Generating C code the internally built nested _postcondition + -- subprograms are inlined; after expanded, inlined aspects are + -- located in the internal block generated by the frontend. + + if Nkind (Subp_Decl) = N_Block_Statement + and then Modify_Tree_For_C + and then In_Inlined_Body + then + null; + + elsif not Nkind_In (Subp_Decl, N_Abstract_Subprogram_Declaration, + N_Entry_Declaration, + N_Generic_Subprogram_Declaration, + N_Subprogram_Body, + N_Subprogram_Body_Stub, + N_Subprogram_Declaration, + N_Subprogram_Renaming_Declaration) then return; end if; @@ -5276,6 +5286,9 @@ package body Sem_Attr is -- Local variables + In_Inlined_C_Postcondition : constant Boolean := + Modify_Tree_For_C and then In_Inlined_Body; + Legal : Boolean; Pref_Id : Entity_Id; Spec_Id : Entity_Id; @@ -5309,10 +5322,7 @@ package body Sem_Attr is -- The exception to this rule is when generating C since in this case -- postconditions are inlined. - if No (Spec_Id) - and then Modify_Tree_For_C - and then In_Inlined_Body - then + if No (Spec_Id) and then In_Inlined_C_Postcondition then Spec_Id := Entity (P); elsif not Legal then @@ -5325,7 +5335,11 @@ package body Sem_Attr is -- Instead, rewrite the attribute as a reference to formal parameter -- _Result of the _Postconditions procedure. - if Chars (Spec_Id) = Name_uPostconditions then + if Chars (Spec_Id) = Name_uPostconditions + or else + (In_Inlined_C_Postcondition + and then Nkind (Parent (Spec_Id)) = N_Block_Statement) + then Rewrite (N, Make_Identifier (Loc, Name_uResult)); -- The type of formal parameter _Result is that of the function |