]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Change Constraint_Error into Data_Error in Text_IO to respect ARM
authorMathias Aparicio <aparicio@adacore.com>
Mon, 18 May 2026 12:48:48 +0000 (14:48 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 5 Jun 2026 07:29:00 +0000 (09:29 +0200)
Before the patch, Get_Upper_Half_Char_Immed and Get_Upper_Half_Char would
both raise a Constraint_Error when the input exceeded a bound. However,
ARM A.13 (13) states that the procedure Get should propagate the
Data_Error exception if the input value does not belong to the range of
the required subtype.

Now propagate Data_Error.

gcc/ada/ChangeLog:

* libgnat/a-textio.adb
(Get_Upper_Half_Char, Get_Upper_Half_Char_Immed): Replace
Constraint_Error with Data_Error

gcc/ada/libgnat/a-textio.adb

index c8e7638f239ecdb0999f65a1b70465d0a992a763..52b7b4b4d0492b8669a4f8207c96135b2cbb25ff 100644 (file)
@@ -100,7 +100,7 @@ is
    --  upper half character value from the given File. The first byte has
    --  already been read and is passed in C. The character value is returned as
    --  the result, and the file pointer is bumped past the character.
-   --  Constraint_Error is raised if the encoded value is outside the bounds of
+   --  Data_Error is raised if the encoded value is outside the bounds of
    --  type Character.
 
    function Get_Upper_Half_Char_Immed
@@ -806,7 +806,7 @@ is
       Result := WC_In (C, File.WC_Method);
 
       if Wide_Character'Pos (Result) > 16#FF# then
-         raise Constraint_Error with
+         raise Data_Error with
            "invalid wide character in Text_'I'O input";
       else
          return Character'Val (Wide_Character'Pos (Result));
@@ -849,7 +849,7 @@ is
       Result := WC_In (C, File.WC_Method);
 
       if Wide_Character'Pos (Result) > 16#FF# then
-         raise Constraint_Error with
+         raise Data_Error with
            "invalid wide character in Text_'I'O input";
       else
          return Character'Val (Wide_Character'Pos (Result));