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] tech debt: Clean up Uint fields, such as Esize
Date: Wed, 20 Oct 2021 19:27:43 +0000	[thread overview]
Message-ID: <20211020192743.GA3154200@adacore.com> (raw)

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

Use No_Uint to indicate "unknown" or "not yet known" for various fields
whose type is Uint, instead of using Uint_0. Otherwise Uint_0 could be
ambiguous -- it could also mean "value is known, and is zero". This
patch does not fix all bugs in this area, but fixes most of them, and
adds assertions that should prevent new ones.

Work around unset sizes:
Previous changes caused several latent bugs to become crashes in e.g.
gnat-llvm, because some size-related fields aren't set. Previously, unset
fields defaulted to Uint_0, but now they default to No_Uint, which crashes
on most operations, such as "=" and ">". This patch turns them back into latent
bugs by checking for No_Uint explictly.

Misc cleanup.

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

gcc/ada/

	* atree.ads: Comment improvements. How is a "completely new
	node" different from a "new node"? Document default values
	corresponding to field types.
	* exp_ch7.adb (Process_Tagged_Type_Declaration): Use
	higher-level Scope_Depth instead of Scope_Depth_Value.  Remove
	confusing comment: not clear what a "true" library level package
	is.
	* uintp.adb (Image_Out): Print No_Uint in a more readable way.
	* gen_il-gen.adb, gen_il-gen-gen_entities.adb,
	gen_il-gen-gen_nodes.adb, gen_il-types.ads: Tighten up the
	subtypes of fields whose type is Uint, where possible; use
	more-constrained subtypes such as Unat.
	* einfo-utils.adb, einfo-utils.ads, exp_attr.adb,
	exp_ch3.adb, exp_intr.adb, exp_unst.adb, exp_util.adb,
	freeze.adb, repinfo.adb, sem.adb, sem_ch12.adb, sem_ch13.adb,
	sem_ch3.adb, sem_ch8.adb, sem_util.adb, sprint.adb, treepr.adb:
	No longer use Uint_0 to indicate "unknown" or "not yet known"
	for various fields whose type is Uint. Use No_Uint for that,
	except in a small number of legacy cases that cause test
	failures. Protect many queries of such fields with calls to
	Known_... functions. Improve comments.
	* exp_aggr.adb: Likewise.
	(Is_OK_Aggregate): Check whether Csiz is present.
	(Aggr_Assignment_OK_For_Backend): Ensure we do not access an
	uninitialized size.
	* exp_strm.adb (Build_Elementary_Input_Call,
	Build_Elementary_Write_Call): Check whether P_Size is present.
	* cstand.adb: Leave Component_Size of Any_Composite unknown.
	Similar for RM_Size of Standard_Exception_Type.  These should
	not be used.
	* einfo.ads: Comment improvements.
	* exp_disp.ads: Minor.
	* gen_il-internals.ads, gen_il-internals.adb: Minor.
	* sinfo-utils.adb: Take advantage of full-coverage rules.
	* types.h: Minor.

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

                 reply	other threads:[~2021-10-20 19:27 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=20211020192743.GA3154200@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).