public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Bob Duff <duff@adacore.com>
Subject: [Ada] Renamed_Or_Alias cleanup
Date: Mon, 25 Oct 2021 15:08:55 +0000	[thread overview]
Message-ID: <20211025150855.GA346349@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3019 bytes --]

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.

[-- Attachment #2: patch.diff.gz --]
[-- Type: application/gzip, Size: 8433 bytes --]

                 reply	other threads:[~2021-10-25 15:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211025150855.GA346349@adacore.com \
    --to=derodat@adacore.com \
    --cc=duff@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).