aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/decl.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2021-04-28 10:21:59 +0200
committerEric Botcazou <ebotcazou@adacore.com>2021-04-28 10:21:59 +0200
commitfccc47dddc2ee605dd7fce5c1d1711404e19cd7f (patch)
tree763c35580310792004c439ac5fbc0ed7f665beff /gcc/ada/gcc-interface/decl.c
parentb81e2d5e76a6bcc71f45b122e8b5538ddb7ebf4c (diff)
downloadgcc-fccc47dddc2ee605dd7fce5c1d1711404e19cd7f.zip
gcc-fccc47dddc2ee605dd7fce5c1d1711404e19cd7f.tar.gz
gcc-fccc47dddc2ee605dd7fce5c1d1711404e19cd7f.tar.bz2
Avoid creating useless local bounds around calls
This prevents the compiler from creating useless local bounds around calls that take a parameter of an unconstrained array type when the bounds already exist somewhere else for the actual parameter. gcc/ada/ * gcc-interface/decl.c (gnat_to_gnu_subprog_type): Do not demote a const or pure function because of a parameter whose type is pointer to function. * gcc-interface/trans.c (Call_to_gnu): Do not put back a conversion between an actual and a formal that are unconstrained array types. (gnat_gimplify_expr) <CALL_EXPR>: New case. * gcc-interface/utils2.c (build_binary_op): Do not use |= operator. (gnat_stabilize_reference_1): Likewise. (gnat_rewrite_reference): Likewise. (build_unary_op): Do not clear existing TREE_CONSTANT on the result. (gnat_build_constructor): Also accept the address of a constant CONSTRUCTOR as constant element.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r--gcc/ada/gcc-interface/decl.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 27ef51a..6fd5c2c 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -6059,12 +6059,13 @@ gnat_to_gnu_subprog_type (Entity_Id gnat_subprog, bool definition,
/* A pure function in the Ada sense which takes an access parameter
may modify memory through it and thus need be considered neither
- const nor pure in the GCC sense. Likewise it if takes a by-ref
- In Out or Out parameter. But if it takes a by-ref In parameter,
- then it may only read memory through it and can be considered
- pure in the GCC sense. */
+ const nor pure in the GCC sense, unless it's access-to-function.
+ Likewise it if takes a by-ref In Out or Out parameter. But if it
+ takes a by-ref In parameter, then it may only read memory through
+ it and can be considered pure in the GCC sense. */
if ((const_flag || pure_flag)
- && (POINTER_TYPE_P (gnu_param_type)
+ && ((POINTER_TYPE_P (gnu_param_type)
+ && TREE_CODE (TREE_TYPE (gnu_param_type)) != FUNCTION_TYPE)
|| TYPE_IS_FAT_POINTER_P (gnu_param_type)))
{
const_flag = false;