public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1455] [Ada] Variable-sized node types: improve error messages
@ 2021-06-15 10:21 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-15 10:21 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5fdd694a74ca51b6f4fa2317c7527a1eaf1e7f57

commit r12-1455-g5fdd694a74ca51b6f4fa2317c7527a1eaf1e7f57
Author: Bob Duff <duff@adacore.com>
Date:   Mon Mar 1 17:35:17 2021 -0500

    [Ada] Variable-sized node types: improve error messages
    
    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.

Diff:
---
 gcc/ada/gen_il-gen.adb | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb
index 6349841139b..36662895950 100644
--- a/gcc/ada/gen_il-gen.adb
+++ b/gcc/ada/gen_il-gen.adb
@@ -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 :=


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-15 10:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 10:21 [gcc r12-1455] [Ada] Variable-sized node types: improve error messages Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).