diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-11-25 10:52:33 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2019-11-25 10:52:33 +0000 |
commit | fd8c1d5fa1960d3e427f16424d08808029a0d9da (patch) | |
tree | 1f4f07f9dedd972048298e0f87c3c20dbe9c7795 | |
parent | 6d5cfbe11efa9c00146463b5a93051189fdae9b5 (diff) |
PR ada/92362
* gcc-interface/trans.c (gnat_to_gnu) <N_Attribute_Definition_Clause>:
Use a temporary instead of clobbering the result with a freeze node.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/gcc-9-branch@278676 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/addr14.adb | 24 |
4 files changed, 38 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 1f13b9c06ab..e2efd819c04 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,11 @@ 2019-11-25 Eric Botcazou <ebotcazou@adacore.com> + PR ada/92362 + * gcc-interface/trans.c (gnat_to_gnu) <N_Attribute_Definition_Clause>: + Use a temporary instead of clobbering the result with a freeze node. + +2019-11-25 Eric Botcazou <ebotcazou@adacore.com> + PR ada/92575 * expect.c (__gnat_expect_poll [VMS, HPUX]): Fix typo. diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index f08f6aac330..2581b71d6fa 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -8308,7 +8308,7 @@ gnat_to_gnu (Node_Id gnat_node) gnat_temp = Entity (Name (gnat_node)); if (Freeze_Node (gnat_temp)) { - tree gnu_address = gnat_to_gnu (Expression (gnat_node)); + tree gnu_address = gnat_to_gnu (Expression (gnat_node)), gnu_temp; /* Get the value to use as the address and save it as the equivalent for the object; when it is frozen, gnat_to_gnu_entity will do the @@ -8318,7 +8318,7 @@ gnat_to_gnu (Node_Id gnat_node) of the object is limited and it is initialized with the result of a function call. */ if (Is_Subprogram (gnat_temp)) - gnu_result = gnu_address; + gnu_temp = gnu_address; else { tree gnu_type = gnat_to_gnu_type (Etype (gnat_temp)); @@ -8327,11 +8327,11 @@ gnat_to_gnu (Node_Id gnat_node) gnu_type = build_reference_type_for_mode (gnu_type, ptr_mode, true); gnu_address = convert (gnu_type, gnu_address); - gnu_result + gnu_temp = build_unary_op (INDIRECT_REF, NULL_TREE, gnu_address); } - save_gnu_tree (gnat_temp, gnu_result, true); + save_gnu_tree (gnat_temp, gnu_temp, true); } break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f3a84448206..c9e38713caa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-11-25 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/addr14.adb: New test. + 2019-11-21 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/91355 diff --git a/gcc/testsuite/gnat.dg/addr14.adb b/gcc/testsuite/gnat.dg/addr14.adb new file mode 100644 index 00000000000..e92c902f038 --- /dev/null +++ b/gcc/testsuite/gnat.dg/addr14.adb @@ -0,0 +1,24 @@ +-- { dg-do run } + +with System; + +procedure Addr14 is + + type Arr is array (1 .. 4) of aliased Integer; + + A : Arr := (1, 2, 3, 4); + I : Natural := 0; + + function Get_Address return System.Address is + begin + I := I + 1; + return A(I)'Address; + end; + + Foo : Integer with Address => Get_Address; + +begin + if Foo /= 1 then + raise Program_Error; + end if; +end; |