aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch3.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-10-24 19:20:30 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-12 14:00:50 +0100
commit3b78393b39a848dadfe6f7b703cda01b9870b6bd (patch)
tree3ac9ff161c781e83c630118a18384c63c1c7aae3 /gcc/ada/sem_ch3.adb
parenta45219815d17b050abc25a6348bfe7c981399363 (diff)
downloadgcc-3b78393b39a848dadfe6f7b703cda01b9870b6bd.zip
gcc-3b78393b39a848dadfe6f7b703cda01b9870b6bd.tar.gz
gcc-3b78393b39a848dadfe6f7b703cda01b9870b6bd.tar.bz2
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.
Diffstat (limited to 'gcc/ada/sem_ch3.adb')
-rw-r--r--gcc/ada/sem_ch3.adb17
1 files changed, 1 insertions, 16 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 28fc25d..aa95069 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -23079,22 +23079,7 @@ package body Sem_Ch3 is
Set_Direct_Primitive_Operations (T, New_Elmt_List);
end if;
- -- We must suppress range checks when processing record components in
- -- the presence of discriminants, since we don't want spurious checks to
- -- be generated during their analysis, but Suppress_Range_Checks flags
- -- must be reset the after processing the record definition.
-
- -- Note: this is the only use of Kill_Range_Checks, and is a bit odd,
- -- couldn't we just use the normal range check suppression method here.
- -- That would seem cleaner ???
-
- if Has_Discriminants (T) and then not Range_Checks_Suppressed (T) then
- Set_Kill_Range_Checks (T, True);
- Record_Type_Definition (Def, Prev);
- Set_Kill_Range_Checks (T, False);
- else
- Record_Type_Definition (Def, Prev);
- end if;
+ Record_Type_Definition (Def, Prev);
-- Exit from record scope