diff options
author | Justin Squirek <squirek@adacore.com> | 2021-07-19 14:03:35 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-10-04 08:45:06 +0000 |
commit | 6c30bccd6897e84465fff147f12133c282c02eae (patch) | |
tree | 1e8c4cde6425e11b28e6471b59a3510a7664c223 | |
parent | 6109bcaf72f86d206f1f76a1968a6cfeafa80576 (diff) | |
download | gcc-6c30bccd6897e84465fff147f12133c282c02eae.zip gcc-6c30bccd6897e84465fff147f12133c282c02eae.tar.gz gcc-6c30bccd6897e84465fff147f12133c282c02eae.tar.bz2 |
[Ada] Spurious non-variable error on implicitly dereferenced in-mode formal
gcc/ada/
* sem_util.adb (Is_Variable): Add check for implicitly
dereferenced access types
(Is_Dependent_Component_Of_Mutable_Object): Set Prefix_Type when
not specified.
-rw-r--r-- | gcc/ada/sem_util.adb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 47c3401..dfd2504 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -16868,6 +16868,15 @@ package body Sem_Util is end if; if Is_Entity_Name (P) then + -- The Etype may not be set on P (which is wrong) in certain + -- corner cases involving the deprecated front-end inlining of + -- subprograms (via -gnatN), so use the Etype set on the + -- the entity for these instances since we know it is present. + + if No (Prefix_Type) then + Prefix_Type := Etype (Entity (P)); + end if; + if Ekind (Entity (P)) = E_Generic_In_Out_Parameter then Prefix_Type := Base_Type (Prefix_Type); end if; @@ -21145,6 +21154,9 @@ package body Sem_Util is -- Is_Variable -- ----------------- + -- Should Is_Variable be refactored to better handle dereferences and + -- technical debt ??? + function Is_Variable (N : Node_Id; Use_Original_Node : Boolean := True) return Boolean @@ -21313,6 +21325,10 @@ package body Sem_Util is and then Nkind (Parent (E)) /= N_Exception_Handler) or else (K = E_Component and then not In_Protected_Function (E)) + or else (Present (Etype (E)) + and then Is_Access_Object_Type (Etype (E)) + and then Is_Access_Variable (Etype (E)) + and then Is_Dereferenced (N)) or else K = E_Out_Parameter or else K = E_In_Out_Parameter or else K = E_Generic_In_Out_Parameter |