Commit 96826e28 by Eric Botcazou Committed by Eric Botcazou

utils2.c (gnat_protect_expr): Also protect only the address if the expression is…

utils2.c (gnat_protect_expr): Also protect only the address if the expression is the component of a dereference.

	* gcc-interface/utils2.c (gnat_protect_expr): Also protect only the
	address if the expression is the component of a dereference.
	Do not use a reference type for the final temporary reference.

From-SVN: r242358
parent 854c00dd
2016-11-13 Eric Botcazou <ebotcazou@adacore.com> 2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils2.c (gnat_protect_expr): Also protect only the
address if the expression is the component of a dereference.
Do not use a reference type for the final temporary reference.
2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/Makefile.in (NO_OMIT_ADAFLAGS): Define. * gcc-interface/Makefile.in (NO_OMIT_ADAFLAGS): Define.
(a-except.o): Replace -fno-inline with NO_INLINE_ADAFLAGS. (a-except.o): Replace -fno-inline with NO_INLINE_ADAFLAGS.
(s-memory.o): New rule. (s-memory.o): New rule.
......
...@@ -2586,6 +2586,12 @@ gnat_protect_expr (tree exp) ...@@ -2586,6 +2586,12 @@ gnat_protect_expr (tree exp)
return t; return t;
} }
/* Likewise if we're indirectly referencing part of something. */
if (code == COMPONENT_REF
&& TREE_CODE (TREE_OPERAND (exp, 0)) == INDIRECT_REF)
return build3 (code, type, gnat_protect_expr (TREE_OPERAND (exp, 0)),
TREE_OPERAND (exp, 1), NULL_TREE);
/* If this is a COMPONENT_REF of a fat pointer, save the entire fat pointer. /* If this is a COMPONENT_REF of a fat pointer, save the entire fat pointer.
This may be more efficient, but will also allow us to more easily find This may be more efficient, but will also allow us to more easily find
the match for the PLACEHOLDER_EXPR. */ the match for the PLACEHOLDER_EXPR. */
...@@ -2605,9 +2611,7 @@ gnat_protect_expr (tree exp) ...@@ -2605,9 +2611,7 @@ gnat_protect_expr (tree exp)
/* Otherwise reference, protect the address and dereference. */ /* Otherwise reference, protect the address and dereference. */
return return
build_unary_op (INDIRECT_REF, type, build_unary_op (INDIRECT_REF, type,
save_expr (build_unary_op (ADDR_EXPR, save_expr (build_unary_op (ADDR_EXPR, NULL_TREE, exp)));
build_reference_type (type),
exp)));
} }
/* This is equivalent to stabilize_reference_1 in tree.c but we take an extra /* This is equivalent to stabilize_reference_1 in tree.c but we take an extra
......
2016-11-13 Eric Botcazou <ebotcazou@adacore.com> 2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/renaming11.ad[sb]: New test.
2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
* c-c++-common/dump-ada-spec-6.c: New test. * c-c++-common/dump-ada-spec-6.c: New test.
2016-11-13 Eric Botcazou <ebotcazou@adacore.com> 2016-11-13 Eric Botcazou <ebotcazou@adacore.com>
......
-- { dg-do compile }
package body Renaming11 is
function F (Arg: Ptr3) return Integer is
V : Ptr1 renames Arg.all.all;
I : Integer renames V.A(1);
begin
return I;
end;
end Renaming11;
package Renaming11 is
subtype Index_Type is Integer range 1..10;
type Arr is array (Index_Type range <>) of Integer;
type Rec (Min : Index_Type; Max : Index_Type) is record
A : Arr (Min .. Max);
end record;
type Ptr1 is access Rec;
type Ptr2 is access Ptr1;
type Ptr3 is access Ptr2;
function F (Arg : Ptr3) return Integer;
end Renaming11;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment