Commit 0f1a6a0b by Arnaud Charlet

[multiple changes]

2010-10-11  Robert Dewar  <dewar@adacore.com>

	* aspects.ads, aspects.adb: Major revision of this package for 2nd
	stage of aspects implementation.
	* gcc-interface/Make-lang.in: Add entry for aspects.o
	* gcc-interface/Makefile.in: Add aspects.o to GNATMAKE_OBJS
	* par-ch13.adb (Aspect_Specifications_Present): New function
	(P_Aspect_Specifications): New procedure
	* par-ch3.adb (P_Type_Declaration): Handle aspect specifications
	(P_Derived_Type_Def_Or_Private_Ext_Decl): Handle aspect specifications
	(P_Identifier_Declarations): Handle aspect specifications
	(P_Component_Items): Handle aspect specifications
	(P_Subtype_Declaration): Handle aspect specifications
	* par-ch6.adb (P_Subprogram): Handle aspect specifications
	* par-ch9.adb (P_Entry_Declaration): Handle aspect specifications
	* par.adb (Aspect_Specifications_Present): New function
	(P_Aspect_Specifications): New procedure
	* sem.adb (Analyze_Full_Type_Declaration): New name for
	Analyze_Type_Declaration.
	(Analyze_Formal_Package_Declaration): New name (add _Declaration)
	(Analyze_Formal_Subprogram_Declaration): New name (add _Declaration)
	(Analyze_Protected_Type_Declaration): New name (add _Declaration)
	(Analyze_Single_Protected_Declaration): New name (add _Declaration)
	(Analyze_Single_Task_Declaration): New name (add _Declaration)
	(Analyze_Task_Type_Declaration): New name (add _Declaration)
	* sem_cat.adb (Analyze_Full_Type_Declaration): New name for
	Analyze_Type_Declaration.
	* sem_ch11.adb (Analyze_Exception_Declaration): Analyze aspect
	specifications.
	* sem_ch12.adb (Analyze_Formal_Object_Declaration): Handle aspect
	specifications.
	(Analyze_Formal_Package_Declaration): New name (add _Declaration)
	(Analyze_Formal_Package_Declaration): Handle aspect specifications
	(Analyze_Formal_Subprogram_Declaration): New name (add _Declaration)
	(Analyze_Formal_Subprogram_Declaration): Handle aspect specifications
	(Analyze_Formal_Type_Declaration): Handle aspect specifications
	(Analyze_Generic_Package_Declaration): Handle aspect specifications
	(Analyze_Generic_Subprogram_Declaration): Handle aspect specifications
	(Analyze_Package_Instantiation): Handle aspect specifications
	(Analyze_Subprogram_Instantiation): Handle aspect specifications
	* sem_ch12.ads (Analyze_Formal_Package_Declaration): New name (add
	_Declaration).
	(Analyze_Formal_Subprogram_Declaration): New name (add _Declaration)
	* sem_ch13.adb (Analyze_Aspect_Specifications): New procedure
	(Duplicate_Clause): New function, calls to this function are added to
	processing for all aspects.
	* sem_ch13.ads (Analyze_Aspect_Specifications): New procedure
	* sem_ch3.adb (Analyze_Full_Type_Declaration): New name for
	Analyze_Type_Declaration.
	* sem_ch3.ads (Analyze_Full_Type_Declaration): New name for
	Analyze_Type_Declaration.
	* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Analyze aspect
	specifications.
	(Analyze_Subprogram_Declaration): Analyze aspect specifications
	* sem_ch7.adb (Analyze_Package_Declaration): Analyze aspect
	specifications.
	(Analyze_Private_Type_Declaration): Analyze aspect specifications
	* sem_ch9.adb (Analyze_Protected_Type_Declaration): Analyze aspect
	specifications.
	(Analyze_Protected_Type_Declaration): New name (add _Declaration)
	(Analyze_Single_Protected_Declaration): Analyze aspect specifications
	(Analyze_Single_Protected_Declaration): New name (add _Declaration)
	(Analyze_Single_Task_Declaration): Analyze aspect specifications
	(Analyze_Single_Task_Declaration): New name (add _Declaration)
	(Analyze_Task_Type_Declaration): Analyze aspect specifications
	(Analyze_Task_Type_Declaration): New name (add _Declaration)
	* sem_ch9.ads (Analyze_Protected_Type_Declaration): New name (add
	_Declaration).
	(Analyze_Single_Protected_Declaration): New name (add _Declaration)
	(Analyze_Single_Task_Declaration): New name (add _Declaration)
	(Analyze_Task_Type_Declaration): New name (add _Declaration)
	* sem_prag.adb: Use Get_Pragma_Arg systematically so that we do not
	have to generate unnecessary pragma argument associations (this matches
	the doc).
	Throughout do changes to accomodate aspect specifications, including
	specializing messages, handling the case of not going through all
	homonyms, and allowing for cancellation.
	* sinfo.ads, sinfo.adb: Clean up obsolete documentation for Flag1,2,3
	(Aspect_Cancel): New flag
	(From_Aspect_Specification): New flag
	(First_Aspect): Removed flag
	(Last_Aspect): Removed flag
	* sprint.adb (Sprint_Aspect_Specifications): New procedure
	(Sprint_Node_Actual): Add calls to Sprint_Aspect_Specifications

2010-10-11  Bob Duff  <duff@adacore.com>

	* sem_res.adb (Resolve_Actuals): Minor change to warning messages so
	they match in Ada 95, 2005, and 2012 modes, in the case where the
	language didn't change. Same thing for the run-time exception message.

2010-10-11  Javier Miranda  <miranda@adacore.com>

	* debug.adb Document that switch -gnatd.p enables the CIL verifier.

2010-10-11  Robert Dewar  <dewar@adacore.com>

	* s-htable.adb: Minor reformatting.

From-SVN: r165299
parent 1237d6ef
2010-10-11 Robert Dewar <dewar@adacore.com>
* aspects.ads, aspects.adb: Major revision of this package for 2nd
stage of aspects implementation.
* gcc-interface/Make-lang.in: Add entry for aspects.o
* gcc-interface/Makefile.in: Add aspects.o to GNATMAKE_OBJS
* par-ch13.adb (Aspect_Specifications_Present): New function
(P_Aspect_Specifications): New procedure
* par-ch3.adb (P_Type_Declaration): Handle aspect specifications
(P_Derived_Type_Def_Or_Private_Ext_Decl): Handle aspect specifications
(P_Identifier_Declarations): Handle aspect specifications
(P_Component_Items): Handle aspect specifications
(P_Subtype_Declaration): Handle aspect specifications
* par-ch6.adb (P_Subprogram): Handle aspect specifications
* par-ch9.adb (P_Entry_Declaration): Handle aspect specifications
* par.adb (Aspect_Specifications_Present): New function
(P_Aspect_Specifications): New procedure
* sem.adb (Analyze_Full_Type_Declaration): New name for
Analyze_Type_Declaration.
(Analyze_Formal_Package_Declaration): New name (add _Declaration)
(Analyze_Formal_Subprogram_Declaration): New name (add _Declaration)
(Analyze_Protected_Type_Declaration): New name (add _Declaration)
(Analyze_Single_Protected_Declaration): New name (add _Declaration)
(Analyze_Single_Task_Declaration): New name (add _Declaration)
(Analyze_Task_Type_Declaration): New name (add _Declaration)
* sem_cat.adb (Analyze_Full_Type_Declaration): New name for
Analyze_Type_Declaration.
* sem_ch11.adb (Analyze_Exception_Declaration): Analyze aspect
specifications.
* sem_ch12.adb (Analyze_Formal_Object_Declaration): Handle aspect
specifications.
(Analyze_Formal_Package_Declaration): New name (add _Declaration)
(Analyze_Formal_Package_Declaration): Handle aspect specifications
(Analyze_Formal_Subprogram_Declaration): New name (add _Declaration)
(Analyze_Formal_Subprogram_Declaration): Handle aspect specifications
(Analyze_Formal_Type_Declaration): Handle aspect specifications
(Analyze_Generic_Package_Declaration): Handle aspect specifications
(Analyze_Generic_Subprogram_Declaration): Handle aspect specifications
(Analyze_Package_Instantiation): Handle aspect specifications
(Analyze_Subprogram_Instantiation): Handle aspect specifications
* sem_ch12.ads (Analyze_Formal_Package_Declaration): New name (add
_Declaration).
(Analyze_Formal_Subprogram_Declaration): New name (add _Declaration)
* sem_ch13.adb (Analyze_Aspect_Specifications): New procedure
(Duplicate_Clause): New function, calls to this function are added to
processing for all aspects.
* sem_ch13.ads (Analyze_Aspect_Specifications): New procedure
* sem_ch3.adb (Analyze_Full_Type_Declaration): New name for
Analyze_Type_Declaration.
* sem_ch3.ads (Analyze_Full_Type_Declaration): New name for
Analyze_Type_Declaration.
* sem_ch6.adb (Analyze_Abstract_Subprogram_Declaration): Analyze aspect
specifications.
(Analyze_Subprogram_Declaration): Analyze aspect specifications
* sem_ch7.adb (Analyze_Package_Declaration): Analyze aspect
specifications.
(Analyze_Private_Type_Declaration): Analyze aspect specifications
* sem_ch9.adb (Analyze_Protected_Type_Declaration): Analyze aspect
specifications.
(Analyze_Protected_Type_Declaration): New name (add _Declaration)
(Analyze_Single_Protected_Declaration): Analyze aspect specifications
(Analyze_Single_Protected_Declaration): New name (add _Declaration)
(Analyze_Single_Task_Declaration): Analyze aspect specifications
(Analyze_Single_Task_Declaration): New name (add _Declaration)
(Analyze_Task_Type_Declaration): Analyze aspect specifications
(Analyze_Task_Type_Declaration): New name (add _Declaration)
* sem_ch9.ads (Analyze_Protected_Type_Declaration): New name (add
_Declaration).
(Analyze_Single_Protected_Declaration): New name (add _Declaration)
(Analyze_Single_Task_Declaration): New name (add _Declaration)
(Analyze_Task_Type_Declaration): New name (add _Declaration)
* sem_prag.adb: Use Get_Pragma_Arg systematically so that we do not
have to generate unnecessary pragma argument associations (this matches
the doc).
Throughout do changes to accomodate aspect specifications, including
specializing messages, handling the case of not going through all
homonyms, and allowing for cancellation.
* sinfo.ads, sinfo.adb: Clean up obsolete documentation for Flag1,2,3
(Aspect_Cancel): New flag
(From_Aspect_Specification): New flag
(First_Aspect): Removed flag
(Last_Aspect): Removed flag
* sprint.adb (Sprint_Aspect_Specifications): New procedure
(Sprint_Node_Actual): Add calls to Sprint_Aspect_Specifications
2010-10-11 Bob Duff <duff@adacore.com>
* sem_res.adb (Resolve_Actuals): Minor change to warning messages so
they match in Ada 95, 2005, and 2012 modes, in the case where the
language didn't change. Same thing for the run-time exception message.
2010-10-11 Javier Miranda <miranda@adacore.com>
* debug.adb Document that switch -gnatd.p enables the CIL verifier.
2010-10-11 Robert Dewar <dewar@adacore.com>
* s-htable.adb: Minor reformatting.
2010-10-11 Javier Miranda <miranda@adacore.com> 2010-10-11 Javier Miranda <miranda@adacore.com>
* debug.adb: Update comment. * debug.adb: Update comment.
......
...@@ -29,10 +29,43 @@ ...@@ -29,10 +29,43 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Atree; use Atree;
with Nlists; use Nlists;
with Sinfo; use Sinfo;
with Snames; use Snames; with Snames; use Snames;
with GNAT.HTable; use GNAT.HTable;
package body Aspects is package body Aspects is
------------------------------------------
-- Hash Table for Aspect Specifications --
------------------------------------------
type AS_Hash_Range is range 0 .. 510;
-- Size of hash table headers
function AS_Hash (F : Node_Id) return AS_Hash_Range;
-- Hash function for hash table
function AS_Hash (F : Node_Id) return AS_Hash_Range is
begin
return AS_Hash_Range (F mod 511);
end AS_Hash;
package Aspect_Specifications_Hash_Table is new
GNAT.HTable.Simple_HTable
(Header_Num => AS_Hash_Range,
Element => List_Id,
No_Element => No_List,
Key => Node_Id,
Hash => AS_Hash,
Equal => "=");
-----------------------------------------
-- Table Linking Names and Aspect_Id's --
-----------------------------------------
type Aspect_Entry is record type Aspect_Entry is record
Nam : Name_Id; Nam : Name_Id;
Asp : Aspect_Id; Asp : Aspect_Id;
...@@ -42,12 +75,10 @@ package body Aspects is ...@@ -42,12 +75,10 @@ package body Aspects is
(Name_Ada_2005, Aspect_Ada_2005), (Name_Ada_2005, Aspect_Ada_2005),
(Name_Ada_2012, Aspect_Ada_2012), (Name_Ada_2012, Aspect_Ada_2012),
(Name_Address, Aspect_Address), (Name_Address, Aspect_Address),
(Name_Aliased, Aspect_Aliased),
(Name_Alignment, Aspect_Alignment), (Name_Alignment, Aspect_Alignment),
(Name_Atomic, Aspect_Atomic), (Name_Atomic, Aspect_Atomic),
(Name_Atomic_Components, Aspect_Atomic_Components), (Name_Atomic_Components, Aspect_Atomic_Components),
(Name_Bit_Order, Aspect_Bit_Order), (Name_Bit_Order, Aspect_Bit_Order),
(Name_C_Pass_By_Copy, Aspect_C_Pass_By_Copy),
(Name_Component_Size, Aspect_Component_Size), (Name_Component_Size, Aspect_Component_Size),
(Name_Discard_Names, Aspect_Discard_Names), (Name_Discard_Names, Aspect_Discard_Names),
(Name_External_Tag, Aspect_External_Tag), (Name_External_Tag, Aspect_External_Tag),
...@@ -60,12 +91,9 @@ package body Aspects is ...@@ -60,12 +91,9 @@ package body Aspects is
(Name_Pack, Aspect_Pack), (Name_Pack, Aspect_Pack),
(Name_Persistent_BSS, Aspect_Persistent_BSS), (Name_Persistent_BSS, Aspect_Persistent_BSS),
(Name_Post, Aspect_Post), (Name_Post, Aspect_Post),
(Name_Postcondition, Aspect_Postcondition),
(Name_Pre, Aspect_Pre), (Name_Pre, Aspect_Pre),
(Name_Precondition, Aspect_Precondition),
(Name_Predicate, Aspect_Predicate), (Name_Predicate, Aspect_Predicate),
(Name_Preelaborable_Initialization, Aspect_Preelaborable_Initialization), (Name_Preelaborable_Initialization, Aspect_Preelaborable_Initialization),
(Name_Psect_Object, Aspect_Psect_Object),
(Name_Pure_Function, Aspect_Pure_Function), (Name_Pure_Function, Aspect_Pure_Function),
(Name_Shared, Aspect_Shared), (Name_Shared, Aspect_Shared),
(Name_Size, Aspect_Size), (Name_Size, Aspect_Size),
...@@ -83,8 +111,31 @@ package body Aspects is ...@@ -83,8 +111,31 @@ package body Aspects is
(Name_Value_Size, Aspect_Value_Size), (Name_Value_Size, Aspect_Value_Size),
(Name_Volatile, Aspect_Volatile), (Name_Volatile, Aspect_Volatile),
(Name_Volatile_Components, Aspect_Volatile_Components), (Name_Volatile_Components, Aspect_Volatile_Components),
(Name_Warnings, Aspect_Warnings), (Name_Warnings, Aspect_Warnings));
(Name_Weak_External, Aspect_Weak_External));
-------------------------------------
-- Hash Table for Aspect Id Values --
-------------------------------------
type AI_Hash_Range is range 0 .. 112;
-- Size of hash table headers
function AI_Hash (F : Name_Id) return AI_Hash_Range;
-- Hash function for hash table
function AI_Hash (F : Name_Id) return AI_Hash_Range is
begin
return AI_Hash_Range (F mod 113);
end AI_Hash;
package Aspect_Id_Hash_Table is new
GNAT.HTable.Simple_HTable
(Header_Num => AI_Hash_Range,
Element => Aspect_Id,
No_Element => No_Aspect,
Key => Name_Id,
Hash => AI_Hash,
Equal => "=");
------------------- -------------------
-- Get_Aspect_Id -- -- Get_Aspect_Id --
...@@ -92,13 +143,74 @@ package body Aspects is ...@@ -92,13 +143,74 @@ package body Aspects is
function Get_Aspect_Id (Name : Name_Id) return Aspect_Id is function Get_Aspect_Id (Name : Name_Id) return Aspect_Id is
begin begin
for J in Aspect_Names'Range loop return Aspect_Id_Hash_Table.Get (Name);
if Aspect_Names (J).Nam = Name then
return Aspect_Names (J).Asp;
end if;
end loop;
return No_Aspect;
end Get_Aspect_Id; end Get_Aspect_Id;
---------------------------
-- Aspect_Specifications --
---------------------------
function Aspect_Specifications (N : Node_Id) return List_Id is
begin
return Aspect_Specifications_Hash_Table.Get (N);
end Aspect_Specifications;
-----------------------------------
-- Permits_Aspect_Specifications --
-----------------------------------
Has_Aspect_Specifications_Flag : constant array (Node_Kind) of Boolean :=
(N_Abstract_Subprogram_Declaration => True,
N_Component_Declaration => True,
N_Entry_Declaration => True,
N_Exception_Declaration => True,
N_Formal_Abstract_Subprogram_Declaration => True,
N_Formal_Concrete_Subprogram_Declaration => True,
N_Formal_Object_Declaration => True,
N_Formal_Package_Declaration => True,
N_Formal_Type_Declaration => True,
N_Full_Type_Declaration => True,
N_Function_Instantiation => True,
N_Generic_Package_Declaration => True,
N_Generic_Subprogram_Declaration => True,
N_Object_Declaration => True,
N_Package_Declaration => True,
N_Package_Instantiation => True,
N_Private_Extension_Declaration => True,
N_Private_Type_Declaration => True,
N_Procedure_Instantiation => True,
N_Protected_Type_Declaration => True,
N_Single_Protected_Declaration => True,
N_Single_Task_Declaration => True,
N_Subprogram_Declaration => True,
N_Subtype_Declaration => True,
N_Task_Type_Declaration => True,
others => False);
function Permits_Aspect_Specifications (N : Node_Id) return Boolean is
begin
return Has_Aspect_Specifications_Flag (Nkind (N));
end Permits_Aspect_Specifications;
-------------------------------
-- Set_Aspect_Specifications --
-------------------------------
procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id) is
begin
pragma Assert (Permits_Aspect_Specifications (N));
pragma Assert (not Has_Aspect_Specifications (N));
pragma Assert (L /= No_List);
Set_Has_Aspect_Specifications (N);
Set_Parent (L, N);
Aspect_Specifications_Hash_Table.Set (N, L);
end Set_Aspect_Specifications;
-- Package initialization sets up Aspect Id hash table
begin
for J in Aspect_Names'Range loop
Aspect_Id_Hash_Table.Set (Aspect_Names (J).Nam, Aspect_Names (J).Asp);
end loop;
end Aspects; end Aspects;
...@@ -29,25 +29,27 @@ ...@@ -29,25 +29,27 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- This package defines the aspects that are recognized in aspect -- This package defines the aspects that are recognized by GNAT in aspect
-- specifications. We separate this off in its own packages to that -- specifications. It also contains the subprograms for storing/retrieving
-- it can be accessed by the parser without dragging in Sem_Asp -- aspect speciciations from the tree. The semantic processing for aspect
-- specifications is found in Sem_Ch13.Analyze_Aspect_Specifications.
with Namet; use Namet; with Namet; use Namet;
with Types; use Types;
package Aspects is package Aspects is
-- Type defining recognized aspects
type Aspect_Id is type Aspect_Id is
(No_Aspect, -- Dummy entry for no aspect (No_Aspect, -- Dummy entry for no aspect
Aspect_Ada_2005, -- GNAT Aspect_Ada_2005, -- GNAT
Aspect_Ada_2012, -- GNAT Aspect_Ada_2012, -- GNAT
Aspect_Address, Aspect_Address,
Aspect_Aliased,
Aspect_Alignment, Aspect_Alignment,
Aspect_Atomic, Aspect_Atomic,
Aspect_Atomic_Components, Aspect_Atomic_Components,
Aspect_Bit_Order, Aspect_Bit_Order,
Aspect_C_Pass_By_Copy,
Aspect_Component_Size, Aspect_Component_Size,
Aspect_Discard_Names, Aspect_Discard_Names,
Aspect_External_Tag, Aspect_External_Tag,
...@@ -56,16 +58,14 @@ package Aspects is ...@@ -56,16 +58,14 @@ package Aspects is
Aspect_Inline_Always, -- GNAT Aspect_Inline_Always, -- GNAT
Aspect_Invariant, Aspect_Invariant,
Aspect_Machine_Radix, Aspect_Machine_Radix,
Aspect_No_Return,
Aspect_Object_Size, -- GNAT Aspect_Object_Size, -- GNAT
Aspect_Pack, Aspect_Pack,
Aspect_Persistent_BSS, -- GNAT Aspect_Persistent_BSS, -- GNAT
Aspect_Post, Aspect_Post,
Aspect_Postcondition, -- GNAT (equivalent to Post)
Aspect_Pre, Aspect_Pre,
Aspect_Precondition, -- GNAT (equivalent to Pre)
Aspect_Predicate, -- GNAT??? Aspect_Predicate, -- GNAT???
Aspect_Preelaborable_Initialization, Aspect_Preelaborable_Initialization,
Aspect_Psect_Object, -- GNAT
Aspect_Pure_Function, -- GNAT Aspect_Pure_Function, -- GNAT
Aspect_Shared, -- GNAT (equivalent to Atomic) Aspect_Shared, -- GNAT (equivalent to Atomic)
Aspect_Size, Aspect_Size,
...@@ -83,17 +83,15 @@ package Aspects is ...@@ -83,17 +83,15 @@ package Aspects is
Aspect_Value_Size, -- GNAT Aspect_Value_Size, -- GNAT
Aspect_Volatile, Aspect_Volatile,
Aspect_Volatile_Components, Aspect_Volatile_Components,
Aspect_Warnings, -- GNAT Aspect_Warnings); -- GNAT
Aspect_Weak_External); -- GNAT
-- The following array indicates aspects that accept 'Class -- The following array indicates aspects that accept 'Class
Class_Aspect_OK : constant array (Aspect_Id) of Boolean := Class_Aspect_OK : constant array (Aspect_Id) of Boolean :=
(Aspect_Invariant => True, (Aspect_Invariant => True,
Aspect_Pre => True, Aspect_Pre => True,
Aspect_Precondition => True, Aspect_Predicate => True,
Aspect_Post => True, Aspect_Post => True,
Aspect_Postcondition => True,
others => False); others => False);
-- The following type is used for indicating allowed expression forms -- The following type is used for indicating allowed expression forms
...@@ -110,12 +108,10 @@ package Aspects is ...@@ -110,12 +108,10 @@ package Aspects is
Aspect_Ada_2005 => Optional, Aspect_Ada_2005 => Optional,
Aspect_Ada_2012 => Optional, Aspect_Ada_2012 => Optional,
Aspect_Address => Expression, Aspect_Address => Expression,
Aspect_Aliased => Optional,
Aspect_Alignment => Expression, Aspect_Alignment => Expression,
Aspect_Atomic => Optional, Aspect_Atomic => Optional,
Aspect_Atomic_Components => Optional, Aspect_Atomic_Components => Optional,
Aspect_Bit_Order => Expression, Aspect_Bit_Order => Expression,
Aspect_C_Pass_By_Copy => Optional,
Aspect_Component_Size => Expression, Aspect_Component_Size => Expression,
Aspect_Discard_Names => Optional, Aspect_Discard_Names => Optional,
Aspect_External_Tag => Expression, Aspect_External_Tag => Expression,
...@@ -124,20 +120,18 @@ package Aspects is ...@@ -124,20 +120,18 @@ package Aspects is
Aspect_Inline_Always => Optional, Aspect_Inline_Always => Optional,
Aspect_Invariant => Expression, Aspect_Invariant => Expression,
Aspect_Machine_Radix => Expression, Aspect_Machine_Radix => Expression,
Aspect_No_Return => Optional,
Aspect_Object_Size => Expression, Aspect_Object_Size => Expression,
Aspect_Pack => Optional,
Aspect_Persistent_BSS => Optional, Aspect_Persistent_BSS => Optional,
Aspect_Pack => Optional,
Aspect_Post => Expression, Aspect_Post => Expression,
Aspect_Postcondition => Expression,
Aspect_Pre => Expression, Aspect_Pre => Expression,
Aspect_Precondition => Expression,
Aspect_Predicate => Expression, Aspect_Predicate => Expression,
Aspect_Preelaborable_Initialization => Optional, Aspect_Preelaborable_Initialization => Optional,
Aspect_Psect_Object => Optional,
Aspect_Pure_Function => Optional, Aspect_Pure_Function => Optional,
Aspect_Shared => Optional, Aspect_Shared => Optional,
Aspect_Size => Expression, Aspect_Size => Expression,
Aspect_Storage_Pool => Expression, Aspect_Storage_Pool => Name,
Aspect_Storage_Size => Expression, Aspect_Storage_Size => Expression,
Aspect_Stream_Size => Expression, Aspect_Stream_Size => Expression,
Aspect_Suppress => Name, Aspect_Suppress => Name,
...@@ -151,11 +145,50 @@ package Aspects is ...@@ -151,11 +145,50 @@ package Aspects is
Aspect_Value_Size => Expression, Aspect_Value_Size => Expression,
Aspect_Volatile => Optional, Aspect_Volatile => Optional,
Aspect_Volatile_Components => Optional, Aspect_Volatile_Components => Optional,
Aspect_Warnings => Name, Aspect_Warnings => Name);
Aspect_Weak_External => Optional);
function Get_Aspect_Id (Name : Name_Id) return Aspect_Id; function Get_Aspect_Id (Name : Name_Id) return Aspect_Id;
pragma Inline (Get_Aspect_Id);
-- Given a name Nam, returns the corresponding aspect id value. If the name -- Given a name Nam, returns the corresponding aspect id value. If the name
-- does not match any aspect, then No_Aspect is returned as the result. -- does not match any aspect, then No_Aspect is returned as the result.
---------------------------------------------------
-- Handling of Aspect Specifications in the Tree --
---------------------------------------------------
-- Several kinds of declaration node permit aspect specifications in Ada
-- 2012 mode. If there was room in all the corresponding declaration nodes,
-- we could just have a field Aspect_Specifications pointing to a list of
-- nodes for the aspects (N_Aspect_Specification nodes). But there isn't
-- room, so we adopt a different approach.
-- The following subprograms provide access to a specialized interface
-- implemented internally with a hash table in the body, that provides
-- access to aspect specifications.
function Permits_Aspect_Specifications (N : Node_Id) return Boolean;
-- Returns True if the node N is a declaration node that permits aspect
-- specifications. All such nodes have the Has_Aspect_Specifications
-- flag defined. Returns False for all other nodes.
function Aspect_Specifications (N : Node_Id) return List_Id;
-- Given a node N, returns the list of N_Aspect_Specification nodes that
-- are attached to this declaration node. If the node is in the class of
-- declaration nodes that permit aspect specifications, as defined by the
-- predicate above, and if their Has_Aspect_Specifications flag is set to
-- True, then this will always be a non-empty list. If this flag is set to
-- False, or the node is not in the declaration class permitting aspect
-- specifications, then No_List is returned.
procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id);
-- The node N must be in the class of declaration nodes that permit aspect
-- specifications and the Has_Aspect_Specifications flag must be False on
-- entry. L must be a non-empty list of N_Aspect_Specification nodes. This
-- procedure sets the Has_Aspect_Specifications flag to True, and makes an
-- entry that can be retrieved by a subsequent Aspect_Specifications call.
-- The parent of list L is set to reference the declaration node N. It is
-- an error to call this procedure with a node that does not permit aspect
-- specifications, or a node that has its Has_Aspect_Specifications flag
-- set True on entry, or with L being an empty list or No_List.
end Aspects; end Aspects;
...@@ -106,7 +106,7 @@ package body Debug is ...@@ -106,7 +106,7 @@ package body Debug is
-- d.m For -gnatl, print full source only for main unit -- d.m For -gnatl, print full source only for main unit
-- d.n Print source file names -- d.n Print source file names
-- d.o Generate .NET listing of CIL code -- d.o Generate .NET listing of CIL code
-- d.p -- d.p Enable the .NET CIL verifier
-- d.q -- d.q
-- d.r Enable OK_To_Reorder_Components in non-variant records -- d.r Enable OK_To_Reorder_Components in non-variant records
-- d.s Disable expansion of slice move, use memmove -- d.s Disable expansion of slice move, use memmove
...@@ -534,6 +534,10 @@ package body Debug is ...@@ -534,6 +534,10 @@ package body Debug is
-- d.o Generate listing showing the IL instructions generated by the .NET -- d.o Generate listing showing the IL instructions generated by the .NET
-- compiler for each subprogram. -- compiler for each subprogram.
-- d.p Enable the .NET CIL verifier. During development the verifier is
-- disabled by default and this flag is used to enable it. In the
-- future we will reverse this functionality.
-- d.r Forces the flag OK_To_Reorder_Components to be set in all record -- d.r Forces the flag OK_To_Reorder_Components to be set in all record
-- base types that have no discriminants. -- base types that have no discriminants.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -296,7 +296,7 @@ GNATLINK_OBJS = gnatlink.o \ ...@@ -296,7 +296,7 @@ GNATLINK_OBJS = gnatlink.o \
sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \ sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
types.o validsw.o widechar.o types.o validsw.o widechar.o
GNATMAKE_OBJS = a-except.o ali.o ali-util.o s-casuti.o \ GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o \
alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\ alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o\
erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \ erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \ gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -35,6 +35,91 @@ package body Ch13 is ...@@ -35,6 +35,91 @@ package body Ch13 is
function P_Component_Clause return Node_Id; function P_Component_Clause return Node_Id;
function P_Mod_Clause return Node_Id; function P_Mod_Clause return Node_Id;
-----------------------------------
-- Aspect_Specifications_Present --
-----------------------------------
function Aspect_Specifications_Present return Boolean is
Scan_State : Saved_Scan_State;
Result : Boolean;
begin
Save_Scan_State (Scan_State);
-- If we have a semicolon, test for semicolon followed by Aspect
-- Specifications, in which case we decide the semicolon is accidental.
if Token = Tok_Semicolon then
Scan; -- past semicolon
if Aspect_Specifications_Present then
Error_Msg_SP ("|extra "";"" ignored");
return True;
else
Restore_Scan_State (Scan_State);
return False;
end if;
end if;
-- Definitely must have WITH to consider aspect specs to be present
if Token /= Tok_With then
return False;
end if;
-- Have a WITH, see if it looks like an aspect specification
Save_Scan_State (Scan_State);
Scan; -- past WITH
-- If no identifier, then consider that we definitely do not have an
-- aspect specification.
if Token /= Tok_Identifier then
Result := False;
-- In Ada 2012 mode, we are less strict, and we consider that we have
-- an aspect specification if the identifier is an aspect name (even if
-- not followed by =>) or the identifier is not an aspect name but is
-- followed by =>. P_Aspect_Specifications will generate messages if the
-- aspect specification is ill-formed.
elsif Ada_Version >= Ada_2012 then
if Get_Aspect_Id (Token_Name) /= No_Aspect then
Result := True;
else
Scan; -- past identifier
Result := Token = Tok_Arrow;
end if;
-- If earlier than Ada 2012, check for valid aspect identifier followed
-- by an arrow, and consider that this is still an aspect specification
-- so we give an appropriate message.
else
if Get_Aspect_Id (Token_Name) = No_Aspect then
Result := False;
else
Scan; -- past aspect name
if Token /= Tok_Arrow then
Result := False;
else
Restore_Scan_State (Scan_State);
Error_Msg_SC ("|aspect specification is an Ada 2012 feature");
Error_Msg_SC ("\|unit must be compiled with -gnat2012 switch");
return True;
end if;
end if;
end if;
Restore_Scan_State (Scan_State);
return Result;
end Aspect_Specifications_Present;
-------------------------------------------- --------------------------------------------
-- 13.1 Representation Clause (also I.7) -- -- 13.1 Representation Clause (also I.7) --
-------------------------------------------- --------------------------------------------
...@@ -274,6 +359,163 @@ package body Ch13 is ...@@ -274,6 +359,163 @@ package body Ch13 is
-- Parsed by P_Representation_Clause (13.1) -- Parsed by P_Representation_Clause (13.1)
------------------------------
-- 13.1 Aspect Specifation --
------------------------------
-- ASPECT_SPECIFICATION ::=
-- with ASPECT_MARK [=> ASPECT_DEFINITION] {.
-- ASPECT_MARK [=> ASPECT_DEFINITION] }
-- ASPECT_MARK ::= aspect_IDENTIFIER['Class]
-- ASPECT_DEFINITION ::= NAME | EXPRESSION
-- Error recovery: cannot raise Error_Resync
procedure P_Aspect_Specifications (Decl : Node_Id) is
Aspects : List_Id;
Aspect : Node_Id;
A_Id : Aspect_Id;
OK : Boolean;
begin
-- Check if aspect specification present
if not Aspect_Specifications_Present then
T_Semicolon;
return;
end if;
-- Aspect Specification is present
Scan; -- past WITH
-- Here we have an aspect specification to scan, note that we don;t
-- set the flag till later, because it may turn out that we have no
-- valid aspects in the list.
Aspects := Empty_List;
loop
OK := True;
if Token /= Tok_Identifier then
Error_Msg_SC ("aspect identifier expected");
Resync_Past_Semicolon;
return;
end if;
-- We have an identifier (which should be an aspect identifier)
Aspect := Token_Node;
A_Id := Get_Aspect_Id (Token_Name);
Aspect :=
Make_Aspect_Specification (Sloc (Aspect),
Identifier => Token_Node);
-- No valid aspect identifier present
if A_Id = No_Aspect then
Error_Msg_SC ("aspect identifier expected");
if Token = Tok_Apostrophe then
Scan; -- past '
Scan; -- past presumably CLASS
end if;
if Token = Tok_Arrow then
Scan; -- Past arrow
Set_Expression (Aspect, P_Expression);
OK := False;
elsif Token = Tok_Comma then
OK := False;
else
Resync_Past_Semicolon;
return;
end if;
-- OK aspect scanned
else
Scan; -- past identifier
-- Check for 'Class present
if Token = Tok_Apostrophe then
if not Class_Aspect_OK (A_Id) then
Error_Msg_Node_1 := Identifier (Aspect);
Error_Msg_SC ("aspect& does not permit attribute here");
Scan; -- past apostophe
Scan; -- past presumed CLASS
OK := False;
else
Scan; -- past apostrophe
if Token /= Tok_Identifier
or else Token_Name /= Name_Class
then
Error_Msg_SC ("Class attribute expected here");
OK := False;
if Token = Tok_Identifier then
Scan; -- past identifier not CLASS
end if;
end if;
end if;
end if;
-- Test case of missing aspect definition
if Token = Tok_Comma or else Token = Tok_Semicolon then
if Aspect_Argument (A_Id) /= Optional then
Error_Msg_Node_1 := Aspect;
Error_Msg_AP ("aspect& requires an aspect definition");
OK := False;
end if;
-- Here we have an aspect definition
else
if Token = Tok_Arrow then
Scan; -- past arrow
else
T_Arrow;
OK := False;
end if;
if Aspect_Argument (A_Id) = Name then
Set_Expression (Aspect, P_Name);
else
Set_Expression (Aspect, P_Expression);
end if;
end if;
-- If OK clause scanned, add it to the list
if OK then
Append (Aspect, Aspects);
end if;
if Token = Tok_Comma then
Scan; -- past comma
else
T_Semicolon;
exit;
end if;
end if;
end loop;
-- If aspects scanned, store them
if Is_Non_Empty_List (Aspects) then
Set_Parent (Aspects, Decl);
Set_Aspect_Specifications (Decl, Aspects);
end if;
end P_Aspect_Specifications;
--------------------------------------------- ---------------------------------------------
-- 13.4 Enumeration Representation Clause -- -- 13.4 Enumeration Representation Clause --
--------------------------------------------- ---------------------------------------------
......
...@@ -327,7 +327,7 @@ package body Ch3 is ...@@ -327,7 +327,7 @@ package body Ch3 is
Type_Start_Col : Column_Number; Type_Start_Col : Column_Number;
Unknown_Dis : Boolean; Unknown_Dis : Boolean;
Typedef_Node : Node_Id; Typedef_Node : Node_Id;
-- Normally holds type definition, except in the case of a private -- Normally holds type definition, except in the case of a private
-- extension declaration, in which case it holds the declaration itself -- extension declaration, in which case it holds the declaration itself
...@@ -476,22 +476,18 @@ package body Ch3 is ...@@ -476,22 +476,18 @@ package body Ch3 is
when Tok_Access | when Tok_Access |
Tok_Not => -- Ada 2005 (AI-231) Tok_Not => -- Ada 2005 (AI-231)
Typedef_Node := P_Access_Type_Definition; Typedef_Node := P_Access_Type_Definition;
TF_Semicolon;
exit; exit;
when Tok_Array => when Tok_Array =>
Typedef_Node := P_Array_Type_Definition; Typedef_Node := P_Array_Type_Definition;
TF_Semicolon;
exit; exit;
when Tok_Delta => when Tok_Delta =>
Typedef_Node := P_Fixed_Point_Definition; Typedef_Node := P_Fixed_Point_Definition;
TF_Semicolon;
exit; exit;
when Tok_Digits => when Tok_Digits =>
Typedef_Node := P_Floating_Point_Definition; Typedef_Node := P_Floating_Point_Definition;
TF_Semicolon;
exit; exit;
when Tok_In => when Tok_In =>
...@@ -500,12 +496,10 @@ package body Ch3 is ...@@ -500,12 +496,10 @@ package body Ch3 is
when Tok_Integer_Literal => when Tok_Integer_Literal =>
T_Range; T_Range;
Typedef_Node := P_Signed_Integer_Type_Definition; Typedef_Node := P_Signed_Integer_Type_Definition;
TF_Semicolon;
exit; exit;
when Tok_Null => when Tok_Null =>
Typedef_Node := P_Record_Definition; Typedef_Node := P_Record_Definition;
TF_Semicolon;
exit; exit;
when Tok_Left_Paren => when Tok_Left_Paren =>
...@@ -517,12 +511,10 @@ package body Ch3 is ...@@ -517,12 +511,10 @@ package body Ch3 is
Set_Comes_From_Source (End_Labl, False); Set_Comes_From_Source (End_Labl, False);
Set_End_Label (Typedef_Node, End_Labl); Set_End_Label (Typedef_Node, End_Labl);
TF_Semicolon;
exit; exit;
when Tok_Mod => when Tok_Mod =>
Typedef_Node := P_Modular_Type_Definition; Typedef_Node := P_Modular_Type_Definition;
TF_Semicolon;
exit; exit;
when Tok_New => when Tok_New =>
...@@ -540,12 +532,10 @@ package body Ch3 is ...@@ -540,12 +532,10 @@ package body Ch3 is
(Record_Extension_Part (Typedef_Node), End_Labl); (Record_Extension_Part (Typedef_Node), End_Labl);
end if; end if;
TF_Semicolon;
exit; exit;
when Tok_Range => when Tok_Range =>
Typedef_Node := P_Signed_Integer_Type_Definition; Typedef_Node := P_Signed_Integer_Type_Definition;
TF_Semicolon;
exit; exit;
when Tok_Record => when Tok_Record =>
...@@ -557,7 +547,6 @@ package body Ch3 is ...@@ -557,7 +547,6 @@ package body Ch3 is
Set_Comes_From_Source (End_Labl, False); Set_Comes_From_Source (End_Labl, False);
Set_End_Label (Typedef_Node, End_Labl); Set_End_Label (Typedef_Node, End_Labl);
TF_Semicolon;
exit; exit;
when Tok_Tagged => when Tok_Tagged =>
...@@ -640,7 +629,6 @@ package body Ch3 is ...@@ -640,7 +629,6 @@ package body Ch3 is
end if; end if;
end if; end if;
TF_Semicolon;
exit; exit;
when Tok_Limited => when Tok_Limited =>
...@@ -733,7 +721,6 @@ package body Ch3 is ...@@ -733,7 +721,6 @@ package body Ch3 is
T_Private; -- past PRIVATE (or complain if not there!) T_Private; -- past PRIVATE (or complain if not there!)
end if; end if;
TF_Semicolon;
exit; exit;
-- Here we have an identifier after the IS, which is certainly -- Here we have an identifier after the IS, which is certainly
...@@ -748,7 +735,6 @@ package body Ch3 is ...@@ -748,7 +735,6 @@ package body Ch3 is
if not Token_Is_At_Start_Of_Line then if not Token_Is_At_Start_Of_Line then
Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl; Typedef_Node := P_Derived_Type_Def_Or_Private_Ext_Decl;
TF_Semicolon;
-- If the identifier is at the start of the line, and is in the -- If the identifier is at the start of the line, and is in the
-- same column as the type declaration itself then we consider -- same column as the type declaration itself then we consider
...@@ -769,7 +755,6 @@ package body Ch3 is ...@@ -769,7 +755,6 @@ package body Ch3 is
else else
Typedef_Node := P_Record_Definition; Typedef_Node := P_Record_Definition;
TF_Semicolon;
end if; end if;
exit; exit;
...@@ -779,13 +764,11 @@ package body Ch3 is ...@@ -779,13 +764,11 @@ package body Ch3 is
when Tok_Interface => when Tok_Interface =>
Typedef_Node := P_Interface_Type_Definition (Abstract_Present); Typedef_Node := P_Interface_Type_Definition (Abstract_Present);
Abstract_Present := True; Abstract_Present := True;
TF_Semicolon;
exit; exit;
when Tok_Private => when Tok_Private =>
Decl_Node := New_Node (N_Private_Type_Declaration, Type_Loc); Decl_Node := New_Node (N_Private_Type_Declaration, Type_Loc);
Scan; -- past PRIVATE Scan; -- past PRIVATE
TF_Semicolon;
exit; exit;
-- Ada 2005 (AI-345): Protected, synchronized or task interface -- Ada 2005 (AI-345): Protected, synchronized or task interface
...@@ -849,7 +832,6 @@ package body Ch3 is ...@@ -849,7 +832,6 @@ package body Ch3 is
end if; end if;
end; end;
TF_Semicolon;
exit; exit;
-- Anything else is an error -- Anything else is an error
...@@ -933,6 +915,7 @@ package body Ch3 is ...@@ -933,6 +915,7 @@ package body Ch3 is
Set_Defining_Identifier (Decl_Node, Ident_Node); Set_Defining_Identifier (Decl_Node, Ident_Node);
Set_Discriminant_Specifications (Decl_Node, Discr_List); Set_Discriminant_Specifications (Decl_Node, Discr_List);
P_Aspect_Specifications (Decl_Node);
return Decl_Node; return Decl_Node;
end P_Type_Declaration; end P_Type_Declaration;
...@@ -980,7 +963,7 @@ package body Ch3 is ...@@ -980,7 +963,7 @@ package body Ch3 is
Set_Subtype_Indication Set_Subtype_Indication
(Decl_Node, P_Subtype_Indication (Not_Null_Present)); (Decl_Node, P_Subtype_Indication (Not_Null_Present));
TF_Semicolon; P_Aspect_Specifications (Decl_Node);
return Decl_Node; return Decl_Node;
end P_Subtype_Declaration; end P_Subtype_Declaration;
...@@ -1836,8 +1819,8 @@ package body Ch3 is ...@@ -1836,8 +1819,8 @@ package body Ch3 is
end if; end if;
end if; end if;
TF_Semicolon;
Set_Defining_Identifier (Decl_Node, Idents (Ident)); Set_Defining_Identifier (Decl_Node, Idents (Ident));
P_Aspect_Specifications (Decl_Node);
if List_OK then if List_OK then
if Ident < Num_Idents then if Ident < Num_Idents then
...@@ -1976,7 +1959,16 @@ package body Ch3 is ...@@ -1976,7 +1959,16 @@ package body Ch3 is
-- missing in the case of "type X is new Y record ..." or in the -- missing in the case of "type X is new Y record ..." or in the
-- case of "type X is new Y null record". -- case of "type X is new Y null record".
if Token = Tok_With -- First make sure we don't have an aspect specification. If we do
-- return now, so that our caller can check it (the WITH here is not
-- part of a type extension).
if Aspect_Specifications_Present then
return Typedef_Node;
-- OK, not an aspect specification, so continue test for extension
elsif Token = Tok_With
or else Token = Tok_Record or else Token = Tok_Record
or else Token = Tok_Null or else Token = Tok_Null
then then
...@@ -3470,10 +3462,9 @@ package body Ch3 is ...@@ -3470,10 +3462,9 @@ package body Ch3 is
Ident := Ident + 1; Ident := Ident + 1;
Restore_Scan_State (Scan_State); Restore_Scan_State (Scan_State);
T_Colon; T_Colon;
end loop Ident_Loop; end loop Ident_Loop;
TF_Semicolon; P_Aspect_Specifications (Decl_Node);
end P_Component_Items; end P_Component_Items;
-------------------------------- --------------------------------
......
...@@ -305,7 +305,7 @@ package body Ch6 is ...@@ -305,7 +305,7 @@ package body Ch6 is
Set_Defining_Unit_Name (Inst_Node, Name_Node); Set_Defining_Unit_Name (Inst_Node, Name_Node);
Set_Generic_Associations (Inst_Node, P_Generic_Actual_Part_Opt); Set_Generic_Associations (Inst_Node, P_Generic_Actual_Part_Opt);
TF_Semicolon; P_Aspect_Specifications (Inst_Node);
Pop_Scope_Stack; -- Don't need scope stack entry in this case Pop_Scope_Stack; -- Don't need scope stack entry in this case
if Is_Overriding then if Is_Overriding then
...@@ -525,7 +525,7 @@ package body Ch6 is ...@@ -525,7 +525,7 @@ package body Ch6 is
Set_Specification (Absdec_Node, Specification_Node); Set_Specification (Absdec_Node, Specification_Node);
Pop_Scope_Stack; -- discard unneeded entry Pop_Scope_Stack; -- discard unneeded entry
Scan; -- past ABSTRACT Scan; -- past ABSTRACT
TF_Semicolon; P_Aspect_Specifications (Absdec_Node);
return Absdec_Node; return Absdec_Node;
-- Ada 2005 (AI-248): Parse a null procedure declaration -- Ada 2005 (AI-248): Parse a null procedure declaration
......
...@@ -900,7 +900,7 @@ package body Ch9 is ...@@ -900,7 +900,7 @@ package body Ch9 is
Discard_Junk_Node (P_Expression_No_Right_Paren); Discard_Junk_Node (P_Expression_No_Right_Paren);
end if; end if;
TF_Semicolon; P_Aspect_Specifications (Decl_Node);
return Decl_Node; return Decl_Node;
exception exception
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Casing; use Casing; with Casing; use Casing;
with Debug; use Debug; with Debug; use Debug;
...@@ -836,6 +837,25 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is ...@@ -836,6 +837,25 @@ function Par (Configuration_Pragmas : Boolean) return List_Id is
package Ch13 is package Ch13 is
function P_Representation_Clause return Node_Id; function P_Representation_Clause return Node_Id;
function Aspect_Specifications_Present return Boolean;
-- This function tests whether the next keyword is WITH followed by
-- something that looks reasonably like an aspect specification. If so,
-- True is returned. Otherwise False is returned. In either case control
-- returns with the token pointer unchanged (i.e. pointing to the WITH
-- token in the case where True is returned). This function takes care
-- of generating appropriate messages if aspect specifications appear
-- in versions of Ada prior to Ada 2012.
procedure P_Aspect_Specifications (Decl : Node_Id);
-- This subprogram is called with the current token pointing to either a
-- WITH keyword starting an aspect specification, or a semicolon. In the
-- former case, the aspect specifications are scanned out including the
-- terminating semicolon, the Has_Aspect_Specifications flag is set in
-- the given declaration node, and the list of aspect specifications is
-- constructed and associated with this declaration node using a call to
-- Set_Aspect_Specifications. If no WITH keyword is present, then this
-- call has no effect other than scanning out the semicolon.
function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id; function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id;
-- Function to parse a code statement. The caller has scanned out -- Function to parse a code statement. The caller has scanned out
-- the name to be used as the subtype mark (but has not checked that -- the name to be used as the subtype mark (but has not checked that
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1995-2009, AdaCore -- -- Copyright (C) 1995-2010, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -110,7 +110,7 @@ package body System.HTable is ...@@ -110,7 +110,7 @@ package body System.HTable is
function Get_Non_Null return Elmt_Ptr is function Get_Non_Null return Elmt_Ptr is
begin begin
while Iterator_Ptr = Null_Ptr loop while Iterator_Ptr = Null_Ptr loop
if Iterator_Index = Table'Last then if Iterator_Index = Table'Last then
Iterator_Started := False; Iterator_Started := False;
return Null_Ptr; return Null_Ptr;
......
...@@ -237,10 +237,10 @@ package body Sem is ...@@ -237,10 +237,10 @@ package body Sem is
Analyze_Formal_Object_Declaration (N); Analyze_Formal_Object_Declaration (N);
when N_Formal_Package_Declaration => when N_Formal_Package_Declaration =>
Analyze_Formal_Package (N); Analyze_Formal_Package_Declaration (N);
when N_Formal_Subprogram_Declaration => when N_Formal_Subprogram_Declaration =>
Analyze_Formal_Subprogram (N); Analyze_Formal_Subprogram_Declaration (N);
when N_Formal_Type_Declaration => when N_Formal_Type_Declaration =>
Analyze_Formal_Type_Declaration (N); Analyze_Formal_Type_Declaration (N);
...@@ -252,7 +252,7 @@ package body Sem is ...@@ -252,7 +252,7 @@ package body Sem is
Analyze_Freeze_Entity (N); Analyze_Freeze_Entity (N);
when N_Full_Type_Declaration => when N_Full_Type_Declaration =>
Analyze_Type_Declaration (N); Analyze_Full_Type_Declaration (N);
when N_Function_Call => when N_Function_Call =>
Analyze_Function_Call (N); Analyze_Function_Call (N);
...@@ -465,7 +465,7 @@ package body Sem is ...@@ -465,7 +465,7 @@ package body Sem is
Analyze_Protected_Definition (N); Analyze_Protected_Definition (N);
when N_Protected_Type_Declaration => when N_Protected_Type_Declaration =>
Analyze_Protected_Type (N); Analyze_Protected_Type_Declaration (N);
when N_Qualified_Expression => when N_Qualified_Expression =>
Analyze_Qualified_Expression (N); Analyze_Qualified_Expression (N);
...@@ -505,10 +505,10 @@ package body Sem is ...@@ -505,10 +505,10 @@ package body Sem is
Analyze_Selective_Accept (N); Analyze_Selective_Accept (N);
when N_Single_Protected_Declaration => when N_Single_Protected_Declaration =>
Analyze_Single_Protected (N); Analyze_Single_Protected_Declaration (N);
when N_Single_Task_Declaration => when N_Single_Task_Declaration =>
Analyze_Single_Task (N); Analyze_Single_Task_Declaration (N);
when N_Slice => when N_Slice =>
Analyze_Slice (N); Analyze_Slice (N);
...@@ -550,7 +550,7 @@ package body Sem is ...@@ -550,7 +550,7 @@ package body Sem is
Analyze_Task_Definition (N); Analyze_Task_Definition (N);
when N_Task_Type_Declaration => when N_Task_Type_Declaration =>
Analyze_Task_Type (N); Analyze_Task_Type_Declaration (N);
when N_Terminate_Alternative => when N_Terminate_Alternative =>
Analyze_Terminate_Alternative (N); Analyze_Terminate_Alternative (N);
......
...@@ -1754,8 +1754,8 @@ package body Sem_Cat is ...@@ -1754,8 +1754,8 @@ package body Sem_Cat is
-- Start of processing for Validate_Remote_Access_Object_Type_Declaration -- Start of processing for Validate_Remote_Access_Object_Type_Declaration
begin begin
-- We are called from Analyze_Type_Declaration, and the Nkind of the -- We are called from Analyze_Full_Type_Declaration, and the Nkind of
-- given node is N_Access_To_Object_Definition. -- the given node is N_Access_To_Object_Definition.
if not Comes_From_Source (T) if not Comes_From_Source (T)
or else (not In_RCI_Declaration (Parent (T)) or else (not In_RCI_Declaration (Parent (T))
...@@ -2055,7 +2055,7 @@ package body Sem_Cat is ...@@ -2055,7 +2055,7 @@ package body Sem_Cat is
-- Start of processing for Validate_SP_Access_Object_Type_Decl -- Start of processing for Validate_SP_Access_Object_Type_Decl
begin begin
-- We are called from Sem_Ch3.Analyze_Type_Declaration, and the -- We are called from Sem_Ch3.Analyze_Full_Type_Declaration, and the
-- Nkind of the given entity is N_Access_To_Object_Definition. -- Nkind of the given entity is N_Access_To_Object_Definition.
if not Comes_From_Source (T) if not Comes_From_Source (T)
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Checks; use Checks; with Checks; use Checks;
with Einfo; use Einfo; with Einfo; use Einfo;
...@@ -39,6 +40,7 @@ with Rtsfind; use Rtsfind; ...@@ -39,6 +40,7 @@ with Rtsfind; use Rtsfind;
with Sem; use Sem; with Sem; use Sem;
with Sem_Ch5; use Sem_Ch5; with Sem_Ch5; use Sem_Ch5;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
with Sem_Res; use Sem_Res; with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util; with Sem_Util; use Sem_Util;
with Sem_Warn; use Sem_Warn; with Sem_Warn; use Sem_Warn;
...@@ -55,6 +57,7 @@ package body Sem_Ch11 is ...@@ -55,6 +57,7 @@ package body Sem_Ch11 is
procedure Analyze_Exception_Declaration (N : Node_Id) is procedure Analyze_Exception_Declaration (N : Node_Id) is
Id : constant Entity_Id := Defining_Identifier (N); Id : constant Entity_Id := Defining_Identifier (N);
PF : constant Boolean := Is_Pure (Current_Scope); PF : constant Boolean := Is_Pure (Current_Scope);
AS : constant List_Id := Aspect_Specifications (N);
begin begin
Generate_Definition (Id); Generate_Definition (Id);
Enter_Name (Id); Enter_Name (Id);
...@@ -63,6 +66,7 @@ package body Sem_Ch11 is ...@@ -63,6 +66,7 @@ package body Sem_Ch11 is
Set_Etype (Id, Standard_Exception_Type); Set_Etype (Id, Standard_Exception_Type);
Set_Is_Statically_Allocated (Id); Set_Is_Statically_Allocated (Id);
Set_Is_Pure (Id, PF); Set_Is_Pure (Id, PF);
Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Exception_Declaration; end Analyze_Exception_Declaration;
-------------------------------- --------------------------------
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Einfo; use Einfo; with Einfo; use Einfo;
with Elists; use Elists; with Elists; use Elists;
...@@ -1801,6 +1802,7 @@ package body Sem_Ch12 is ...@@ -1801,6 +1802,7 @@ package body Sem_Ch12 is
procedure Analyze_Formal_Object_Declaration (N : Node_Id) is procedure Analyze_Formal_Object_Declaration (N : Node_Id) is
E : constant Node_Id := Default_Expression (N); E : constant Node_Id := Default_Expression (N);
Id : constant Node_Id := Defining_Identifier (N); Id : constant Node_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
K : Entity_Kind; K : Entity_Kind;
T : Node_Id; T : Node_Id;
...@@ -1929,6 +1931,8 @@ package body Sem_Ch12 is ...@@ -1929,6 +1931,8 @@ package body Sem_Ch12 is
("initialization not allowed for `IN OUT` formals", N); ("initialization not allowed for `IN OUT` formals", N);
end if; end if;
end if; end if;
Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Formal_Object_Declaration; end Analyze_Formal_Object_Declaration;
---------------------------------------------- ----------------------------------------------
...@@ -1972,13 +1976,14 @@ package body Sem_Ch12 is ...@@ -1972,13 +1976,14 @@ package body Sem_Ch12 is
Check_Restriction (No_Fixed_Point, Def); Check_Restriction (No_Fixed_Point, Def);
end Analyze_Formal_Ordinary_Fixed_Point_Type; end Analyze_Formal_Ordinary_Fixed_Point_Type;
---------------------------- ----------------------------------------
-- Analyze_Formal_Package -- -- Analyze_Formal_Package_Declaration --
---------------------------- ----------------------------------------
procedure Analyze_Formal_Package (N : Node_Id) is procedure Analyze_Formal_Package_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
Pack_Id : constant Entity_Id := Defining_Identifier (N); Pack_Id : constant Entity_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
Formal : Entity_Id; Formal : Entity_Id;
Gen_Id : constant Node_Id := Name (N); Gen_Id : constant Node_Id := Name (N);
Gen_Decl : Node_Id; Gen_Decl : Node_Id;
...@@ -2115,14 +2120,14 @@ package body Sem_Ch12 is ...@@ -2115,14 +2120,14 @@ package body Sem_Ch12 is
if Ekind (Gen_Unit) /= E_Generic_Package then if Ekind (Gen_Unit) /= E_Generic_Package then
Error_Msg_N ("expect generic package name", Gen_Id); Error_Msg_N ("expect generic package name", Gen_Id);
Restore_Env; Restore_Env;
return; goto Leave;
elsif Gen_Unit = Current_Scope then elsif Gen_Unit = Current_Scope then
Error_Msg_N Error_Msg_N
("generic package cannot be used as a formal package of itself", ("generic package cannot be used as a formal package of itself",
Gen_Id); Gen_Id);
Restore_Env; Restore_Env;
return; goto Leave;
elsif In_Open_Scopes (Gen_Unit) then elsif In_Open_Scopes (Gen_Unit) then
if Is_Compilation_Unit (Gen_Unit) if Is_Compilation_Unit (Gen_Unit)
...@@ -2142,7 +2147,7 @@ package body Sem_Ch12 is ...@@ -2142,7 +2147,7 @@ package body Sem_Ch12 is
& "within itself", & "within itself",
Gen_Id); Gen_Id);
Restore_Env; Restore_Env;
return; goto Leave;
end if; end if;
end if; end if;
...@@ -2190,7 +2195,7 @@ package body Sem_Ch12 is ...@@ -2190,7 +2195,7 @@ package body Sem_Ch12 is
Remove_Parent; Remove_Parent;
end if; end if;
return; goto Leave;
end; end;
Rewrite (N, New_N); Rewrite (N, New_N);
...@@ -2273,7 +2278,9 @@ package body Sem_Ch12 is ...@@ -2273,7 +2278,9 @@ package body Sem_Ch12 is
Set_Etype (Pack_Id, Standard_Void_Type); Set_Etype (Pack_Id, Standard_Void_Type);
Set_Scope (Pack_Id, Scope (Formal)); Set_Scope (Pack_Id, Scope (Formal));
Set_Has_Completion (Pack_Id, True); Set_Has_Completion (Pack_Id, True);
end Analyze_Formal_Package;
<<Leave>> Analyze_Aspect_Specifications (N, Pack_Id, AS);
end Analyze_Formal_Package_Declaration;
--------------------------------- ---------------------------------
-- Analyze_Formal_Private_Type -- -- Analyze_Formal_Private_Type --
...@@ -2323,14 +2330,15 @@ package body Sem_Ch12 is ...@@ -2323,14 +2330,15 @@ package body Sem_Ch12 is
Set_Parent (Base, Parent (Def)); Set_Parent (Base, Parent (Def));
end Analyze_Formal_Signed_Integer_Type; end Analyze_Formal_Signed_Integer_Type;
------------------------------- -------------------------------------------
-- Analyze_Formal_Subprogram -- -- Analyze_Formal_Subprogram_Declaration --
------------------------------- -------------------------------------------
procedure Analyze_Formal_Subprogram (N : Node_Id) is procedure Analyze_Formal_Subprogram_Declaration (N : Node_Id) is
Spec : constant Node_Id := Specification (N); Spec : constant Node_Id := Specification (N);
Def : constant Node_Id := Default_Name (N); Def : constant Node_Id := Default_Name (N);
Nam : constant Entity_Id := Defining_Unit_Name (Spec); Nam : constant Entity_Id := Defining_Unit_Name (Spec);
AS : constant List_Id := Aspect_Specifications (N);
Subp : Entity_Id; Subp : Entity_Id;
begin begin
...@@ -2340,7 +2348,7 @@ package body Sem_Ch12 is ...@@ -2340,7 +2348,7 @@ package body Sem_Ch12 is
if Nkind (Nam) = N_Defining_Program_Unit_Name then if Nkind (Nam) = N_Defining_Program_Unit_Name then
Error_Msg_N ("name of formal subprogram must be a direct name", Nam); Error_Msg_N ("name of formal subprogram must be a direct name", Nam);
return; goto Leave;
end if; end if;
Analyze_Subprogram_Declaration (N); Analyze_Subprogram_Declaration (N);
...@@ -2384,7 +2392,7 @@ package body Sem_Ch12 is ...@@ -2384,7 +2392,7 @@ package body Sem_Ch12 is
Analyze (Prefix (Def)); Analyze (Prefix (Def));
Valid_Default_Attribute (Nam, Def); Valid_Default_Attribute (Nam, Def);
return; goto Leave;
end if; end if;
-- Default name may be overloaded, in which case the interpretation -- Default name may be overloaded, in which case the interpretation
...@@ -2394,7 +2402,7 @@ package body Sem_Ch12 is ...@@ -2394,7 +2402,7 @@ package body Sem_Ch12 is
-- can be a protected operation. -- can be a protected operation.
if Etype (Def) = Any_Type then if Etype (Def) = Any_Type then
return; goto Leave;
elsif Nkind (Def) = N_Selected_Component then elsif Nkind (Def) = N_Selected_Component then
if not Is_Overloadable (Entity (Selector_Name (Def))) then if not Is_Overloadable (Entity (Selector_Name (Def))) then
...@@ -2416,7 +2424,7 @@ package body Sem_Ch12 is ...@@ -2416,7 +2424,7 @@ package body Sem_Ch12 is
else else
Error_Msg_N ("expect valid subprogram name as default", Def); Error_Msg_N ("expect valid subprogram name as default", Def);
return; goto Leave;
end if; end if;
elsif Nkind (Def) = N_Character_Literal then elsif Nkind (Def) = N_Character_Literal then
...@@ -2429,7 +2437,7 @@ package body Sem_Ch12 is ...@@ -2429,7 +2437,7 @@ package body Sem_Ch12 is
or else not Is_Overloadable (Entity (Def)) or else not Is_Overloadable (Entity (Def))
then then
Error_Msg_N ("expect valid subprogram name as default", Def); Error_Msg_N ("expect valid subprogram name as default", Def);
return; goto Leave;
elsif not Is_Overloaded (Def) then elsif not Is_Overloaded (Def) then
Subp := Entity (Def); Subp := Entity (Def);
...@@ -2491,7 +2499,9 @@ package body Sem_Ch12 is ...@@ -2491,7 +2499,9 @@ package body Sem_Ch12 is
end if; end if;
end if; end if;
end if; end if;
end Analyze_Formal_Subprogram;
<<Leave>> Analyze_Aspect_Specifications (N, Nam, AS);
end Analyze_Formal_Subprogram_Declaration;
------------------------------------- -------------------------------------
-- Analyze_Formal_Type_Declaration -- -- Analyze_Formal_Type_Declaration --
...@@ -2499,6 +2509,7 @@ package body Sem_Ch12 is ...@@ -2499,6 +2509,7 @@ package body Sem_Ch12 is
procedure Analyze_Formal_Type_Declaration (N : Node_Id) is procedure Analyze_Formal_Type_Declaration (N : Node_Id) is
Def : constant Node_Id := Formal_Type_Definition (N); Def : constant Node_Id := Formal_Type_Definition (N);
AS : constant List_Id := Aspect_Specifications (N);
T : Entity_Id; T : Entity_Id;
begin begin
...@@ -2564,6 +2575,7 @@ package body Sem_Ch12 is ...@@ -2564,6 +2575,7 @@ package body Sem_Ch12 is
end case; end case;
Set_Is_Generic_Type (T); Set_Is_Generic_Type (T);
Analyze_Aspect_Specifications (N, T, AS);
end Analyze_Formal_Type_Declaration; end Analyze_Formal_Type_Declaration;
------------------------------------ ------------------------------------
...@@ -2630,6 +2642,7 @@ package body Sem_Ch12 is ...@@ -2630,6 +2642,7 @@ package body Sem_Ch12 is
procedure Analyze_Generic_Package_Declaration (N : Node_Id) is procedure Analyze_Generic_Package_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
AS : constant List_Id := Aspect_Specifications (N);
Id : Entity_Id; Id : Entity_Id;
New_N : Node_Id; New_N : Node_Id;
Save_Parent : Node_Id; Save_Parent : Node_Id;
...@@ -2740,6 +2753,8 @@ package body Sem_Ch12 is ...@@ -2740,6 +2753,8 @@ package body Sem_Ch12 is
Check_References (Id); Check_References (Id);
end if; end if;
end if; end if;
Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Generic_Package_Declaration; end Analyze_Generic_Package_Declaration;
-------------------------------------------- --------------------------------------------
...@@ -2747,6 +2762,7 @@ package body Sem_Ch12 is ...@@ -2747,6 +2762,7 @@ package body Sem_Ch12 is
-------------------------------------------- --------------------------------------------
procedure Analyze_Generic_Subprogram_Declaration (N : Node_Id) is procedure Analyze_Generic_Subprogram_Declaration (N : Node_Id) is
AS : constant List_Id := Aspect_Specifications (N);
Spec : Node_Id; Spec : Node_Id;
Id : Entity_Id; Id : Entity_Id;
Formals : List_Id; Formals : List_Id;
...@@ -2865,6 +2881,7 @@ package body Sem_Ch12 is ...@@ -2865,6 +2881,7 @@ package body Sem_Ch12 is
End_Scope; End_Scope;
Exit_Generic_Scope (Id); Exit_Generic_Scope (Id);
Generate_Reference_To_Formals (Id); Generate_Reference_To_Formals (Id);
Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Generic_Subprogram_Declaration; end Analyze_Generic_Subprogram_Declaration;
----------------------------------- -----------------------------------
...@@ -2874,6 +2891,7 @@ package body Sem_Ch12 is ...@@ -2874,6 +2891,7 @@ package body Sem_Ch12 is
procedure Analyze_Package_Instantiation (N : Node_Id) is procedure Analyze_Package_Instantiation (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
Gen_Id : constant Node_Id := Name (N); Gen_Id : constant Node_Id := Name (N);
AS : constant List_Id := Aspect_Specifications (N);
Act_Decl : Node_Id; Act_Decl : Node_Id;
Act_Decl_Name : Node_Id; Act_Decl_Name : Node_Id;
...@@ -3014,7 +3032,7 @@ package body Sem_Ch12 is ...@@ -3014,7 +3032,7 @@ package body Sem_Ch12 is
if Etype (Gen_Unit) = Any_Type then if Etype (Gen_Unit) = Any_Type then
Restore_Env; Restore_Env;
return; goto Leave;
elsif Ekind (Gen_Unit) /= E_Generic_Package then elsif Ekind (Gen_Unit) /= E_Generic_Package then
...@@ -3029,7 +3047,7 @@ package body Sem_Ch12 is ...@@ -3029,7 +3047,7 @@ package body Sem_Ch12 is
end if; end if;
Restore_Env; Restore_Env;
return; goto Leave;
end if; end if;
if In_Extended_Main_Source_Unit (N) then if In_Extended_Main_Source_Unit (N) then
...@@ -3072,7 +3090,7 @@ package body Sem_Ch12 is ...@@ -3072,7 +3090,7 @@ package body Sem_Ch12 is
if In_Open_Scopes (Gen_Unit) then if In_Open_Scopes (Gen_Unit) then
Error_Msg_NE ("instantiation of & within itself", N, Gen_Unit); Error_Msg_NE ("instantiation of & within itself", N, Gen_Unit);
Restore_Env; Restore_Env;
return; goto Leave;
elsif Contains_Instance_Of (Gen_Unit, Current_Scope, Gen_Id) then elsif Contains_Instance_Of (Gen_Unit, Current_Scope, Gen_Id) then
Error_Msg_Node_2 := Current_Scope; Error_Msg_Node_2 := Current_Scope;
...@@ -3080,7 +3098,7 @@ package body Sem_Ch12 is ...@@ -3080,7 +3098,7 @@ package body Sem_Ch12 is
("circular Instantiation: & instantiated in &!", N, Gen_Unit); ("circular Instantiation: & instantiated in &!", N, Gen_Unit);
Circularity_Detected := True; Circularity_Detected := True;
Restore_Env; Restore_Env;
return; goto Leave;
else else
Gen_Decl := Unit_Declaration_Node (Gen_Unit); Gen_Decl := Unit_Declaration_Node (Gen_Unit);
...@@ -3537,6 +3555,8 @@ package body Sem_Ch12 is ...@@ -3537,6 +3555,8 @@ package body Sem_Ch12 is
Set_Defining_Identifier (N, Act_Decl_Id); Set_Defining_Identifier (N, Act_Decl_Id);
end if; end if;
<<Leave>> Analyze_Aspect_Specifications (N, Act_Decl_Id, AS);
exception exception
when Instantiation_Error => when Instantiation_Error =>
if Parent_Installed then if Parent_Installed then
...@@ -3890,6 +3910,7 @@ package body Sem_Ch12 is ...@@ -3890,6 +3910,7 @@ package body Sem_Ch12 is
is is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
Gen_Id : constant Node_Id := Name (N); Gen_Id : constant Node_Id := Name (N);
AS : constant List_Id := Aspect_Specifications (N);
Anon_Id : constant Entity_Id := Anon_Id : constant Entity_Id :=
Make_Defining_Identifier (Sloc (Defining_Entity (N)), Make_Defining_Identifier (Sloc (Defining_Entity (N)),
...@@ -4153,7 +4174,7 @@ package body Sem_Ch12 is ...@@ -4153,7 +4174,7 @@ package body Sem_Ch12 is
Error_Msg_NE Error_Msg_NE
("circular Instantiation: & instantiated in &!", N, Gen_Unit); ("circular Instantiation: & instantiated in &!", N, Gen_Unit);
Circularity_Detected := True; Circularity_Detected := True;
return; goto Leave;
end if; end if;
Gen_Decl := Unit_Declaration_Node (Gen_Unit); Gen_Decl := Unit_Declaration_Node (Gen_Unit);
...@@ -4311,6 +4332,8 @@ package body Sem_Ch12 is ...@@ -4311,6 +4332,8 @@ package body Sem_Ch12 is
Generic_Renamings_HTable.Reset; Generic_Renamings_HTable.Reset;
end if; end if;
<<Leave>> Analyze_Aspect_Specifications (N, Act_Decl_Id, AS);
exception exception
when Instantiation_Error => when Instantiation_Error =>
if Parent_Installed then if Parent_Installed then
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -34,8 +34,8 @@ package Sem_Ch12 is ...@@ -34,8 +34,8 @@ package Sem_Ch12 is
procedure Analyze_Function_Instantiation (N : Node_Id); procedure Analyze_Function_Instantiation (N : Node_Id);
procedure Analyze_Formal_Object_Declaration (N : Node_Id); procedure Analyze_Formal_Object_Declaration (N : Node_Id);
procedure Analyze_Formal_Type_Declaration (N : Node_Id); procedure Analyze_Formal_Type_Declaration (N : Node_Id);
procedure Analyze_Formal_Subprogram (N : Node_Id); procedure Analyze_Formal_Subprogram_Declaration (N : Node_Id);
procedure Analyze_Formal_Package (N : Node_Id); procedure Analyze_Formal_Package_Declaration (N : Node_Id);
procedure Start_Generic; procedure Start_Generic;
-- Must be invoked before starting to process a generic spec or body -- Must be invoked before starting to process a generic spec or body
......
...@@ -36,6 +36,17 @@ package Sem_Ch13 is ...@@ -36,6 +36,17 @@ package Sem_Ch13 is
procedure Analyze_Record_Representation_Clause (N : Node_Id); procedure Analyze_Record_Representation_Clause (N : Node_Id);
procedure Analyze_Code_Statement (N : Node_Id); procedure Analyze_Code_Statement (N : Node_Id);
procedure Analyze_Aspect_Specifications
(N : Node_Id;
E : Entity_Id;
L : List_Id);
-- This procedure is called to analyze aspect spefications for node N. E is
-- the corresponding entity declared by the declaration node N, and L is
-- the list of aspect specifications for this node. If L is No_List, the
-- call is ignored. Note that we can't use a simpler interface of just
-- passing the node N, since the analysis of the node may cause it to be
-- rewritten to a node not permitting aspect specifications.
procedure Adjust_Record_For_Reverse_Bit_Order (R : Entity_Id); procedure Adjust_Record_For_Reverse_Bit_Order (R : Entity_Id);
-- Called from Freeze where R is a record entity for which reverse bit -- Called from Freeze where R is a record entity for which reverse bit
-- order is specified and there is at least one component clause. Adjusts -- order is specified and there is at least one component clause. Adjusts
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -28,6 +28,7 @@ with Types; use Types; ...@@ -28,6 +28,7 @@ with Types; use Types;
package Sem_Ch3 is package Sem_Ch3 is
procedure Analyze_Component_Declaration (N : Node_Id); procedure Analyze_Component_Declaration (N : Node_Id);
procedure Analyze_Full_Type_Declaration (N : Node_Id);
procedure Analyze_Incomplete_Type_Decl (N : Node_Id); procedure Analyze_Incomplete_Type_Decl (N : Node_Id);
procedure Analyze_Itype_Reference (N : Node_Id); procedure Analyze_Itype_Reference (N : Node_Id);
procedure Analyze_Number_Declaration (N : Node_Id); procedure Analyze_Number_Declaration (N : Node_Id);
...@@ -35,7 +36,6 @@ package Sem_Ch3 is ...@@ -35,7 +36,6 @@ package Sem_Ch3 is
procedure Analyze_Others_Choice (N : Node_Id); procedure Analyze_Others_Choice (N : Node_Id);
procedure Analyze_Private_Extension_Declaration (N : Node_Id); procedure Analyze_Private_Extension_Declaration (N : Node_Id);
procedure Analyze_Subtype_Indication (N : Node_Id); procedure Analyze_Subtype_Indication (N : Node_Id);
procedure Analyze_Type_Declaration (N : Node_Id);
procedure Analyze_Variant_Part (N : Node_Id); procedure Analyze_Variant_Part (N : Node_Id);
procedure Analyze_Subtype_Declaration procedure Analyze_Subtype_Declaration
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Checks; use Checks; with Checks; use Checks;
with Debug; use Debug; with Debug; use Debug;
...@@ -59,6 +60,7 @@ with Sem_Ch5; use Sem_Ch5; ...@@ -59,6 +60,7 @@ with Sem_Ch5; use Sem_Ch5;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch8; use Sem_Ch8;
with Sem_Ch10; use Sem_Ch10; with Sem_Ch10; use Sem_Ch10;
with Sem_Ch12; use Sem_Ch12; with Sem_Ch12; use Sem_Ch12;
with Sem_Ch13; use Sem_Ch13;
with Sem_Disp; use Sem_Disp; with Sem_Disp; use Sem_Disp;
with Sem_Dist; use Sem_Dist; with Sem_Dist; use Sem_Dist;
with Sem_Elim; use Sem_Elim; with Sem_Elim; use Sem_Elim;
...@@ -352,6 +354,7 @@ package body Sem_Ch6 is ...@@ -352,6 +354,7 @@ package body Sem_Ch6 is
Designator : constant Entity_Id := Designator : constant Entity_Id :=
Analyze_Subprogram_Specification (Specification (N)); Analyze_Subprogram_Specification (Specification (N));
Scop : constant Entity_Id := Current_Scope; Scop : constant Entity_Id := Current_Scope;
AS : constant List_Id := Aspect_Specifications (N);
begin begin
Generate_Definition (Designator); Generate_Definition (Designator);
...@@ -381,6 +384,7 @@ package body Sem_Ch6 is ...@@ -381,6 +384,7 @@ package body Sem_Ch6 is
Generate_Reference_To_Formals (Designator); Generate_Reference_To_Formals (Designator);
Check_Eliminated (Designator); Check_Eliminated (Designator);
Analyze_Aspect_Specifications (N, Designator, AS);
end Analyze_Abstract_Subprogram_Declaration; end Analyze_Abstract_Subprogram_Declaration;
---------------------------------------- ----------------------------------------
...@@ -2696,9 +2700,10 @@ package body Sem_Ch6 is ...@@ -2696,9 +2700,10 @@ package body Sem_Ch6 is
procedure Analyze_Subprogram_Declaration (N : Node_Id) is procedure Analyze_Subprogram_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
AS : constant List_Id := Aspect_Specifications (N);
Scop : constant Entity_Id := Current_Scope;
Designator : Entity_Id; Designator : Entity_Id;
Form : Node_Id; Form : Node_Id;
Scop : constant Entity_Id := Current_Scope;
Null_Body : Node_Id := Empty; Null_Body : Node_Id := Empty;
-- Start of processing for Analyze_Subprogram_Declaration -- Start of processing for Analyze_Subprogram_Declaration
...@@ -2891,6 +2896,8 @@ package body Sem_Ch6 is ...@@ -2891,6 +2896,8 @@ package body Sem_Ch6 is
Write_Location (Sloc (N)); Write_Location (Sloc (N));
Write_Eol; Write_Eol;
end if; end if;
Analyze_Aspect_Specifications (N, Designator, AS);
end Analyze_Subprogram_Declaration; end Analyze_Subprogram_Declaration;
-------------------------------------- --------------------------------------
...@@ -8334,20 +8341,19 @@ package body Sem_Ch6 is ...@@ -8334,20 +8341,19 @@ package body Sem_Ch6 is
if Is_Tagged_Type (Formal_Type) then if Is_Tagged_Type (Formal_Type) then
null; null;
elsif Nkind_In (Parent (Parent (T)), elsif Nkind_In (Parent (Parent (T)), N_Accept_Statement,
N_Accept_Statement, N_Entry_Body,
N_Entry_Body, N_Subprogram_Body)
N_Subprogram_Body)
then then
Error_Msg_NE Error_Msg_NE
("invalid use of untagged incomplete type&", ("invalid use of untagged incomplete type&",
Ptype, Formal_Type); Ptype, Formal_Type);
end if; end if;
else else
Error_Msg_NE Error_Msg_NE
("invalid use of incomplete type&", ("invalid use of incomplete type&",
Param_Spec, Formal_Type); Param_Spec, Formal_Type);
-- Further checks on the legality of incomplete types -- Further checks on the legality of incomplete types
-- in formal parts are delayed until the freeze point -- in formal parts are delayed until the freeze point
...@@ -8356,8 +8362,9 @@ package body Sem_Ch6 is ...@@ -8356,8 +8362,9 @@ package body Sem_Ch6 is
end if; end if;
elsif Ekind (Formal_Type) = E_Void then elsif Ekind (Formal_Type) = E_Void then
Error_Msg_NE ("premature use of&", Error_Msg_NE
Parameter_Type (Param_Spec), Formal_Type); ("premature use of&",
Parameter_Type (Param_Spec), Formal_Type);
end if; end if;
-- Ada 2005 (AI-231): Create and decorate an internal subtype -- Ada 2005 (AI-231): Create and decorate an internal subtype
...@@ -8378,8 +8385,7 @@ package body Sem_Ch6 is ...@@ -8378,8 +8385,7 @@ package body Sem_Ch6 is
then then
Error_Msg_NE Error_Msg_NE
("`NOT NULL` not allowed (& already excludes null)", ("`NOT NULL` not allowed (& already excludes null)",
Param_Spec, Param_Spec, Formal_Type);
Formal_Type);
end if; end if;
Formal_Type := Formal_Type :=
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
-- handling of private and full declarations, and the construction of dispatch -- handling of private and full declarations, and the construction of dispatch
-- tables for tagged types. -- tables for tagged types.
with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Debug; use Debug; with Debug; use Debug;
with Einfo; use Einfo; with Einfo; use Einfo;
...@@ -51,6 +52,7 @@ with Sem_Ch6; use Sem_Ch6; ...@@ -51,6 +52,7 @@ with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch8; use Sem_Ch8;
with Sem_Ch10; use Sem_Ch10; with Sem_Ch10; use Sem_Ch10;
with Sem_Ch12; use Sem_Ch12; with Sem_Ch12; use Sem_Ch12;
with Sem_Ch13; use Sem_Ch13;
with Sem_Disp; use Sem_Disp; with Sem_Disp; use Sem_Disp;
with Sem_Eval; use Sem_Eval; with Sem_Eval; use Sem_Eval;
with Sem_Prag; use Sem_Prag; with Sem_Prag; use Sem_Prag;
...@@ -749,6 +751,7 @@ package body Sem_Ch7 is ...@@ -749,6 +751,7 @@ package body Sem_Ch7 is
procedure Analyze_Package_Declaration (N : Node_Id) is procedure Analyze_Package_Declaration (N : Node_Id) is
Id : constant Node_Id := Defining_Entity (N); Id : constant Node_Id := Defining_Entity (N);
AS : constant List_Id := Aspect_Specifications (N);
PF : Boolean; PF : Boolean;
-- True when in the context of a declared pure library unit -- True when in the context of a declared pure library unit
...@@ -768,7 +771,7 @@ package body Sem_Ch7 is ...@@ -768,7 +771,7 @@ package body Sem_Ch7 is
-- package Pkg is ... -- package Pkg is ...
if From_With_Type (Id) then if From_With_Type (Id) then
return; goto Leave;
end if; end if;
if Debug_Flag_C then if Debug_Flag_C then
...@@ -842,6 +845,8 @@ package body Sem_Ch7 is ...@@ -842,6 +845,8 @@ package body Sem_Ch7 is
Write_Location (Sloc (N)); Write_Location (Sloc (N));
Write_Eol; Write_Eol;
end if; end if;
<<Leave>> Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Package_Declaration; end Analyze_Package_Declaration;
----------------------------------- -----------------------------------
...@@ -1412,6 +1417,7 @@ package body Sem_Ch7 is ...@@ -1412,6 +1417,7 @@ package body Sem_Ch7 is
procedure Analyze_Private_Type_Declaration (N : Node_Id) is procedure Analyze_Private_Type_Declaration (N : Node_Id) is
PF : constant Boolean := Is_Pure (Enclosing_Lib_Unit_Entity); PF : constant Boolean := Is_Pure (Enclosing_Lib_Unit_Entity);
Id : constant Entity_Id := Defining_Identifier (N); Id : constant Entity_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
begin begin
Generate_Definition (Id); Generate_Definition (Id);
...@@ -1426,6 +1432,7 @@ package body Sem_Ch7 is ...@@ -1426,6 +1432,7 @@ package body Sem_Ch7 is
New_Private_Type (N, Id, N); New_Private_Type (N, Id, N);
Set_Depends_On_Private (Id); Set_Depends_On_Private (Id);
Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Private_Type_Declaration; end Analyze_Private_Type_Declaration;
---------------------------------- ----------------------------------
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree; with Atree; use Atree;
with Checks; use Checks; with Checks; use Checks;
with Einfo; use Einfo; with Einfo; use Einfo;
...@@ -44,6 +45,7 @@ with Sem_Ch3; use Sem_Ch3; ...@@ -44,6 +45,7 @@ with Sem_Ch3; use Sem_Ch3;
with Sem_Ch5; use Sem_Ch5; with Sem_Ch5; use Sem_Ch5;
with Sem_Ch6; use Sem_Ch6; with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8; with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
with Sem_Eval; use Sem_Eval; with Sem_Eval; use Sem_Eval;
with Sem_Res; use Sem_Res; with Sem_Res; use Sem_Res;
with Sem_Type; use Sem_Type; with Sem_Type; use Sem_Type;
...@@ -873,6 +875,7 @@ package body Sem_Ch9 is ...@@ -873,6 +875,7 @@ package body Sem_Ch9 is
D_Sdef : constant Node_Id := Discrete_Subtype_Definition (N); D_Sdef : constant Node_Id := Discrete_Subtype_Definition (N);
Def_Id : constant Entity_Id := Defining_Identifier (N); Def_Id : constant Entity_Id := Defining_Identifier (N);
Formals : constant List_Id := Parameter_Specifications (N); Formals : constant List_Id := Parameter_Specifications (N);
AS : constant List_Id := Aspect_Specifications (N);
begin begin
Generate_Definition (Def_Id); Generate_Definition (Def_Id);
...@@ -904,6 +907,7 @@ package body Sem_Ch9 is ...@@ -904,6 +907,7 @@ package body Sem_Ch9 is
end if; end if;
Generate_Reference_To_Formals (Def_Id); Generate_Reference_To_Formals (Def_Id);
Analyze_Aspect_Specifications (N, Def_Id, AS);
end Analyze_Entry_Declaration; end Analyze_Entry_Declaration;
--------------------------------------- ---------------------------------------
...@@ -1122,19 +1126,20 @@ package body Sem_Ch9 is ...@@ -1122,19 +1126,20 @@ package body Sem_Ch9 is
Process_End_Label (N, 'e', Current_Scope); Process_End_Label (N, 'e', Current_Scope);
end Analyze_Protected_Definition; end Analyze_Protected_Definition;
---------------------------- ----------------------------------------
-- Analyze_Protected_Type -- -- Analyze_Protected_Type_Declaration --
---------------------------- ----------------------------------------
procedure Analyze_Protected_Type (N : Node_Id) is procedure Analyze_Protected_Type_Declaration (N : Node_Id) is
Def_Id : constant Entity_Id := Defining_Identifier (N); Def_Id : constant Entity_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
E : Entity_Id; E : Entity_Id;
T : Entity_Id; T : Entity_Id;
begin begin
if No_Run_Time_Mode then if No_Run_Time_Mode then
Error_Msg_CRT ("protected type", N); Error_Msg_CRT ("protected type", N);
return; goto Leave;
end if; end if;
Tasking_Used := True; Tasking_Used := True;
...@@ -1254,7 +1259,9 @@ package body Sem_Ch9 is ...@@ -1254,7 +1259,9 @@ package body Sem_Ch9 is
Process_Full_View (N, T, Def_Id); Process_Full_View (N, T, Def_Id);
end if; end if;
end if; end if;
end Analyze_Protected_Type;
<<Leave>> Analyze_Aspect_Specifications (N, Def_Id, AS);
end Analyze_Protected_Type_Declaration;
--------------------- ---------------------
-- Analyze_Requeue -- -- Analyze_Requeue --
...@@ -1651,13 +1658,14 @@ package body Sem_Ch9 is ...@@ -1651,13 +1658,14 @@ package body Sem_Ch9 is
end if; end if;
end Analyze_Selective_Accept; end Analyze_Selective_Accept;
------------------------------ ------------------------------------------
-- Analyze_Single_Protected -- -- Analyze_Single_Protected_Declaration --
------------------------------ ------------------------------------------
procedure Analyze_Single_Protected (N : Node_Id) is procedure Analyze_Single_Protected_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
Id : constant Node_Id := Defining_Identifier (N); Id : constant Node_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
T : Entity_Id; T : Entity_Id;
T_Decl : Node_Id; T_Decl : Node_Id;
O_Decl : Node_Id; O_Decl : Node_Id;
...@@ -1704,16 +1712,18 @@ package body Sem_Ch9 is ...@@ -1704,16 +1712,18 @@ package body Sem_Ch9 is
-- procedure directly. Otherwise the node would be expanded twice, with -- procedure directly. Otherwise the node would be expanded twice, with
-- disastrous result. -- disastrous result.
Analyze_Protected_Type (N); Analyze_Protected_Type_Declaration (N);
end Analyze_Single_Protected; Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Single_Protected_Declaration;
------------------------- -------------------------------------
-- Analyze_Single_Task -- -- Analyze_Single_Task_Declaration --
------------------------- -------------------------------------
procedure Analyze_Single_Task (N : Node_Id) is procedure Analyze_Single_Task_Declaration (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N); Loc : constant Source_Ptr := Sloc (N);
Id : constant Node_Id := Defining_Identifier (N); Id : constant Node_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
T : Entity_Id; T : Entity_Id;
T_Decl : Node_Id; T_Decl : Node_Id;
O_Decl : Node_Id; O_Decl : Node_Id;
...@@ -1768,8 +1778,9 @@ package body Sem_Ch9 is ...@@ -1768,8 +1778,9 @@ package body Sem_Ch9 is
-- procedure directly. Otherwise the node would be expanded twice, with -- procedure directly. Otherwise the node would be expanded twice, with
-- disastrous result. -- disastrous result.
Analyze_Task_Type (N); Analyze_Task_Type_Declaration (N);
end Analyze_Single_Task; Analyze_Aspect_Specifications (N, Id, AS);
end Analyze_Single_Task_Declaration;
----------------------- -----------------------
-- Analyze_Task_Body -- -- Analyze_Task_Body --
...@@ -1935,12 +1946,13 @@ package body Sem_Ch9 is ...@@ -1935,12 +1946,13 @@ package body Sem_Ch9 is
Process_End_Label (N, 'e', Current_Scope); Process_End_Label (N, 'e', Current_Scope);
end Analyze_Task_Definition; end Analyze_Task_Definition;
----------------------- -----------------------------------
-- Analyze_Task_Type -- -- Analyze_Task_Type_Declaration --
----------------------- -----------------------------------
procedure Analyze_Task_Type (N : Node_Id) is procedure Analyze_Task_Type_Declaration (N : Node_Id) is
Def_Id : constant Entity_Id := Defining_Identifier (N); Def_Id : constant Entity_Id := Defining_Identifier (N);
AS : constant List_Id := Aspect_Specifications (N);
T : Entity_Id; T : Entity_Id;
begin begin
...@@ -2038,7 +2050,9 @@ package body Sem_Ch9 is ...@@ -2038,7 +2050,9 @@ package body Sem_Ch9 is
Process_Full_View (N, T, Def_Id); Process_Full_View (N, T, Def_Id);
end if; end if;
end if; end if;
end Analyze_Task_Type;
Analyze_Aspect_Specifications (N, Def_Id, AS);
end Analyze_Task_Type_Declaration;
----------------------------------- -----------------------------------
-- Analyze_Terminate_Alternative -- -- Analyze_Terminate_Alternative --
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1992-2007, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2010, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -41,14 +41,14 @@ package Sem_Ch9 is ...@@ -41,14 +41,14 @@ package Sem_Ch9 is
procedure Analyze_Entry_Index_Specification (N : Node_Id); procedure Analyze_Entry_Index_Specification (N : Node_Id);
procedure Analyze_Protected_Body (N : Node_Id); procedure Analyze_Protected_Body (N : Node_Id);
procedure Analyze_Protected_Definition (N : Node_Id); procedure Analyze_Protected_Definition (N : Node_Id);
procedure Analyze_Protected_Type (N : Node_Id); procedure Analyze_Protected_Type_Declaration (N : Node_Id);
procedure Analyze_Requeue (N : Node_Id); procedure Analyze_Requeue (N : Node_Id);
procedure Analyze_Selective_Accept (N : Node_Id); procedure Analyze_Selective_Accept (N : Node_Id);
procedure Analyze_Single_Protected (N : Node_Id); procedure Analyze_Single_Protected_Declaration (N : Node_Id);
procedure Analyze_Single_Task (N : Node_Id); procedure Analyze_Single_Task_Declaration (N : Node_Id);
procedure Analyze_Task_Body (N : Node_Id); procedure Analyze_Task_Body (N : Node_Id);
procedure Analyze_Task_Definition (N : Node_Id); procedure Analyze_Task_Definition (N : Node_Id);
procedure Analyze_Task_Type (N : Node_Id); procedure Analyze_Task_Type_Declaration (N : Node_Id);
procedure Analyze_Terminate_Alternative (N : Node_Id); procedure Analyze_Terminate_Alternative (N : Node_Id);
procedure Analyze_Timed_Entry_Call (N : Node_Id); procedure Analyze_Timed_Entry_Call (N : Node_Id);
procedure Analyze_Triggering_Alternative (N : Node_Id); procedure Analyze_Triggering_Alternative (N : Node_Id);
......
...@@ -3674,18 +3674,28 @@ package body Sem_Res is ...@@ -3674,18 +3674,28 @@ package body Sem_Res is
Apply_Range_Check (A, F_Typ); Apply_Range_Check (A, F_Typ);
end if; end if;
-- Ada 2005 (AI-231) -- Ada 2005 (AI-231): Note that the controlling parameter case
-- already existed in Ada 95, which is partially checked
-- elsewhere (see Checks), and we don't want the warning
-- message to differ.
if Ada_Version >= Ada_2005 if Is_Access_Type (F_Typ)
and then Is_Access_Type (F_Typ)
and then Can_Never_Be_Null (F_Typ) and then Can_Never_Be_Null (F_Typ)
and then Known_Null (A) and then Known_Null (A)
then then
Apply_Compile_Time_Constraint_Error if Is_Controlling_Formal (F) then
(N => A, Apply_Compile_Time_Constraint_Error
Msg => "(Ada 2005) null not allowed in " (N => A,
& "null-excluding formal?", Msg => "null value not allowed here?",
Reason => CE_Null_Not_Allowed); Reason => CE_Access_Check_Failed);
elsif Ada_Version >= Ada_2005 then
Apply_Compile_Time_Constraint_Error
(N => A,
Msg => "(Ada 2005) null not allowed in "
& "null-excluding formal?",
Reason => CE_Null_Not_Allowed);
end if;
end if; end if;
end if; end if;
......
...@@ -32,10 +32,8 @@ ...@@ -32,10 +32,8 @@
pragma Style_Checks (All_Checks); pragma Style_Checks (All_Checks);
-- No subprogram ordering check, due to logical grouping -- No subprogram ordering check, due to logical grouping
with Atree; use Atree; with Aspects; use Aspects;
with Nlists; use Nlists; with Atree; use Atree;
with GNAT.HTable;
package body Sinfo is package body Sinfo is
...@@ -56,30 +54,6 @@ package body Sinfo is ...@@ -56,30 +54,6 @@ package body Sinfo is
NT : Nodes.Table_Ptr renames Nodes.Table; NT : Nodes.Table_Ptr renames Nodes.Table;
-- A short hand abbreviation, useful for the debugging checks -- A short hand abbreviation, useful for the debugging checks
------------------------------------------
-- Hash Table for Aspect Specifications --
------------------------------------------
type Hash_Range is range 0 .. 510;
-- Size of hash table headers
function AS_Hash (F : Node_Id) return Hash_Range;
-- Hash function for hash table
function AS_Hash (F : Node_Id) return Hash_Range is
begin
return Hash_Range (F mod 511);
end AS_Hash;
package Aspect_Specifications_Hash_Table is new
GNAT.HTable.Simple_HTable
(Header_Num => Hash_Range,
Element => List_Id,
No_Element => No_List,
Key => Node_Id,
Hash => AS_Hash,
Equal => "=");
---------------------------- ----------------------------
-- Field Access Functions -- -- Field Access Functions --
---------------------------- ----------------------------
...@@ -282,6 +256,14 @@ package body Sinfo is ...@@ -282,6 +256,14 @@ package body Sinfo is
return Node3 (N); return Node3 (N);
end Array_Aggregate; end Array_Aggregate;
function Aspect_Cancel
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
return Flag11 (N);
end Aspect_Cancel;
function Assignment_OK function Assignment_OK
(N : Node_Id) return Boolean is (N : Node_Id) return Boolean is
begin begin
...@@ -1251,14 +1233,6 @@ package body Sinfo is ...@@ -1251,14 +1233,6 @@ package body Sinfo is
return List1 (N); return List1 (N);
end Expressions; end Expressions;
function First_Aspect
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
return Flag4 (N);
end First_Aspect;
function First_Bit function First_Bit
(N : Node_Id) return Node_Id is (N : Node_Id) return Node_Id is
begin begin
...@@ -1333,6 +1307,15 @@ package body Sinfo is ...@@ -1333,6 +1307,15 @@ package body Sinfo is
return Flag5 (N); return Flag5 (N);
end Forwards_OK; end Forwards_OK;
function From_Aspect_Specification
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Pragma);
return Flag13 (N);
end From_Aspect_Specification;
function From_At_End function From_At_End
(N : Node_Id) return Boolean is (N : Node_Id) return Boolean is
begin begin
...@@ -1869,14 +1852,6 @@ package body Sinfo is ...@@ -1869,14 +1852,6 @@ package body Sinfo is
return Node2 (N); return Node2 (N);
end Label_Construct; end Label_Construct;
function Last_Aspect
(N : Node_Id) return Boolean is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
return Flag5 (N);
end Last_Aspect;
function Last_Bit function Last_Bit
(N : Node_Id) return Node_Id is (N : Node_Id) return Node_Id is
begin begin
...@@ -3229,6 +3204,14 @@ package body Sinfo is ...@@ -3229,6 +3204,14 @@ package body Sinfo is
Set_Node3_With_Parent (N, Val); Set_Node3_With_Parent (N, Val);
end Set_Array_Aggregate; end Set_Array_Aggregate;
procedure Set_Aspect_Cancel
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Pragma);
Set_Flag11 (N, Val);
end Set_Aspect_Cancel;
procedure Set_Assignment_OK procedure Set_Assignment_OK
(N : Node_Id; Val : Boolean := True) is (N : Node_Id; Val : Boolean := True) is
begin begin
...@@ -4189,14 +4172,6 @@ package body Sinfo is ...@@ -4189,14 +4172,6 @@ package body Sinfo is
Set_List1_With_Parent (N, Val); Set_List1_With_Parent (N, Val);
end Set_Expressions; end Set_Expressions;
procedure Set_First_Aspect
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
Set_Flag4 (N, Val);
end Set_First_Aspect;
procedure Set_First_Bit procedure Set_First_Bit
(N : Node_Id; Val : Node_Id) is (N : Node_Id; Val : Node_Id) is
begin begin
...@@ -4271,6 +4246,15 @@ package body Sinfo is ...@@ -4271,6 +4246,15 @@ package body Sinfo is
Set_Flag5 (N, Val); Set_Flag5 (N, Val);
end Set_Forwards_OK; end Set_Forwards_OK;
procedure Set_From_Aspect_Specification
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Attribute_Definition_Clause
or else NT (N).Nkind = N_Pragma);
Set_Flag13 (N, Val);
end Set_From_Aspect_Specification;
procedure Set_From_At_End procedure Set_From_At_End
(N : Node_Id; Val : Boolean := True) is (N : Node_Id; Val : Boolean := True) is
begin begin
...@@ -4816,14 +4800,6 @@ package body Sinfo is ...@@ -4816,14 +4800,6 @@ package body Sinfo is
Set_Node4_With_Parent (N, Val); Set_Node4_With_Parent (N, Val);
end Set_Last_Bit; end Set_Last_Bit;
procedure Set_Last_Aspect
(N : Node_Id; Val : Boolean := True) is
begin
pragma Assert (False
or else NT (N).Nkind = N_Aspect_Specification);
Set_Flag5 (N, Val);
end Set_Last_Aspect;
procedure Set_Last_Name procedure Set_Last_Name
(N : Node_Id; Val : Boolean := True) is (N : Node_Id; Val : Boolean := True) is
begin begin
...@@ -6163,65 +6139,4 @@ package body Sinfo is ...@@ -6163,65 +6139,4 @@ package body Sinfo is
return Chars (Pragma_Identifier (N)); return Chars (Pragma_Identifier (N));
end Pragma_Name; end Pragma_Name;
-----------------------------------
-- Permits_Aspect_Specifications --
-----------------------------------
Has_Aspect_Specifications_Flag : constant array (Node_Kind) of Boolean :=
(N_Abstract_Subprogram_Declaration => True,
N_Component_Declaration => True,
N_Entry_Declaration => True,
N_Exception_Declaration => True,
N_Formal_Abstract_Subprogram_Declaration => True,
N_Formal_Concrete_Subprogram_Declaration => True,
N_Formal_Object_Declaration => True,
N_Formal_Package_Declaration => True,
N_Formal_Type_Declaration => True,
N_Full_Type_Declaration => True,
N_Function_Instantiation => True,
N_Generic_Package_Declaration => True,
N_Generic_Subprogram_Declaration => True,
N_Object_Declaration => True,
N_Package_Declaration => True,
N_Package_Instantiation => True,
N_Private_Extension_Declaration => True,
N_Private_Type_Declaration => True,
N_Procedure_Instantiation => True,
N_Protected_Type_Declaration => True,
N_Single_Protected_Declaration => True,
N_Single_Task_Declaration => True,
N_Subprogram_Declaration => True,
N_Subtype_Declaration => True,
N_Task_Type_Declaration => True,
others => False);
function Permits_Aspect_Specifications (N : Node_Id) return Boolean is
begin
return Has_Aspect_Specifications_Flag (Nkind (N));
end Permits_Aspect_Specifications;
---------------------------
-- Aspect_Specifications --
---------------------------
function Aspect_Specifications (N : Node_Id) return List_Id is
begin
return Aspect_Specifications_Hash_Table.Get (N);
end Aspect_Specifications;
-------------------------------
-- Set_Aspect_Specifications --
-------------------------------
procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id) is
begin
pragma Assert (Permits_Aspect_Specifications (N));
pragma Assert (not Has_Aspect_Specifications (N));
pragma Assert (L /= No_List);
Set_Has_Aspect_Specifications (N);
Set_Parent (L, N);
Aspect_Specifications_Hash_Table.Set (N, L);
end Set_Aspect_Specifications;
end Sinfo; end Sinfo;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment