]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Get rid of Kill_Range_Checks flag on entities
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 24 Oct 2024 17:20:30 +0000 (19:20 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 12 Nov 2024 13:00:50 +0000 (14:00 +0100)
commit3b78393b39a848dadfe6f7b703cda01b9870b6bd
tree3ac9ff161c781e83c630118a18384c63c1c7aae3
parenta45219815d17b050abc25a6348bfe7c981399363
ada: Get rid of Kill_Range_Checks flag on entities

This flag is set in a single context, namely semantic analysis of record
type definitions, to avoid generating spurious range checks from it, and
a large testing campaign showed that, in practice, it makes a difference
in a single case, namely an access-to-constrained-array component with a
default expression, for example:

  type Acc_String is access all String (1 .. 100);

  type Rec (D : Positive) is record
    A : Acc_String := new String (1 .. D);
  end record;

Now there is another mechanism implemented in Process_Range_Expr_In_Decl to
avoid generating spurious range checks, which does not work in this specific
case but can be made to work with a small tweak to Denotes_Discriminant.

gcc/ada/ChangeLog:

* checks.adb (Range_Checks_Suppressed): Remove test on the
Kill_Range_Checks flag.
* einfo.ads (Kill_Range_Checks): Delete.
* gen_il-fields.ads (Opt_Field_Enum): Remove Kill_Range_Checks.
* gen_il-gen-gen_entities.adb (Entity_Kind): Likewise.
* sem_ch3.adb (Record_Type_Declaration): Do not set the
Kill_Range_Checks flag.
* sem_util.adb (Denotes_Discriminant): In a default expression,
also return True for a discriminal.
gcc/ada/checks.adb
gcc/ada/einfo.ads
gcc/ada/gen_il-fields.ads
gcc/ada/gen_il-gen-gen_entities.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_util.adb