* [Ada] Fix ICE on renaming of downcast of dereference
@ 2016-03-07 8:10 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2016-03-07 8:10 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 575 bytes --]
This is a regression present on the mainline: the compiler aborts on the
renaming of a type conversion of the dereference of an access value, if the
renaming is declared at library level and used in a subprogram.
Fixed thusly, tested on x86_64-suse-linux, applied on the mainline.
2016-03-07 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Always mark
the expression of a renaming manually in case #3.
2016-03-07 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/renaming9.ad[sb]: New testcase.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 968 bytes --]
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 233957)
+++ gcc-interface/decl.c (working copy)
@@ -1058,12 +1058,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
= elaborate_reference (gnu_expr, gnat_entity, definition,
&init);
- /* If we are not defining the entity, the expression will not
- be attached through DECL_INITIAL so it needs to be marked
- manually because it will likely be shared. Likewise for a
- dereference as it will be folded by the ADDR_EXPR below. */
- if ((!definition || TREE_CODE (renamed_obj) == INDIRECT_REF)
- && global_bindings_p ())
+ /* The expression needs to be marked manually because it will
+ likely be shared, even for a definition since the ADDR_EXPR
+ built below can cause the first few nodes to be folded. */
+ if (global_bindings_p ())
MARK_VISITED (renamed_obj);
if (type_annotate_only
[-- Attachment #3: renaming9.adb --]
[-- Type: text/x-adasrc, Size: 136 bytes --]
-- { dg-do compile }
package body Renaming9 is
procedure Proc is
begin
Obj.I := 0;
end;
begin
Obj.I := 0;
end Renaming9;
[-- Attachment #4: renaming9.ads --]
[-- Type: text/x-adasrc, Size: 295 bytes --]
package Renaming9 is
pragma Elaborate_Body;
type Object is tagged null record;
type Pointer is access all Object'Class;
type Derived is new Object with record
I : Integer;
end record;
Ptr : Pointer := new Derived;
Obj : Derived renames Derived (Ptr.all);
end Renaming9;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-03-07 8:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-07 8:10 [Ada] Fix ICE on renaming of downcast of dereference Eric Botcazou
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).