decl.c (gnat_to_gnu_entity): Deal with PLUS_EXPR in the expression of a renaming.
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 13 Jun 2016 08:00:17 +0000 (08:00 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 13 Jun 2016 08:00:17 +0000 (08:00 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Deal with
PLUS_EXPR in the expression of a renaming.

From-SVN: r237360

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

index 41a6c619fe283b6585fb5d4d1480710584d4a519..4ab664865a6de855913799bce5f77053738952c3 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Variable>: Deal with
+       PLUS_EXPR in the expression of a renaming.
+
 2016-06-13  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/utils2.c (known_alignment) <CALL_EXPR>: Deal specially
index 8d4ff3fd76c7e3944cbe5b171bf71dc837859714..985527ea5ecfbe02e21c5a1f1505dd1ecc40c573 100644 (file)
@@ -1003,6 +1003,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
                 && !call_is_atomic_load (inner))
                || TREE_CODE (inner) == ADDR_EXPR
                || TREE_CODE (inner) == NULL_EXPR
+               || TREE_CODE (inner) == PLUS_EXPR
                || TREE_CODE (inner) == CONSTRUCTOR
                || CONSTANT_CLASS_P (inner)
                /* We need to detect the case where a temporary is created to
index 506c7f77b5331eba4649cc130295c2f4a3a4851f..803f9b023ff8cbfeed395e69f95fa324f20509cc 100644 (file)
@@ -1,3 +1,7 @@
+2016-06-13  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/renaming10.ad[sb]: New test.
+
 2016-06-13  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/70673
diff --git a/gcc/testsuite/gnat.dg/renaming10.adb b/gcc/testsuite/gnat.dg/renaming10.adb
new file mode 100644 (file)
index 0000000..07d4312
--- /dev/null
@@ -0,0 +1,12 @@
+-- { dg-do compile }
+
+package body Renaming10 is
+
+   function F (Input : Rec) return Natural is
+      Position : Natural renames Input.Position;
+      Index : Natural renames Natural'Succ(Position);
+   begin
+      return Index;
+   end;
+
+end Renaming10;
diff --git a/gcc/testsuite/gnat.dg/renaming10.ads b/gcc/testsuite/gnat.dg/renaming10.ads
new file mode 100644 (file)
index 0000000..aeb9fc1
--- /dev/null
@@ -0,0 +1,9 @@
+package Renaming10 is
+
+   type Rec is record
+      Position : Natural;
+   end record;
+
+   function F (Input : Rec) return Natural;
+
+end Renaming10;