public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-894] [Ada] Propagate null-exclusion to anonymous access types
@ 2022-06-01  8:45 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-06-01  8:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2ae98c3a75102cb4dbb9b8da690952a9971d4e93

commit r13-894-g2ae98c3a75102cb4dbb9b8da690952a9971d4e93
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Fri May 6 17:23:25 2022 +0200

    [Ada] Propagate null-exclusion to anonymous access types
    
    When analyzing an array or record type declaration whose component has a
    constrained access type, e.g.:
    
       type Buffer_Acc is not null access all String;
    
       type Buffer_Rec is record
          Data : Buffer_Acc (1 .. 10);
       end record;
    
       type Buffer_Arr is array (Boolean) of Buffer_Acc (1 .. 10);
    
    we propagated various properties of the unconstrained access type (e.g.
    the designated type, access-to-constant flag), but forgot to propagate
    the null-exclusion.
    
    For GNAT it didn't make a big difference, because the (anonymous)
    component type was never subject to legality checks. The "value
    tracking" optimisation machinery, which also deals with null values,
    only works for entire objects and doesn't care about components.
    However, GNATprove uses this flag when an access-to-component object is
    dereferenced.
    
    gcc/ada/
    
            * sem_ch3.adb (Constrain_Access): Propagate null-exclusion flag
            from parent type.

Diff:
---
 gcc/ada/sem_ch3.adb | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index b7f26a3a066..f91d3edfefd 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -13535,6 +13535,7 @@ package body Sem_Ch3 is
       Set_Directly_Designated_Type (Def_Id, Desig_Subtype);
       Set_Depends_On_Private       (Def_Id, Has_Private_Component (Def_Id));
       Set_Is_Access_Constant       (Def_Id, Is_Access_Constant (T));
+      Set_Can_Never_Be_Null        (Def_Id, Can_Never_Be_Null (T));
 
       Conditional_Delay (Def_Id, T);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-01  8:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01  8:45 [gcc r13-894] [Ada] Propagate null-exclusion to anonymous access types Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).