diff mbox

[Ada] Implement AI05-0086-1 (consider null exclusion for static matching)

Message ID 20101019105507.GA8759@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Oct. 19, 2010, 10:55 a.m. UTC
This patch implements the requirement of AI05-0086-1 that access types
are only to be considered statically matching if their null exclusion
status matches. The following shows the new error message resulting
from this check (compiled with -gnat05):

     1. procedure StatCompat is
     2. begin
     3.    declare
     4.       type Ref is access Integer;
     5.       type R1 (D1 : not null Ref) is null record;
     6.       type R2 (D2 : Ref) is new R1 (D1 => D2);
                       |
        >>> subtype must be compatible with parent discriminant

     7.    begin
     8.       null;
     9.    end;
    10. end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2010-10-19  Robert Dewar  <dewar@adacore.com>

	* sem_eval.adb: Minor reformatting.

Comments

Duncan Sands Oct. 19, 2010, 11:05 a.m. UTC | #1
Hi Arnaud, this patch seems to only contain formatting changes.
The meat of it is commented out:

+         --  Also check that null exclusion matches (AI05-0086-1)
+         --  commented out because this causes many mail test failures ???
+
+         --  and then Can_Never_Be_Null (T1) = Can_Never_Be_Null (T2);

So I'm not sure how it can cause the testcase to pass :)

Ciao,

Duncan.
Arnaud Charlet Oct. 19, 2010, 12:16 p.m. UTC | #2
> Hi Arnaud, this patch seems to only contain formatting changes.
> The meat of it is commented out:
> 
> +         --  Also check that null exclusion matches (AI05-0086-1)
> +         --  commented out because this causes many mail test failures ???
> +
> +         --  and then Can_Never_Be_Null (T1) = Can_Never_Be_Null (T2);
> 
> So I'm not sure how it can cause the testcase to pass :)

Indeed, the code has been disabled at the last minute because of unexpected
errors, sorry for the confusion.

Arno
diff mbox

Patch

Index: sem_eval.adb
===================================================================
--- sem_eval.adb	(revision 165687)
+++ sem_eval.adb	(working copy)
@@ -4548,6 +4548,8 @@ 
       T2 : Entity_Id) return Boolean
    is
    begin
+      --  Scalar types
+
       if Is_Scalar_Type (T1) then
 
          --  Definitely compatible if we match
@@ -4606,11 +4608,20 @@ 
             end;
          end if;
 
+      --  Access types
+
       elsif Is_Access_Type (T1) then
          return not Is_Constrained (T2)
-           or else Subtypes_Statically_Match
-                     (Designated_Type (T1), Designated_Type (T2));
+                  or else Subtypes_Statically_Match
+                            (Designated_Type (T1), Designated_Type (T2));
 
+         --  Also check that null exclusion matches (AI05-0086-1)
+         --  commented out because this causes many mail test failures ???
+
+         --  and then Can_Never_Be_Null (T1) = Can_Never_Be_Null (T2);
+
+      --  All other cases
+
       else
          return (Is_Composite_Type (T1) and then not Is_Constrained (T2))
            or else Subtypes_Statically_Match (T1, T2);