diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-04-05 20:34:43 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-29 10:23:20 +0200 |
commit | 9098ae6cde6f6ec9818c180f28a7a7f7ebc6699d (patch) | |
tree | 5dcd70ef2d247e7140afe8575c0b43d2e8c63936 | |
parent | 7c784ca077ce181bb247c6f17407da5ee0b46b0c (diff) | |
download | gcc-9098ae6cde6f6ec9818c180f28a7a7f7ebc6699d.zip gcc-9098ae6cde6f6ec9818c180f28a7a7f7ebc6699d.tar.gz gcc-9098ae6cde6f6ec9818c180f28a7a7f7ebc6699d.tar.bz2 |
ada: Fix wrong result for membership test of null in null-excluding access type
The result must be False as per the RM 4.5.2 (30.2/4) clause.
gcc/ada/
* exp_ch4.adb (Expand_N_In): Deal specifically with a null operand.
-rw-r--r-- | gcc/ada/exp_ch4.adb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 3f864f2..537d7a6 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -6972,11 +6972,13 @@ package body Exp_Ch4 is -- If the null exclusion checks are not compatible, need to -- perform further checks. In other words, we cannot have - -- Ltyp including null and Typ excluding null. All other cases - -- are OK. + -- Ltyp including null or Lop being null, and Typ excluding + -- null. All other cases are OK. Check_Null_Exclusion := - Can_Never_Be_Null (Typ) and then not Can_Never_Be_Null (Ltyp); + Can_Never_Be_Null (Typ) + and then (not Can_Never_Be_Null (Ltyp) + or else Nkind (Lop) = N_Null); Typ := Designated_Type (Typ); end if; |