aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sinfo.ads
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-06-01 13:25:53 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-06-20 13:25:28 +0200
commit865c5db7cbc16de9887d5941be9a63a7fa03692e (patch)
tree71bb2d3b35732cb26ab66e3e0f775057f6d5fc1b /gcc/ada/sinfo.ads
parent31edd39bc418ccb6b806767ff5cbefd98fb81fb5 (diff)
downloadgcc-865c5db7cbc16de9887d5941be9a63a7fa03692e.zip
gcc-865c5db7cbc16de9887d5941be9a63a7fa03692e.tar.gz
gcc-865c5db7cbc16de9887d5941be9a63a7fa03692e.tar.bz2
ada: Further fixes to handling of private views in instances
This removes more bypasses for private views in instances that are present in type predicates (Conforming_Types, Covers, Specific_Type and Wrong_Type), which in exchange requires additional work in Sem_Ch12 to restore the proper view of types during the instantiation of generic bodies. The main mechanism for this is the Has_Private_View flag, but it comes with the limitations that 1) there must be a direct reference to the global type in the generic construct (either a reference to a global object of this type or the explicit declaration of a local object of this type), which is not always the case e.g. for loop parameters and 2) it can deal with a single type at a time, e.g. it cannot deal with an array type and its component type if their respective views are not the same in the instance. To overcome the second limitation, a new Has_Secondary_Private_View flag is introduced to deal with a secondary type, which as of this writing is either the component type of an array type or the designated type of an access type (together they make up the vast majority of the problematic cases for the Has_Private_View flag alone). This new mechanism subsumes a specific treatment for them that was added in Copy_Generic_Node a few years ago, although a specific treatment still needs to be preserved for comparison and equality operators in a narrower case. Additional handling is also introduced to overcome the first limitation for loop parameters in Copy_Generic_Node, and a relaxed condition is used in Exp_Ch7.Convert_View to generate an unchecked conversion between views. gcc/ada/ * exp_ch7.adb (Convert_View): Detect more cases of mismatches for private types and use Implementation_Base_Type as main criterion. * gen_il-fields.ads (Opt_Field_Enum): Add Has_Secondary_Private_View * gen_il-gen-gen_nodes.adb (N_Expanded_Name): Likewise. (N_Direct_Name): Likewise. (N_Op): Likewise. * sem_ch12.ads (Check_Private_View): Document the usage of second flag Has_Secondary_Private_View. * sem_ch12.adb (Get_Associated_Entity): New function to retrieve the ultimate associated entity, if any. (Check_Private_View): Implement Has_Secondary_Private_View support. (Copy_Generic_Node): Remove specific treatment for Component_Type of an array type and Designated_Type of an access type. Add specific treatment for comparison and equality operators, as well as iterator and loop parameter specifications. (Instantiate_Type): Implement Has_Secondary_Private_View support. (Requires_Delayed_Save): Call Get_Associated_Entity. (Set_Global_Type): Implement Has_Secondary_Private_View support. * sem_ch6.adb (Conforming_Types): Remove bypass for private views in instances. * sem_type.adb (Covers): Return true if Is_Subtype_Of does so. Remove bypass for private views in instances. (Specific_Type): Likewise. * sem_util.adb (Wrong_Type): Likewise. * sinfo.ads (Has_Secondary_Private_View): Document new flag.
Diffstat (limited to 'gcc/ada/sinfo.ads')
-rw-r--r--gcc/ada/sinfo.ads39
1 files changed, 26 insertions, 13 deletions
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 8040a59..57fd704 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -389,21 +389,23 @@ package Sinfo is
-- abbreviations are used:
-- "plus fields for binary operator"
- -- Chars Name_Id for the operator
- -- Left_Opnd left operand expression
- -- Right_Opnd right operand expression
- -- Entity defining entity for operator
- -- Associated_Node for generic processing
- -- Do_Overflow_Check set if overflow check needed
- -- Has_Private_View set in generic units.
+ -- Chars Name_Id for the operator
+ -- Left_Opnd left operand expression
+ -- Right_Opnd right operand expression
+ -- Entity defining entity for operator
+ -- Associated_Node for generic processing
+ -- Do_Overflow_Check set if overflow check needed
+ -- Has_Private_View set in generic units
+ -- Has_Secondary_Private_View set in generic units
-- "plus fields for unary operator"
- -- Chars Name_Id for the operator
- -- Right_Opnd right operand expression
- -- Entity defining entity for operator
- -- Associated_Node for generic processing
- -- Do_Overflow_Check set if overflow check needed
- -- Has_Private_View set in generic units.
+ -- Chars Name_Id for the operator
+ -- Right_Opnd right operand expression
+ -- Entity defining entity for operator
+ -- Associated_Node for generic processing
+ -- Do_Overflow_Check set if overflow check needed
+ -- Has_Private_View set in generic units
+ -- Has_Secondary_Private_View set in generic units
-- "plus fields for expression"
-- Paren_Count number of parentheses levels
@@ -1457,6 +1459,13 @@ package Sinfo is
-- A flag present in N_Subprogram_Body and N_Task_Definition nodes to
-- flag the presence of a pragma Relative_Deadline.
+ -- Has_Secondary_Private_View
+ -- A flag present in generic nodes that have an entity, to indicate that
+ -- the node is either of an access type whose Designated_Type is private
+ -- or of an array type whose Component_Type is private. Used to exchange
+ -- private and full declarations if the visibility at instantiation is
+ -- different from the visibility at generic definition.
+
-- Has_Self_Reference
-- Present in N_Aggregate and N_Extension_Aggregate. Indicates that one
-- of the expressions contains an access attribute reference to the
@@ -2522,6 +2531,7 @@ package Sinfo is
-- Is_SPARK_Mode_On_Node
-- Is_Elaboration_Warnings_OK_Node
-- Has_Private_View (set in generic units)
+ -- Has_Secondary_Private_View (set in generic units)
-- Redundant_Use
-- Atomic_Sync_Required
-- plus fields for expression
@@ -2605,6 +2615,7 @@ package Sinfo is
-- Entity
-- Associated_Node
-- Has_Private_View (set in generic units)
+ -- Has_Secondary_Private_View (set in generic units)
-- plus fields for expression
-- Note: the Entity field will be missing (set to Empty) for character
@@ -5388,6 +5399,7 @@ package Sinfo is
-- Associated_Node Note this is shared with Entity
-- Etype
-- Has_Private_View (set in generic units)
+ -- Has_Secondary_Private_View (set in generic units)
-- Note: the Strval field may be set to No_String for generated
-- operator symbols that are known not to be string literals
@@ -8030,6 +8042,7 @@ package Sinfo is
-- Is_SPARK_Mode_On_Node
-- Is_Elaboration_Warnings_OK_Node
-- Has_Private_View (set in generic units)
+ -- Has_Secondary_Private_View (set in generic units)
-- Redundant_Use
-- Atomic_Sync_Required
-- plus fields for expression