aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorClaire Dross <dross@adacore.com>2023-06-14 13:05:12 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-06-27 14:05:51 +0200
commitcba529bc70be52bbc7796faea212fb694d2d25a4 (patch)
tree3bc309abb329b255299988ddc420c862d3b3fa4f /gcc
parentfb36f0187808d8486b9eb7442aacf13e7e2d3ed9 (diff)
downloadgcc-cba529bc70be52bbc7796faea212fb694d2d25a4.zip
gcc-cba529bc70be52bbc7796faea212fb694d2d25a4.tar.gz
gcc-cba529bc70be52bbc7796faea212fb694d2d25a4.tar.bz2
ada: Correct the contract of Ada.Text_IO.Get_Line
Item might not be entirely initialized after a call to Get_Line. gcc/ada/ * libgnat/a-textio.ads (Get_Line): Use Relaxed_Initialization on the Item parameter of Get_Line.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/libgnat/a-textio.ads22
1 files changed, 13 insertions, 9 deletions
diff --git a/gcc/ada/libgnat/a-textio.ads b/gcc/ada/libgnat/a-textio.ads
index ddbbd85..4318b6c 100644
--- a/gcc/ada/libgnat/a-textio.ads
+++ b/gcc/ada/libgnat/a-textio.ads
@@ -523,24 +523,28 @@ is
Item : out String;
Last : out Natural)
with
- Pre => Is_Open (File) and then Mode (File) = In_File,
- Post =>
+ Relaxed_Initialization => Item,
+ Pre => Is_Open (File) and then Mode (File) = In_File,
+ Post =>
(if Item'Length > 0 then Last in Item'First - 1 .. Item'Last
- else Last = Item'First - 1),
- Global => (In_Out => File_System),
- Exceptional_Cases => (End_Error => Item'Length'Old > 0);
+ else Last = Item'First - 1)
+ and (for all I in Item'First .. Last => Item (I)'Initialized),
+ Global => (In_Out => File_System),
+ Exceptional_Cases => (End_Error => Item'Length'Old > 0);
procedure Get_Line
(Item : out String;
Last : out Natural)
with
- Post =>
+ Relaxed_Initialization => Item,
+ Post =>
Line_Length'Old = Line_Length
and Page_Length'Old = Page_Length
and (if Item'Length > 0 then Last in Item'First - 1 .. Item'Last
- else Last = Item'First - 1),
- Global => (In_Out => File_System),
- Exceptional_Cases => (End_Error => Item'Length'Old > 0);
+ else Last = Item'First - 1)
+ and (for all I in Item'First .. Last => Item (I)'Initialized),
+ Global => (In_Out => File_System),
+ Exceptional_Cases => (End_Error => Item'Length'Old > 0);
function Get_Line (File : File_Type) return String with SPARK_Mode => Off;
pragma Ada_05 (Get_Line);