summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-11 10:54:52 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2011-12-11 10:54:52 +0000
commitb7aa163fa36a89dc3423c65e98ef3471419632d6 (patch)
tree866e2a85362fea662e43d4ddee9a4b625ebe68ff
parent6f619588f88edb9aca82ec57dc83b499a21aa8e3 (diff)
downloadgcc-b7aa163fa36a89dc3423c65e98ef3471419632d6.tar.gz
* gcc-interface/decl.c (gnat_to_gnu_param): Set the restrict qualifier
on references built for parameters which aren't specifically by-ref. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182202 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/decl.c8
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e8ce2e6902c..6a2dd2604fa 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,10 @@
2011-12-11 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (gnat_to_gnu_param): Set the restrict qualifier
+ on references built for parameters which aren't specifically by-ref.
+
+2011-12-11 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/decl.c (gnat_to_gnu_entity) <object>: If there is an
alignment set on a renaming, assert that the renamed object is aligned
enough as to make it possible to honor it.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index aecbd76b983..c3774f2a6ba 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -5518,7 +5518,15 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech,
|| (!foreign
&& default_pass_by_ref (gnu_param_type)))))
{
+ /* We take advantage of 6.2(12) by considering that references built for
+ parameters whose type isn't by-ref and for which the mechanism hasn't
+ been forced to by-ref are restrict-qualified in the C sense. */
+ bool restrict_p
+ = !TREE_ADDRESSABLE (gnu_param_type) && mech != By_Reference;
gnu_param_type = build_reference_type (gnu_param_type);
+ if (restrict_p)
+ gnu_param_type
+ = build_qualified_type (gnu_param_type, TYPE_QUAL_RESTRICT);
by_ref = true;
/* In some ABIs, e.g. SPARC 32-bit, fat pointer types are themselves