There are three "fields" that are aliases for the Renamed_Or_Alias field: Alias, Renamed_Entity, and Renamed_Object. The getters and setters were (mis)used more or less interchangeably, in violation of the comments.
This patch adds assertions to enforce the comments, and changes all of the call sites to obey the comments, except for some call sites of [Set_]Renamed_Object involving front end inlining and generation of debug information, which are too complicated to fix and which are well isolated from the other uses. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.ads, einfo-utils.adb (Alias, Set_Alias, Renamed_Entity, Set_Renamed_Entity, Renamed_Object, Set_Renamed_Object): Add assertions that reflect how these are supposed to be used and what they are supposed to return. (Renamed_Entity_Or_Object): New getter. (Set_Renamed_Object_Of_Possibly_Void): Setter that allows N to be E_Void. * checks.adb (Ensure_Valid): Use Renamed_Entity_Or_Object because this is called for both cases. * exp_dbug.adb (Debug_Renaming_Declaration): Use Renamed_Entity_Or_Object because this is called for both cases. Add assertions. * exp_util.adb (Possible_Bit_Aligned_Component): Likewise. * freeze.adb (Freeze_All_Ent): Likewise. * sem_ch5.adb (Within_Function): Likewise. * exp_attr.adb (Calculate_Header_Size): Call Renamed_Entity instead of Renamed_Object. * exp_ch11.adb (Expand_N_Raise_Statement): Likewise. * repinfo.adb (Find_Declaration): Likewise. * sem_ch10.adb (Same_Unit, Process_Spec_Clauses, Analyze_With_Clause, Install_Parents): Likewise. * sem_ch12.adb (Build_Local_Package, Needs_Body_Instantiated, Build_Subprogram_Renaming, Check_Formal_Package_Instance, Check_Generic_Actuals, In_Enclosing_Instance, Denotes_Formal_Package, Process_Nested_Formal, Check_Initialized_Types, Map_Formal_Package_Entities, Restore_Nested_Formal): Likewise. * sem_ch6.adb (Report_Conflict): Likewise. * sem_ch8.adb (Analyze_Exception_Renaming, Analyze_Generic_Renaming, Analyze_Package_Renaming, Is_Primitive_Operator_In_Use, Declared_In_Actual, Note_Redundant_Use): Likewise. * sem_warn.adb (Find_Package_Renaming): Likewise. * sem_elab.adb (Ultimate_Variable): Call Renamed_Object instead of Renamed_Entity. * exp_ch6.adb (Get_Function_Id): Call Set_Renamed_Object_Of_Possibly_Void, because the defining identifer is still E_Void at this point. * sem_util.adb (Function_Call_Or_Allocator_Level): Likewise. Remove redundant (unreachable) code. (Is_Object_Renaming, Is_Valid_Renaming): Call Renamed_Object instead of Renamed_Entity. (Get_Fullest_View): Call Renamed_Entity instead of Renamed_Object. (Copy_Node_With_Replacement): Call Set_Renamed_Object_Of_Possibly_Void because the defining entity is sometimes E_Void. * exp_ch5.adb (Expand_N_Assignment_Statement): Protect a call to Renamed_Object with Is_Object to avoid assertion failure. * einfo.ads: Minor comment fixes. * inline.adb: Minor comment fixes. * tbuild.ads: Minor comment fixes.
patch.diff.gz
Description: application/gzip