aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-07-22 13:56:55 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-22 13:56:55 +0000
commit52860cc145a7075a9f30840703f96b242cd0150f (patch)
treed2c89e2e6587d36af6c2b95c94a23dbeb3c04cc5 /gcc/ada
parentf3d2fbfdb83bcc60d72824daf7a470c0e5398854 (diff)
downloadgcc-52860cc145a7075a9f30840703f96b242cd0150f.zip
gcc-52860cc145a7075a9f30840703f96b242cd0150f.tar.gz
gcc-52860cc145a7075a9f30840703f96b242cd0150f.tar.bz2
[Ada] Fix wrong assumption on bounds in GNAT.Encode_String
This fixes a couple of oversights in the GNAT.Encode_String package, whose effect is to assume that all the strings have a lower bound of 1. 2019-07-22 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * libgnat/g-encstr.adb (Encode_Wide_String): Fix oversight. (Encode_Wide_Wide_String): Likewise. gcc/testsuite/ * gnat.dg/encode_string1.adb, gnat.dg/encode_string1_pkg.adb, gnat.dg/encode_string1_pkg.ads: New testcase. From-SVN: r273674
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/libgnat/g-encstr.adb8
2 files changed, 9 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6fc9d1c..cf8b171 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
+ * libgnat/g-encstr.adb (Encode_Wide_String): Fix oversight.
+ (Encode_Wide_Wide_String): Likewise.
+
+2019-07-22 Eric Botcazou <ebotcazou@adacore.com>
+
* sem_warn.adb (Find_Var): Bail out for a function call with an
Out or In/Out parameter.
diff --git a/gcc/ada/libgnat/g-encstr.adb b/gcc/ada/libgnat/g-encstr.adb
index 81a73fd..b115c8a 100644
--- a/gcc/ada/libgnat/g-encstr.adb
+++ b/gcc/ada/libgnat/g-encstr.adb
@@ -79,12 +79,12 @@ package body GNAT.Encode_String is
Ptr : Natural;
begin
- Ptr := S'First;
+ Ptr := Result'First;
for J in S'Range loop
Encode_Wide_Character (S (J), Result, Ptr);
end loop;
- Length := Ptr - S'First;
+ Length := Ptr - Result'First;
end Encode_Wide_String;
-----------------------------
@@ -108,12 +108,12 @@ package body GNAT.Encode_String is
Ptr : Natural;
begin
- Ptr := S'First;
+ Ptr := Result'First;
for J in S'Range loop
Encode_Wide_Wide_Character (S (J), Result, Ptr);
end loop;
- Length := Ptr - S'First;
+ Length := Ptr - Result'First;
end Encode_Wide_Wide_String;
---------------------------