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] Completing the implementation of Ada 2012 restrictions


This patch adds several restrictions identifiers that were introduced late
in the Ada 2012 development process.

Given the following configuration file:
---
pragma Restrictions (No_Access_Parameter_Allocators, No_Coextensions);
pragma Restrictions (No_Standard_Allocators_After_Elaboration);
pragma Restrictions (No_Use_Of_Attribute => Address);
pragma Restrictions (No_Use_Of_Pragma => Pure);
---

compiling main.adb below must yield:

main.adb:2:11:
    violation of restriction "No_Use_Of_Pragma => Pure" at gnat.adc:4
main.adb:12:23:
    violation of restriction "No_Coextensions" at gnat.adc:1
main.adb:13:04:
    violation of restriction "No_Use_Of_Attribute => Address" at gnat.adc:3
main.adb:15:15:
    violation of restriction "No_Access_Parameter_Allocators" at gnat.adc:1
---

procedure Main is
   pragma Pure;
   type T (X : access Integer) is record
      Value : Integer;
   end record;
   function Double (X : access integer) return Integer is
   begin
      return X.all * 2;
   end;

   Here : Integer;
   Thing : T := (X => new Integer'(123), Value => -1);
   for Thing'address use here'address;
begin
   if Double (new Integer'(111)) /= 222 then
      Raise Program_Error;
   end if;
end;

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

2013-04-12  Ed Schonberg  <schonberg@adacore.com>

	* s-rident.ads: Add various missing Ada 2012 restrictions:
	No_Access_Parameter_Allocators, No_Coextensions,
	No_Use_Of_Attribute, No_Use_Of_Pragma.
	* snames.ads-tmpl: Add corresponding names.
	* restrict.ads restrict.adb: Subprograms and data structures to
	handle aspects No_Use_Of_Attribute and No_Use_Of_Pragma.
	* sem_ch4.adb: Correct name of restrictions is
	No_Standard_Allocators_After_Elaboration.
	* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Check
	violation of restriction No_Use_Of_Attribute.
	* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
	Set restrictions No_Use_Of_Pragma and No_Use_Of_Attribute.
	(Analyze_Pragma): Check violation of restriction No_Use_Of_Pragma.
	* sem_res.adb: Check restrictions No_Access_Parameter_Allocators
	and No_Coextensions.
	* bcheck.adb: Correct name of restrictions is
	No_Standard_Allocators_After_Elaboration.
	* gnatbind.adb: Correct name of restrictions is
	No_Standard_Allocators_After_Elaboration.

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]