This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Fix ICE on on indirect renaming of address at -O
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Nov 2015 19:29:30 +0100
- Subject: [Ada] Fix ICE on on indirect renaming of address at -O
- Authentication-results: sourceware.org; auth=none
Addresses cannot be directly subject to a renaming, but they can nevertheless
be renamed through a constant and thus need to be dealt with as other rvalues.
Tested on x86_64-suse-linux, applied on the mainline.
2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Use case #1
for the renaming of an address.
2015-11-18 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/renaming7.adb: New test.
* gnat.dg/renaming7_pkg.ads: New helper.
--
Eric Botcazou
Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c (revision 230557)
+++ gcc-interface/decl.c (working copy)
@@ -963,8 +963,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
function call is a constant object. Therefore, it can be the
inner object of a constant renaming and the renaming must be
fully instantiated, i.e. it cannot be a reference to (part of)
- an existing object. And treat null expressions, constructors
- and literals the same way. */
+ an existing object. And treat other rvalues (addresses, null
+ expressions, constructors and literals) the same way. */
tree inner = gnu_expr;
while (handled_component_p (inner) || CONVERT_EXPR_P (inner))
inner = TREE_OPERAND (inner, 0);
@@ -974,6 +974,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
inner = TREE_OPERAND (inner, 1);
if ((TREE_CODE (inner) == CALL_EXPR
&& !call_is_atomic_load (inner))
+ || TREE_CODE (inner) == ADDR_EXPR
|| TREE_CODE (inner) == NULL_EXPR
|| TREE_CODE (inner) == CONSTRUCTOR
|| CONSTANT_CLASS_P (inner))
-- { dg-do compile }
-- { dg-options "-O" }
with Renaming7_Pkg; use Renaming7_Pkg;
with System;
procedure Renaming7 is
C : constant System.Address := A'Address;
D : System.Address renames C;
begin
null;
end;
package Renaming7_Pkg is
A : Integer;
end Renaming7_Pkg;