diff options
Diffstat (limited to 'gcc/ada/sem_util.adb')
-rw-r--r-- | gcc/ada/sem_util.adb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index c1af228..595d3d1 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -28309,11 +28309,29 @@ package body Sem_Util is R1 : constant Node_Id := Get_Referenced_Object (E1); R2 : constant Node_Id := Get_Referenced_Object (E2); begin - return Is_Entity_Name (R1) - and then Is_Entity_Name (R2) - and then Entity (R1) /= Entity (R2) - and then not Is_Formal (Entity (R1)) - and then not Is_Formal (Entity (R2)); + -- Two identifiers are statically different if they denote different + -- entities that are not formal parameters. + + if Is_Entity_Name (R1) and then Is_Entity_Name (R2) then + return Entity (R1) /= Entity (R2) + and then not Is_Formal (Entity (R1)) + and then not Is_Formal (Entity (R2)); + + -- A function call that does not return its result by reference denotes + -- a constant object that is statically different from anything else. + + elsif (Nkind (R1) = N_Function_Call + and then Is_Entity_Name (Name (R1)) + and then not Returns_By_Ref (Entity (Name (R1)))) + or else (Nkind (R2) = N_Function_Call + and then Is_Entity_Name (Name (R2)) + and then not Returns_By_Ref (Entity (Name (R2)))) + then + return R1 /= R2; + + else + return False; + end if; end Statically_Different; ----------------------------- |