aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-11-10 08:21:05 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-11-10 08:21:05 +0000
commit4896b86556f8d2149fae8e8dc27a93332b9482e2 (patch)
tree9fa6c392e31b8c052f90d7b9aa005e493870b47d /gcc/ada/gcc-interface/utils.c
parent35b9d8e7695aa37563293217aefb3a606b72f131 (diff)
downloadgcc-4896b86556f8d2149fae8e8dc27a93332b9482e2.zip
gcc-4896b86556f8d2149fae8e8dc27a93332b9482e2.tar.gz
gcc-4896b86556f8d2149fae8e8dc27a93332b9482e2.tar.bz2
utils.c (convert): Add comment and do not fall through to the next case.
* gcc-interface/utils.c (convert) <RECORD_TYPE>: Add comment and do not fall through to the next case. <ARRAY_TYPE>: Deal specially with a dereference from another array type with the same element type. From-SVN: r254618
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index bfd3388..2c80a61 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -4706,6 +4706,7 @@ convert (tree type, tree expr)
return fold (convert_to_real (type, expr));
case RECORD_TYPE:
+ /* Do a normal conversion between scalar and justified modular type. */
if (TYPE_JUSTIFIED_MODULAR_P (type) && !AGGREGATE_TYPE_P (etype))
{
vec<constructor_elt, va_gc> *v;
@@ -4717,9 +4718,27 @@ convert (tree type, tree expr)
return gnat_build_constructor (type, v);
}
- /* ... fall through ... */
+ /* In these cases, assume the front-end has validated the conversion.
+ If the conversion is valid, it will be a bit-wise conversion, so
+ it can be viewed as an unchecked conversion. */
+ return unchecked_convert (type, expr, false);
case ARRAY_TYPE:
+ /* Do a normal conversion between unconstrained and constrained array
+ type, assuming the latter is a constrained version of the former. */
+ if (TREE_CODE (expr) == INDIRECT_REF
+ && ecode == ARRAY_TYPE
+ && TREE_TYPE (etype) == TREE_TYPE (type))
+ {
+ tree ptr_type = build_pointer_type (type);
+ tree t = build_unary_op (INDIRECT_REF, NULL_TREE,
+ fold_convert (ptr_type,
+ TREE_OPERAND (expr, 0)));
+ TREE_READONLY (t) = TREE_READONLY (expr);
+ TREE_THIS_NOTRAP (t) = TREE_THIS_NOTRAP (expr);
+ return t;
+ }
+
/* In these cases, assume the front-end has validated the conversion.
If the conversion is valid, it will be a bit-wise conversion, so
it can be viewed as an unchecked conversion. */