aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils2.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-11-13 18:08:25 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-11-13 18:08:25 +0000
commit96826e28ef9a627b82f1d7ccda0906f20dfe96d5 (patch)
treea48f85ec10e25a6592a4c4e4dde297541dd8d217 /gcc/ada/gcc-interface/utils2.c
parent854c00dd69de6b13c1dc8d75948360420e4816d6 (diff)
downloadgcc-96826e28ef9a627b82f1d7ccda0906f20dfe96d5.zip
gcc-96826e28ef9a627b82f1d7ccda0906f20dfe96d5.tar.gz
gcc-96826e28ef9a627b82f1d7ccda0906f20dfe96d5.tar.bz2
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
Diffstat (limited to 'gcc/ada/gcc-interface/utils2.c')
-rw-r--r--gcc/ada/gcc-interface/utils2.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index c0d831f..fc6f1b8 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