]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Variable-sized node types: improve error messages
authorBob Duff <duff@adacore.com>
Mon, 1 Mar 2021 22:35:17 +0000 (17:35 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 15 Jun 2021 10:19:18 +0000 (06:19 -0400)
gcc/ada/

* gen_il-gen.adb (To_Bit_Offset): Use 'Base to avoid overflow in
computations in Last_Bit when Offset = 'Last.
(Choose_Offset): Give a better error message when we run out of
fields.  In particular, point out that
Gen_IL.Internals.Bit_Offset'Last needs to be increased.

gcc/ada/gen_il-gen.adb

index 6349841139bfd0407bc6306dc762c8a133028922..36662895950660623528abd46e14976fc77038ca 100644 (file)
@@ -860,9 +860,9 @@ package body Gen_IL.Gen is
       function Field_Size (F : Field_Enum) return Bit_Offset is
         (Field_Size (Field_Table (F).Field_Type));
 
-      function To_Bit_Offset (F : Field_Enum; Offset : Field_Offset)
-        return Bit_Offset is
-          (Bit_Offset (Offset) * Field_Size (F));
+      function To_Bit_Offset (F : Field_Enum; Offset : Field_Offset'Base)
+        return Bit_Offset'Base is
+          (Bit_Offset'Base (Offset) * Field_Size (F));
       function First_Bit (F : Field_Enum; Offset : Field_Offset)
         return Bit_Offset is
           (To_Bit_Offset (F, Offset));
@@ -964,7 +964,9 @@ package body Gen_IL.Gen is
                end if;
             end loop;
 
-            raise Illegal with "No available field offset for " & Image (F);
+            raise Illegal with "No available field offset for " & Image (F) &
+              "; need to increase Gen_IL.Internals.Bit_Offset'Last (" &
+              Image (Gen_IL.Internals.Bit_Offset'Last) & " is too small)";
          end Choose_Offset;
 
          Num_Concrete_Have_Field : array (Field_Enum) of Type_Count :=
This page took 0.065736 seconds and 5 git commands to generate.