public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <derodat@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Ed Schonberg <schonberg@adacore.com>
Subject: [Ada] Attribute Img on derived types
Date: Fri, 16 Oct 2020 03:35:40 -0400	[thread overview]
Message-ID: <20201016073540.GA65531@adacore.com> (raw)

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

Refinement of previous patch: the root type must be used for the image
of enumeration types, because the literal map is attached to the root
type even when derivations are present.
Fixes several ACATS and fixedbugs regressions involving 'Image.

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

gcc/ada/

	*  exp_imgv.adb (Expand_Image_Attribute):  Refine previous patch
	to use root type (and not base type) on enumeration types.

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

diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -481,9 +481,15 @@ package body Exp_Imgv is
 
       --  Ada 2020 allows 'Image on private types, so fetch the underlying
       --  type to obtain the structure of the type. We use the base type,
-      --  not the root type, to handle properly derived types.
+      --  not the root type, to handle properly derived types, but we use
+      --  the root type for enumeration types, because the literal map is
+      --  attached to the root. Should be inherited ???
 
-      Rtyp := Underlying_Type (Base_Type (Ptyp));
+      if Is_Enumeration_Type (Ptyp) then
+         Rtyp := Underlying_Type (Root_Type (Ptyp));
+      else
+         Rtyp := Underlying_Type (Base_Type (Ptyp));
+      end if;
 
       --  Enable speed-optimized expansion of user-defined enumeration types
       --  if we are compiling with optimizations enabled and enumeration type



             reply	other threads:[~2020-10-16  7:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16  7:35 Pierre-Marie de Rodat [this message]
2020-10-16  7:35 Pierre-Marie de Rodat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201016073540.GA65531@adacore.com \
    --to=derodat@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=schonberg@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).