decl.c (gnat_to_gnu_entity): Use case #1 for the renaming of an address.
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 18 Nov 2015 18:31:42 +0000 (18:31 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 18 Nov 2015 18:31:42 +0000 (18:31 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Use case #1
for the renaming of an address.

From-SVN: r230560

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/renaming7.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/renaming7_pkg.ads [new file with mode: 0644]

index 3ffb45e7114c79f89e428ae0696f1737ce58fff5..6c4a850a9a97936161218d533ff2cfad020b9518 100644 (file)
@@ -1,3 +1,8 @@
+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>
 
        * gcc-interface/trans.c (fold_constant_decl_in_expr) <ARRAY_REF>: If
index ceeb9958617bdcbfffc1e6aaa60714542ed6792a..883b2755df45428fa687ee9ab1e4a83a5eca5807 100644 (file)
@@ -963,8 +963,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
               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_entity, tree gnu_expr, int definition)
              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))
index d0c4b6c95f56ddd021e26956c0566785ed64cd7d..b4e2db51fd2969d9d1e1ded1e3029f7a2c4e6955 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/renaming7.adb: New test.
+       * gnat.dg/renaming7_pkg.ads: New helper.
+
 2015-11-18  Ajit Agarwal  <ajitkum@xilinx.com>
 
        PR tree-optimization/68402
diff --git a/gcc/testsuite/gnat.dg/renaming7.adb b/gcc/testsuite/gnat.dg/renaming7.adb
new file mode 100644 (file)
index 0000000..2a93f9e
--- /dev/null
@@ -0,0 +1,12 @@
+-- { 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;
diff --git a/gcc/testsuite/gnat.dg/renaming7_pkg.ads b/gcc/testsuite/gnat.dg/renaming7_pkg.ads
new file mode 100644 (file)
index 0000000..4014adc
--- /dev/null
@@ -0,0 +1,5 @@
+package Renaming7_Pkg is
+
+  A : Integer;
+
+end Renaming7_Pkg;