aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-array-bounds.cc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-12-03 15:30:22 +0100
committerMarc Poulhiès <poulhies@adacore.com>2022-12-06 14:58:48 +0100
commitd1ab8eddca918f342b06a66fedb8fbc06c5532ab (patch)
treeb7d9e0f6b0e6d09fa2bf84689db9ac3f295c1c6c /gcc/gimple-array-bounds.cc
parentf459afaa679956df1f3c0243a87583e4d4b43a2e (diff)
downloadgcc-d1ab8eddca918f342b06a66fedb8fbc06c5532ab.zip
gcc-d1ab8eddca918f342b06a66fedb8fbc06c5532ab.tar.gz
gcc-d1ab8eddca918f342b06a66fedb8fbc06c5532ab.tar.bz2
ada: Use larger type for membership test of universal value
When a membership test is applied to a nonstatic expression of a universal type, for example an attribute whose type is universal_integer and whose prefix is not static, the operation is performed using the tested type that is determined by the choice list. In particular, a check that the value of the expression lies in the range of the tested type may be generated before the test is actually performed. This goes against the spirit of membership tests, which are typically used to guard a specific operation and ought not to fail a check in doing so. Therefore the resolution of the operands of membership tests is changed in this case to use the universal type instead of the tested type. The final computation of the type used to actually perform the test is left to the expander, which already has the appropriate circuitry. This nevertheless requires fixing an irregularity in the expansion of the subtype_mark form of membership tests, which was dependent on the presence of predicates for the subtype; the confusing name of a routine used by this expansion is also changed in the process. gcc/ada/ * exp_ch4.adb (Expand_N_In) <Substitute_Valid_Check>: Rename to... <Substitute_Valid_Test>: ...this. Use Is_Entity_Name to test for the presence of entity references. Do not warn or substitute a valid test for a test with a mark for a subtype that is predicated. Apply the same transformation for a test with a mark for a subtype that is predicated as for a subtype that is not. Remove useless return statement. * sem_res.adb (Resolve_Membership_Op): Perform a special resolution if the left operand is of a universal numeric type.
Diffstat (limited to 'gcc/gimple-array-bounds.cc')
0 files changed, 0 insertions, 0 deletions