]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix wrong result for membership test of null in null-excluding access type
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Apr 2023 18:34:43 +0000 (20:34 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:20 +0000 (10:23 +0200)
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.

gcc/ada/exp_ch4.adb

index 3f864f2675ca316b93507211aa59d1b1efd04512..537d7a6311c320c811d8f3ddfcdce5fee9297dbf 100644 (file)
@@ -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;