aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorRichard Kenner <kenner@adacore.com>2021-12-08 17:11:26 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2022-01-07 16:24:06 +0000
commita3c3de386bfce7910745386f727fe6b5f83d2906 (patch)
tree3d595eae7c0bf701942c2749e9a6da99860d62c1 /gcc/ada
parent5e5030df8f223fb800d5ad7735c419a16b37dfaf (diff)
downloadgcc-a3c3de386bfce7910745386f727fe6b5f83d2906.zip
gcc-a3c3de386bfce7910745386f727fe6b5f83d2906.tar.gz
gcc-a3c3de386bfce7910745386f727fe6b5f83d2906.tar.bz2
[Ada] Use non-internal representation for access subprograms if UC to Address
gcc/ada/ * libgnat/g-spipat.ads (Boolean_Func, Natural_Func, VString_Func): Mark as Favor_Top_Level. * sem_ch13.adb (Validate_Unchecked_Conversion): Avoid using internal representation if Unchecked_Conversion between an access to subprogram and System.Address within the same unit.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/libgnat/g-spipat.ads6
-rw-r--r--gcc/ada/sem_ch13.adb16
2 files changed, 19 insertions, 3 deletions
diff --git a/gcc/ada/libgnat/g-spipat.ads b/gcc/ada/libgnat/g-spipat.ads
index 13d1e93..7b103c0 100644
--- a/gcc/ada/libgnat/g-spipat.ads
+++ b/gcc/ada/libgnat/g-spipat.ads
@@ -654,19 +654,19 @@ package GNAT.Spitbol.Patterns is
-- operations for constructing patterns that can be used in the pattern
-- matching operations provided.
- type Boolean_Func is access function return Boolean;
+ type Boolean_Func is access function return Boolean with Favor_Top_Level;
-- General Boolean function type. When this type is used as a formal
-- parameter type in this package, it indicates a deferred predicate
-- pattern. The function will be called when the pattern element is
-- matched and failure signalled if False is returned.
- type Natural_Func is access function return Natural;
+ type Natural_Func is access function return Natural with Favor_Top_Level;
-- General Natural function type. When this type is used as a formal
-- parameter type in this package, it indicates a deferred pattern.
-- The function will be called when the pattern element is matched
-- to obtain the currently referenced Natural value.
- type VString_Func is access function return VString;
+ type VString_Func is access function return VString with Favor_Top_Level;
-- General VString function type. When this type is used as a formal
-- parameter type in this package, it indicates a deferred pattern.
-- The function will be called when the pattern element is matched
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 8173532..f462951 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -17546,6 +17546,22 @@ package body Sem_Ch13 is
Set_No_Strict_Aliasing (Implementation_Base_Type (Target));
end if;
+ -- If the unchecked conversion is between Address and an access
+ -- subprogram type, show that we shouldn't use an internal
+ -- representation for the access subprogram type.
+
+ if Is_Access_Subprogram_Type (Target)
+ and then Is_Descendant_Of_Address (Source)
+ and then In_Same_Source_Unit (Target, N)
+ then
+ Set_Can_Use_Internal_Rep (Target, False);
+ elsif Is_Access_Subprogram_Type (Source)
+ and then Is_Descendant_Of_Address (Target)
+ and then In_Same_Source_Unit (Source, N)
+ then
+ Set_Can_Use_Internal_Rep (Source, False);
+ end if;
+
-- Generate N_Validate_Unchecked_Conversion node for back end in case
-- the back end needs to perform special validation checks.