aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2011-09-26 08:26:37 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2011-09-26 08:26:37 +0000
commita1c7d7973c44afbee5e1251b200cc6e7a27409b1 (patch)
tree0bbfdf9e810f8a0d87f499a7747d27b4dadc2da4 /gcc/ada/gcc-interface/utils.c
parent20633efc34fadc76b339620c2d37f3c12231c40a (diff)
downloadgcc-a1c7d7973c44afbee5e1251b200cc6e7a27409b1.zip
gcc-a1c7d7973c44afbee5e1251b200cc6e7a27409b1.tar.gz
gcc-a1c7d7973c44afbee5e1251b200cc6e7a27409b1.tar.bz2
ada-tree.h (DECL_CAN_NEVER_BE_NULL_P): New macro.
* gcc-interface/ada-tree.h (DECL_CAN_NEVER_BE_NULL_P): New macro. * gcc-interface/decl.c (gnat_to_gnu_entity) <object>: Set the flag. (gnat_to_gnu_param): Likewise. * gcc-interface/utils.c (convert) <UNCONSTRAINED_ARRAY_REF>: Invoke maybe_unconstrained_array instead of doing the work manually. (maybe_unconstrained_array): Propagate the TREE_THIS_NOTRAP flag. * gcc-interface/utils2.c (build_unary_op) <INDIRECT_REF>: If operand is a DECL with the flag, set TREE_THIS_NOTRAP on the reference. (gnat_stabilize_reference_1): Propagate the TREE_THIS_NOTRAP flag. (gnat_stabilize_reference): Likewise. From-SVN: r179182
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 4d95845..baa4ca1 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -3819,8 +3819,7 @@ convert (tree type, tree expr)
return gnat_build_constructor (type, v);
}
- /* There are some special cases of expressions that we process
- specially. */
+ /* There are some cases of expressions that we process specially. */
switch (TREE_CODE (expr))
{
case ERROR_MARK:
@@ -3976,21 +3975,11 @@ convert (tree type, tree expr)
break;
case UNCONSTRAINED_ARRAY_REF:
- {
- /* Convert this to the type of the inner array by getting the address
- of the array from the template. */
- const bool no_trap = TREE_THIS_NOTRAP (expr);
- expr = TREE_OPERAND (expr, 0);
- expr = build_unary_op (INDIRECT_REF, NULL_TREE,
- build_component_ref (expr, NULL_TREE,
- TYPE_FIELDS
- (TREE_TYPE (expr)),
- false));
- TREE_THIS_NOTRAP (expr) = no_trap;
- etype = TREE_TYPE (expr);
- ecode = TREE_CODE (etype);
- break;
- }
+ /* First retrieve the underlying array. */
+ expr = maybe_unconstrained_array (expr);
+ etype = TREE_TYPE (expr);
+ ecode = TREE_CODE (etype);
+ break;
case VIEW_CONVERT_EXPR:
{
@@ -4282,6 +4271,8 @@ maybe_unconstrained_array (tree exp)
if (code == UNCONSTRAINED_ARRAY_REF)
{
const bool read_only = TREE_READONLY (exp);
+ const bool no_trap = TREE_THIS_NOTRAP (exp);
+
exp = TREE_OPERAND (exp, 0);
if (TREE_CODE (exp) == COND_EXPR)
{
@@ -4306,12 +4297,16 @@ maybe_unconstrained_array (tree exp)
TREE_OPERAND (exp, 0), op1, op2);
}
else
- exp = build_unary_op (INDIRECT_REF, NULL_TREE,
- build_component_ref (exp, NULL_TREE,
- TYPE_FIELDS
- (TREE_TYPE (exp)),
- false));
- TREE_READONLY (exp) = read_only;
+ {
+ exp = build_unary_op (INDIRECT_REF, NULL_TREE,
+ build_component_ref (exp, NULL_TREE,
+ TYPE_FIELDS
+ (TREE_TYPE (exp)),
+ false));
+ TREE_READONLY (exp) = read_only;
+ TREE_THIS_NOTRAP (exp) = no_trap;
+ }
+
return exp;
}