* [Ada] Crash processing comparison of composite objects
@ 2017-04-25 13:05 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2017-04-25 13:05 UTC (permalink / raw)
To: gcc-patches; +Cc: Javier Miranda
[-- Attachment #1: Type: text/plain, Size: 963 bytes --]
Comparisons of composite objects may be internally transformed by the
frontend into a special kind of node that facilitates their internal
management. If processing the comparison causes the internal declaration
of a subtype declaration associated with some sub-expression, the backend
may crash when generating the code.
After this patch the following test compiles fine.
package Q is
type Rec (D : Positive) is record
S : String (1 .. D);
end record;
type Field_T is (One);
type Mask_T is array (Field_T) of Boolean;
function F return Rec;
end Q;
with Q; use Q;
procedure P (A : Rec) is
M : Mask_T;
use type Rec;
begin
M := (One => A /= F);
end;
Command: gcc -c p.adb
Tested on x86_64-pc-linux-gnu, committed on trunk
2017-04-25 Javier Miranda <miranda@adacore.com>
* sem_util.adb (New_Copy_Tree.Visit_Entity): Extend previous change
to generate new entities for subtype declarations located in
Expression_With_Action nodes.
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1567 bytes --]
Index: sem_util.adb
===================================================================
--- sem_util.adb (revision 247212)
+++ sem_util.adb (working copy)
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
+-- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -17120,10 +17120,12 @@
pragma Assert (not Is_Itype (Old_Entity));
pragma Assert (Nkind (Old_Entity) in N_Entity);
- -- Restrict entity creation to variable declarations. There is no
- -- need to create variables declared in inner scopes.
+ -- Restrict entity creation to declarations of constants, variables
+ -- and subtypes. There is no need to duplicate entities declared in
+ -- inner scopes.
- if not Ekind_In (Old_Entity, E_Constant, E_Variable)
+ if (not Ekind_In (Old_Entity, E_Constant, E_Variable)
+ and then Nkind (Parent (Old_Entity)) /= N_Subtype_Declaration)
or else EWA_Inner_Scope_Level > 0
then
return;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-04-25 12:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25 13:05 [Ada] Crash processing comparison of composite objects Arnaud Charlet
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).