aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorBob Duff <duff@adacore.com>2018-05-23 10:23:19 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-05-23 10:23:19 +0000
commitaeaa0347e94b1dfa040809b3b098fcc0474d45f7 (patch)
tree0532e5d5338427fb6e8ad3a6e2de1b5ae80c5807 /gcc/ada
parent5e1c231ec79d0a772c24cb299f88d10ba076e9f2 (diff)
downloadgcc-aeaa0347e94b1dfa040809b3b098fcc0474d45f7.zip
gcc-aeaa0347e94b1dfa040809b3b098fcc0474d45f7.tar.gz
gcc-aeaa0347e94b1dfa040809b3b098fcc0474d45f7.tar.bz2
[Ada] Vectors: spurious error in -gnatwE mode
This patch fixes a bug in which if Ada.Containers.Vectors is instantiated with an Index_Type such that Index_Type'Base'Last is less than Count_Type'Last, and the -gnatwE switch is used, the compiler gives spurious error messages. The following test should compile quietly with -gnatwE: gnatmake short_vectors.ads -gnatwa -gnatwE -gnatf with Ada.Containers.Vectors; package Short_Vectors is type Index_Type is range 1 .. 256; package Map_Pkg is new Ada.Containers.Vectors (Index_Type => Index_Type, Element_Type => Integer); end Short_Vectors; 2018-05-23 Bob Duff <duff@adacore.com> gcc/ada/ * libgnat/a-convec.adb: (Insert, Insert_Space): Suppress warnings. The code in question is not reachable in the case where Count_Type'Last is out of range. From-SVN: r260590
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/libgnat/a-convec.adb10
2 files changed, 14 insertions, 2 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 1f91142..bb3d631 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-23 Bob Duff <duff@adacore.com>
+
+ * libgnat/a-convec.adb: (Insert, Insert_Space): Suppress warnings. The
+ code in question is not reachable in the case where Count_Type'Last is
+ out of range.
+
2018-05-23 Yannick Moy <moy@adacore.com>
* doc/gnat_rm/implementation_defined_pragmas.rst: Clarify meaning of
diff --git a/gcc/ada/libgnat/a-convec.adb b/gcc/ada/libgnat/a-convec.adb
index 285d3f5..b098860 100644
--- a/gcc/ada/libgnat/a-convec.adb
+++ b/gcc/ada/libgnat/a-convec.adb
@@ -999,9 +999,12 @@ package body Ada.Containers.Vectors is
-- We know that No_Index (the same as Index_Type'First - 1) is
-- less than 0, so it is safe to compute the following sum without
- -- fear of overflow.
+ -- fear of overflow. We need to suppress warnings, because
+ -- otherwise we get an error in -gnatwE mode.
+ pragma Warnings (Off);
Index := No_Index + Index_Type'Base (Count_Type'Last);
+ pragma Warnings (On);
if Index <= Index_Type'Last then
@@ -1657,9 +1660,12 @@ package body Ada.Containers.Vectors is
-- We know that No_Index (the same as Index_Type'First - 1) is
-- less than 0, so it is safe to compute the following sum without
- -- fear of overflow.
+ -- fear of overflow. We need to suppress warnings, because
+ -- otherwise we get an error in -gnatwE mode.
+ pragma Warnings (Off);
Index := No_Index + Index_Type'Base (Count_Type'Last);
+ pragma Warnings (On);
if Index <= Index_Type'Last then