From: Eric Botcazou <ebotcazou@adacore.com>
To: gcc-patches@gcc.gnu.org
Subject: [Ada] Fix ICE on array type with aggregate component as bound
Date: Fri, 08 Apr 2011 20:22:00 -0000 [thread overview]
Message-ID: <201104082221.43317.ebotcazou@adacore.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 656 bytes --]
The compiler aborts on the declaration of an array type whose upper bound is a
component of an aggregate whose nominal subtype is a discriminated record type
which contains a component whose nominal subtype is a volatile discriminated
record type with a variant part and a size clause.
Tested on i586-suse-linux, applied on the mainline.
2011-04-08 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (Identifier_to_gnu): Do not return initializers
of aggregate types that contain a placeholder.
2011-04-08 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/aggr17.adb: New test.
* gnat.dg/aggr18.adb: Likewise.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 1076 bytes --]
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c (revision 172166)
+++ gcc-interface/trans.c (working copy)
@@ -1058,10 +1058,14 @@ Identifier_to_gnu (Node_Id gnat_node, tr
/* If we have a constant declaration and its initializer, try to return the
latter to avoid the need to call fold in lots of places and the need for
- elaboration code if this identifier is used as an initializer itself. */
+ elaboration code if this identifier is used as an initializer itself.
+ Don't do it for aggregate types that contain a placeholder since their
+ initializers cannot be manipulated easily. */
if (TREE_CONSTANT (gnu_result)
&& DECL_P (gnu_result)
- && DECL_INITIAL (gnu_result))
+ && DECL_INITIAL (gnu_result)
+ && !(AGGREGATE_TYPE_P (TREE_TYPE (gnu_result))
+ && type_contains_placeholder_p (TREE_TYPE (gnu_result))))
{
bool constant_only = (TREE_CODE (gnu_result) == CONST_DECL
&& !DECL_CONST_CORRESPONDING_VAR (gnu_result));
[-- Attachment #3: aggr17.adb --]
[-- Type: text/x-adasrc, Size: 554 bytes --]
-- { dg-do compile }
-- { dg-options "-gnatws" }
procedure Aggr17 is
type Enum is (A, B);
type Rec (D : Enum := Enum'First) is record
case D is
when A => X : Integer;
when B => null;
end case;
end record;
for Rec'Size use 128;
pragma Volatile (Rec);
type Config_T (D : Enum := Enum'First) is record
N : Natural;
R : Rec (D);
end record;
C : constant Config_T := (D => A, N => 1, R => (D => A, X => 0));
type Arr is array (Natural range 1 .. C.N) of Boolean;
begin
null;
end;
[-- Attachment #4: aggr18.adb --]
[-- Type: text/x-adasrc, Size: 545 bytes --]
-- { dg-do compile }
-- { dg-options "-gnatws" }
procedure Aggr18 is
type Enum is (A, B);
type Rec (D : Enum := Enum'First) is record
case D is
when A => X : Integer;
when B => null;
end case;
end record;
for Rec'Size use 128;
pragma Volatile (Rec);
type Config_T (D : Enum := Enum'First) is record
N : Natural;
R : Rec (D);
end record;
C : Config_T := (D => A, N => 1, R => (D => A, X => 0));
type Arr is array (Natural range 1 .. C.N) of Boolean;
begin
null;
end;
reply other threads:[~2011-04-08 20:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201104082221.43317.ebotcazou@adacore.com \
--to=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/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).