public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix handling of PATs
@ 2021-05-06  7:58 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-05-06  7:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: Arnaud Charlet

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

When trying to compare two fields, one that's a packed array of known
length and one that's a packed array of unknown length, Expand_Packed_Eq
converts each side of the equality to its packed array type
and then says that's enough if the types are modular integer types.
That's correct, however, only if they're the same PATs.

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

gcc/ada/

	* exp_pakd.adb (Expand_Packed_Eq): Fix handling of PATs.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 773 bytes --]

diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb
--- a/gcc/ada/exp_pakd.adb
+++ b/gcc/ada/exp_pakd.adb
@@ -1909,9 +1909,10 @@ package body Exp_Pakd is
       --  where PAT is the packed array type. This works fine, since in the
       --  modular case we guarantee that the unused bits are always zeroes.
       --  We do have to compare the lengths because we could be comparing
-      --  two different subtypes of the same base type.
+      --  two different subtypes of the same base type. We can only do this
+      --  if the PATs on both sides are the same.
 
-      if Is_Modular_Integer_Type (PAT) then
+      if Is_Modular_Integer_Type (PAT) and then PAT = Etype (R) then
          Rewrite (N,
            Make_And_Then (Loc,
              Left_Opnd =>



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

only message in thread, other threads:[~2021-05-06  7:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06  7:58 [Ada] Fix handling of PATs 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).