diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-13 18:08:25 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-11-13 18:08:25 +0000 |
commit | 9ed6bb1c468f6858f694b316d2b217eab87d1bb5 (patch) | |
tree | a48f85ec10e25a6592a4c4e4dde297541dd8d217 /gcc/ada/gcc-interface/utils2.c | |
parent | 29f9b3e04ededc0ddd69e1e6353e10ba9e9960ec (diff) |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242358 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/gcc-interface/utils2.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils2.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index c0d831fb1e5b..fc6f1b86bdc3 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -2586,6 +2586,12 @@ gnat_protect_expr (tree exp) 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. This may be more efficient, but will also allow us to more easily find the match for the PLACEHOLDER_EXPR. */ @@ -2605,9 +2611,7 @@ gnat_protect_expr (tree exp) /* Otherwise reference, protect the address and dereference. */ return build_unary_op (INDIRECT_REF, type, - save_expr (build_unary_op (ADDR_EXPR, - build_reference_type (type), - exp))); + save_expr (build_unary_op (ADDR_EXPR, NULL_TREE, exp))); } /* This is equivalent to stabilize_reference_1 in tree.c but we take an extra |