]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
sem_ch6.adb (Set_Formal_Mode): Set Can_Never_Be_Null on an IN or IN OUT formal parame...
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 26 Sep 2011 08:37:32 +0000 (08:37 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 26 Sep 2011 08:37:32 +0000 (08:37 +0000)
* sem_ch6.adb (Set_Formal_Mode): Set Can_Never_Be_Null on an IN or IN
OUT formal parameter which is of an null-exclusion access subtype.

Co-Authored-By: Robert Dewar <dewar@adacore.com>
From-SVN: r179183

gcc/ada/ChangeLog
gcc/ada/sem_ch6.adb

index 47842198be60e8d4c62251a588c0da0617e726ea..b747f8ab2df5f239a5db79ab64ebb6e35154ae39 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-26  Eric Botcazou  <ebotcazou@adacore.com>
+           Robert Dewar  <dewar@adacore.com>
+
+       * sem_ch6.adb (Set_Formal_Mode): Set Can_Never_Be_Null on an IN or IN
+       OUT formal parameter which is of an null-exclusion access subtype.
+
 2011-09-26  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/ada-tree.h (DECL_CAN_NEVER_BE_NULL_P): New macro.
index b2a046bb4f8e9b4b15e8389e17a889f9226b8338..a9a45bc6445fe76b44be7e713acc7c578726bb98 100644 (file)
@@ -10267,6 +10267,16 @@ package body Sem_Ch6 is
         and then Can_Never_Be_Null (Etype (Formal_Id))
       then
          Set_Is_Known_Non_Null (Formal_Id);
+
+         --  We can also set Can_Never_Be_Null (thus preventing some junk
+         --  access checks) for the case of an IN parameter, which cannot
+         --  be changed, or for an IN OUT parameter, which can be changed but
+         --  not to a null value. But for an OUT parameter, the initial value
+         --  passed in can be null, so we can't set this flag in that case.
+
+         if Ekind (Formal_Id) /= E_Out_Parameter then
+            Set_Can_Never_Be_Null (Formal_Id);
+         end if;
       end if;
 
       Set_Mechanism (Formal_Id, Default_Mechanism);