]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_param): Set the restrict qualifier on references built for parame...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 11 Dec 2011 10:54:52 +0000 (10:54 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 11 Dec 2011 10:54:52 +0000 (10:54 +0000)
* gcc-interface/decl.c (gnat_to_gnu_param): Set the restrict qualifier
on references built for parameters which aren't specifically by-ref.

From-SVN: r182202

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c

index e8ce2e6902caa21a806ced51c6215deac8bc55d2..6a2dd2604fa7a93e5a62a25ec1654d4effdd2e46 100644 (file)
@@ -1,3 +1,8 @@
+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
index aecbd76b9839b0500147906b99f7cd6675b46215..c3774f2a6ba50963853c0eb3daef166610eac85e 100644 (file)
@@ -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