[Ada] Expanded names in ghost assignments

Pierre-Marie de Rodat derodat@adacore.com
Mon Oct 19 09:54:22 GMT 2020


If the left-hand side of an assignment statement denotes a ghost
entity, then the assignment statement is a ghost assignment.
This patch fixes a bug in which ghost assignments were not
recognized in some cases. In particular, for an assignment
of the form "P.R.C := ...;", where P is a nonghost package,
R is a ghost record object, and C is a component, the assignment
was not recognized as ghost. This could cause compiler crashes
and undefined linker symbols in ghost-ignored mode.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* ghost.adb (Whole_Object_Ref): New function to compute the name
	of the whole object.
	(Mark_And_Set_Ghost_Assignment): Rewrite to use
	Whole_Object_Ref.  We need to partly analyze the left-hand side
	in order to distinguish expanded names and record components.
	* lib-xref.ads, lib-xref.adb (Deferred_References): Move table
	to body, and add Defer_Reference to update the table, avoiding
	duplicates.
	(Generate_Reference): Avoid duplicates.
	* sem_ch8.ads, sem_ch8.adb (Find_Direct_Name): Remove _OK
	parameters, which are no longer needed. Ignore errors in
	Ignore_Errors mode.
	* sem_util.ads, sem_util.adb (Preanalyze_Without_Errors): Make
	this public, so we can call it from Ghost.
	* errout.ads, scng.adb, sem_prag.adb: Minor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 27655 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201019/e4b50a5b/attachment-0001.bin>


More information about the Gcc-patches mailing list