diff options
author | Arnaud Charlet <charlet@adacore.com> | 2020-02-17 12:41:37 -0500 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-08 03:51:10 -0400 |
commit | 4b8c2c4ba3566f8dd6d256e4b93321410782a0b4 (patch) | |
tree | aaf437ff87e097d88686df3196640419c85f94fe /gcc/ada | |
parent | 8eda13a49e566270f04323dbec11b2e86d3ddccc (diff) | |
download | gcc-4b8c2c4ba3566f8dd6d256e4b93321410782a0b4.zip gcc-4b8c2c4ba3566f8dd6d256e4b93321410782a0b4.tar.gz gcc-4b8c2c4ba3566f8dd6d256e4b93321410782a0b4.tar.bz2 |
[Ada] AI12-0228 Properties of qualified expressions used as names
2020-06-08 Arnaud Charlet <charlet@adacore.com>
gcc/ada/
* sem_ch8.adb (Analyze_Object_Renaming): Update Get_Object_Name
to go through N_Qualified_Expression and N_Type_Conversion. Fix
another case of wrong usage of E_Anonymous_Access_Type instead
of Anonymous_Access_Kind.
* sem_util.adb (Is_Dependent_Component_Of_Mutable_Object): Work
on the original node.
(Is_Aliased_View): Take into account N_Qualified_Expression.
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/sem_ch8.adb | 31 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 17 |
2 files changed, 32 insertions, 16 deletions
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index 709a839..4d9b5ba 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -844,18 +844,23 @@ package body Sem_Ch8 is begin Obj_Nam := Nod; while Present (Obj_Nam) loop - if Nkind_In (Obj_Nam, N_Attribute_Reference, - N_Explicit_Dereference, - N_Indexed_Component, - N_Slice) - then - Obj_Nam := Prefix (Obj_Nam); + case Nkind (Obj_Nam) is + when N_Attribute_Reference + | N_Explicit_Dereference + | N_Indexed_Component + | N_Slice + => + Obj_Nam := Prefix (Obj_Nam); - elsif Nkind (Obj_Nam) = N_Selected_Component then - Obj_Nam := Selector_Name (Obj_Nam); - else - exit; - end if; + when N_Selected_Component => + Obj_Nam := Selector_Name (Obj_Nam); + + when N_Qualified_Expression | N_Type_Conversion => + Obj_Nam := Expression (Obj_Nam); + + when others => + exit; + end case; end loop; return Obj_Nam; @@ -1046,8 +1051,8 @@ package body Sem_Ch8 is if Nkind (Nam) = N_Type_Conversion and then not Comes_From_Source (Nam) - and then Ekind (Etype (Expression (Nam))) = E_Anonymous_Access_Type - and then Ekind (T) /= E_Anonymous_Access_Type + and then Ekind (Etype (Expression (Nam))) in Anonymous_Access_Kind + and then Ekind (T) not in Anonymous_Access_Kind then Wrong_Type (Expression (Nam), T); -- Should we give better error??? end if; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 4f7d2d0..f359fa2 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -13736,6 +13736,13 @@ package body Sem_Util is return Is_Tagged_Type (Etype (Obj)) and then Is_Aliased_View (Expression (Obj)); + -- Ada 202x AI12-0228 + + elsif Nkind (Obj) = N_Qualified_Expression + and then Ada_Version >= Ada_2012 + then + return Is_Aliased_View (Expression (Obj)); + elsif Nkind (Obj) = N_Explicit_Dereference then return Nkind (Original_Node (Obj)) /= N_Function_Call; @@ -14582,6 +14589,8 @@ package body Sem_Util is Deref := Prefix (Deref); end loop; + Deref := Original_Node (Deref); + -- If the prefix is a qualified expression of a variable, then function -- Is_Variable will return False for that because a qualified expression -- denotes a constant view, so we need to get the name being qualified @@ -14599,9 +14608,11 @@ package body Sem_Util is if Is_Variable (Object) or else Is_Variable (Deref) - or else (Ada_Version >= Ada_2005 - and then (Nkind (Deref) = N_Explicit_Dereference - or else Is_Access_Type (Etype (Deref)))) + or else + (Ada_Version >= Ada_2005 + and then (Nkind (Deref) = N_Explicit_Dereference + or else (Present (Etype (Deref)) + and then Is_Access_Type (Etype (Deref))))) then if Nkind (Object) = N_Selected_Component then |