[Ada] Silence spurious warning on instances of formal vectors

Message ID 20200608080042.GA90283@adacore.com
State New
Headers show
Series
  • [Ada] Silence spurious warning on instances of formal vectors
Related show

Commit Message

Pierre-Marie de Rodat June 8, 2020, 8 a.m.
Use pragma Warnings to silence a spurious warning that may occur in
instances of formal vectors.

Tested on x86_64-pc-linux-gnu, committed on trunk

2020-06-08  Claire Dross  <dross@adacore.com>

gcc/ada/

	* libgnat/a-cofove.adb (Insert_Space): The computation of Index
	generates a spurious compiler warning about a value not being in
	range for a statically dead branch.  Silence it using pragma
	Warnings.

Patch

--- gcc/ada/libgnat/a-cofove.adb
+++ gcc/ada/libgnat/a-cofove.adb
@@ -868,7 +868,11 @@  is
             --  less than 0, so it is safe to compute the following sum without
             --  fear of overflow.
 
+            pragma Warnings
+              (Off, "value not in range of type ""T"" defined at line 4");
             Index := No_Index + Index_Type'Base (Count_Type'Last);
+            pragma Warnings
+              (On, "value not in range of type ""T"" defined at line 4");
 
             if Index <= Index_Type'Last then