From 1878be32235c6f9c52a5368b18650b215dbdd508 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 7 Mar 2016 08:08:27 +0000 Subject: [PATCH] decl.c (gnat_to_gnu_entity): Always mark the expression of a renaming manually in case #3. * gcc-interface/decl.c (gnat_to_gnu_entity) : Always mark the expression of a renaming manually in case #3. From-SVN: r234018 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/gcc-interface/decl.c | 10 ++++------ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/renaming9.adb | 12 ++++++++++++ gcc/testsuite/gnat.dg/renaming9.ads | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/renaming9.adb create mode 100644 gcc/testsuite/gnat.dg/renaming9.ads diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cb5aeb5..0573865 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2016-03-07 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : Always mark + the expression of a renaming manually in case #3. + 2016-03-02 Dominik Vogt * system-linux-s390.adsx: Enable Stack_Check_Probes. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 7ea5ff8..4b0ce28 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -1058,12 +1058,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) = 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 808b0c8..182e917 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-03-07 Eric Botcazou + + * gnat.dg/renaming9.ad[sb]: New testcase. + 2016-03-05 Jakub Jelinek PR c++/70084 diff --git a/gcc/testsuite/gnat.dg/renaming9.adb b/gcc/testsuite/gnat.dg/renaming9.adb new file mode 100644 index 0000000..c50243e --- /dev/null +++ b/gcc/testsuite/gnat.dg/renaming9.adb @@ -0,0 +1,12 @@ +-- { dg-do compile } + +package body Renaming9 is + + procedure Proc is + begin + Obj.I := 0; + end; + +begin + Obj.I := 0; +end Renaming9; diff --git a/gcc/testsuite/gnat.dg/renaming9.ads b/gcc/testsuite/gnat.dg/renaming9.ads new file mode 100644 index 0000000..ce6b4ed --- /dev/null +++ b/gcc/testsuite/gnat.dg/renaming9.ads @@ -0,0 +1,16 @@ +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; -- 2.7.4