This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Expand barrier conditions permitted by the restriction Pure_Barrier


This patch permits the use of type conversions and components of objects
subject to the following conditions: type conversions cannot potentially raise
contraint errors and access types cannot be dereferenced. These additions
provide greater functionality to users while respecting the aims of the
Pure_Barrier restriction: side effects, exceptions, and recursion cannot occur
during the evaluation of the barriers.

In practise this patch allows users to compare the result of the Count
attribute with a literal or named number, and reference components of array or
record types in barriers.

The following must compile quietly:

---
package Test_PO is
   type BooT is record
      Far : Integer;
   end record;

   type FooT is record
      Bar : BooT;
   end record;

   protected PO is
      entry A;
      entry B;
   private
      Foo : FooT;
   end PO;
end Test_PO;

---
pragma Restrictions (Pure_Barriers);

package body Test_PO is
   protected body PO is
      entry A when A'Count > 5 is
      begin
         null;
      end A;

      entry B when Foo.Bar.Far = 5 is
      begin
         null;
      end B;
   end PO;
end Test_PO;

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-08  Patrick Bernardi  <bernardi@adacore.com>

	* exp_ch9.adb (Is_Pure_Barrier): Allow type
	conversions and components of objects. Simplified the detection
	of the Count attribute by identifying the corresponding run-time
	calls.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]