Skip to content

Commit 09eced2

Browse files
swbairdMarc Poulhiès
authored andcommitted
ada: Follow up fixes.
Two follow-up fixes for the previous change for this issue. gcc/ada/ChangeLog: * exp_ch6.adb (Apply_Access_Discrims_Accessibility_Check): Do nothing and simply return if either Ada_Version <= Ada_95 or if the function being returned from lacks the extra formal parameter needed to perform the check (typically because the result is tagged).
1 parent 91fc017 commit 09eced2

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

gcc/ada/exp_ch6.adb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,34 @@ package body Exp_Ch6 is
899899
Constrained_Subtype : constant Entity_Id :=
900900
Constraint_Bearing_Subtype_If_Any (Exp);
901901
begin
902+
-- ??? Do not generate a check if version is Ada 95 (or earlier).
903+
-- It is unclear whether this is really correct, or is just a stopgap
904+
-- measure. Investigation is needed to decide how post-Ada-95 binding
905+
-- interpretation changes in RM 3.10.2 should interact with Ada 95's
906+
-- return-by-reference model for functions with limited result types
907+
-- (which was abandoned in Ada 2005).
908+
909+
if Ada_Version <= Ada_95 then
910+
return;
911+
end if;
912+
902913
-- If we are returning a function call then that function will
903914
-- perform the needed check.
904915

905916
if Nkind (Unqualify (Exp)) = N_Function_Call then
906917
return;
907918
end if;
908919

920+
-- ??? Cope with the consequences of the Disable_Tagged_Cases flag
921+
-- in accessibility.adb (which can cause the extra formal parameter
922+
-- needed for the check(s) generated here to be missing in the case
923+
-- of a tagged result type); this is a workaround and can
924+
-- prevent generation of a required check.
925+
926+
if No (Extra_Accessibility_Of_Result (Func)) then
927+
return;
928+
end if;
929+
909930
Remove_Side_Effects (Exp);
910931

911932
while Present (Discr) loop

0 commit comments

Comments
 (0)