This patch adds aspects for library unit pragmas, e.g. in packages, and implements the new syntax (aspects before IS keyword), as shown in these tests:
1. pragma Ada_2012; 2. package aspectpu with Pure is 3. X : Integer; | >>> declaration of variable not allowed in pure unit 4. end; 1. pragma Ada_2012; 2. package AspectPuerr is 3. package X with Pure is | >>> incorrect context for library unit aspect "Pure" 4. end X; 5. end AspectPuerr; 1. pragma Ada_2012; 2. procedure Aspectsubp with 3. Pure => True; (the last test needs -gnatc) Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Robert Dewar <de...@adacore.com> * aspects.ads, aspects.adb: Add aspects for library unit pragmas (Pre_Post_Aspects): New subtype. * par-ch12.adb (P_Generic): New syntax for aspects in packages * par-ch13.adb (P_Aspect_Specifications): Add Semicolon parameter * par-ch7.adb (P_Package): Remove Decl parameter (P_Package): Handle new syntax for aspects (before IS) * par-ch9.adb (P_Protected_Definition): Remove Decl parameter, handle new aspect syntax (P_Task_Definition): Remove Decl parameter, handle new aspect syntax * par.adb (P_Aspect_Specifications): Add Semicolon parameter (P_Package): Remove Decl parameter * sem_ch13.adb (Analyze_Aspect_Specifications): Handle library unit aspects * sem_ch7.adb (Analyze_Package_Declaration): Analyze new format aspect specs * sem_util.ads, sem_util.adb (Static_Boolean): New function * sinfo.ads: Document new syntax for aspects in packages etc. * sprint.adb: Handle new syntax of aspects before IS in package
Index: sinfo.ads =================================================================== --- sinfo.ads (revision 169935) +++ sinfo.ads (working copy) @@ -1158,7 +1158,7 @@ -- Has_Pragma_Suppress_All (Flag14-Sem) -- This flag is set in an N_Compilation_Unit node if the Suppress_All - -- pragma appears anywhere in the unit. This accomodates the rather + -- pragma appears anywhere in the unit. This accommodates the rather -- strange placement rules of other compilers (DEC permits it at the -- end of a unit, and Rational allows it as a program unit pragma). We -- allow it anywhere at all, and consider it equivalent to a pragma @@ -1468,7 +1468,7 @@ -- Next_Exit_Statement (Node3-Sem) -- Present in N_Exit_Statement nodes. The exit statements for a loop are - -- chained (in reverse order of appearence) from the First_Exit_Statement + -- chained (in reverse order of appearance) from the First_Exit_Statement -- field of the E_Loop entity for the loop. Next_Exit_Statement points to -- the next entry on this chain (Empty = end of list). @@ -1479,7 +1479,7 @@ -- A postorder traversal of the tree whose nodes are units and whose -- links are with_clauses defines the order in which Inspector must -- examine a compiled unit and its full context. This ordering ensures - -- that any subprogram call is examined after the subprogram declartion + -- that any subprogram call is examined after the subprogram declaration -- has been seen. -- Next_Named_Actual (Node4-Sem) @@ -1747,9 +1747,9 @@ -- secondary stack. -- Suppress_Assignment_Checks (Flag18-Sem) - -- Used in genererated N_Assignment_Statement nodes to suppress predicate + -- Used in generated N_Assignment_Statement nodes to suppress predicate -- and range checks in cases where the generated code knows that the - -- value being assigned is in range and satisifies any predicate. Also + -- value being assigned is in range and satisfies any predicate. Also -- can be set in N_Object_Declaration nodes, to similarly suppress any -- checks on the initializing value. @@ -4078,7 +4078,7 @@ -- Suppress_Assignment_Checks (Flag18-Sem) -- Note: if a range check is required, then the Do_Range_Check flag - -- is set in the Expression (right hand side), with the check b6ing + -- is set in the Expression (right hand side), with the check being -- done against the type of the Name (left hand side). -- Note: the back end places some restrictions on the form of the @@ -4203,7 +4203,7 @@ -- explicit loop identifier. Otherwise the parser leaves this field -- set to Empty, and then the semantic processing for a loop statement -- creates an identifier, setting the Has_Created_Identifier flag to - -- True. So after semantic anlaysis, the Identifier is always set, + -- True. So after semantic analysis, the Identifier is always set, -- referencing an identifier whose entity has an Ekind of E_Loop. -------------------------- @@ -6837,7 +6837,7 @@ -- CASE_EXPRESSION_ALTERNATIVE -- {CASE_EXPRESSION_ALTERNATIVE} - -- Note that the Alternatives cannot include pragmas (this constrasts + -- Note that the Alternatives cannot include pragmas (this contrasts -- with the situation of case statements where pragmas are allowed). -- N_Case_Expression @@ -6861,7 +6861,7 @@ -- Note: The Actions field temporarily holds any actions associated with -- evaluation of the Expression. During expansion of the case expression - -- these actions are wrapped into the an N_Expressions_With_Actions node + -- these actions are wrapped into an N_Expressions_With_Actions node -- replacing the original expression. ---------------------------- @@ -6890,7 +6890,7 @@ -- And we add the additional constructs - -- PRIMARY ::= ( CONDITIONAL_EXPRESION ) + -- PRIMARY ::= ( CONDITIONAL_EXPRESSION ) -- PRAGMA_ARGUMENT_ASSOCIATION ::= CONDITIONAL_EXPRESSION -- Note: if we have (IF x1 THEN x2 ELSIF x3 THEN x4 ELSE x5) then it Index: sem_ch7.adb =================================================================== --- sem_ch7.adb (revision 169935) +++ sem_ch7.adb (working copy) @@ -1936,7 +1936,7 @@ procedure New_Private_Type (N : Node_Id; Id : Entity_Id; Def : Node_Id) is begin - -- For other than Ada 2012, enter tha name in the current scope + -- For other than Ada 2012, enter the name in the current scope if Ada_Version < Ada_2012 then Enter_Name (Id); Index: par-ch13.adb =================================================================== --- par-ch13.adb (revision 169935) +++ par-ch13.adb (working copy) @@ -367,9 +367,9 @@ -- Parsed by P_Representation_Clause (13.1) - ------------------------------ - -- 13.1 Aspect Specifation -- - ------------------------------ + -------------------------------- + -- 13.1 Aspect Specification -- + -------------------------------- -- ASPECT_SPECIFICATION ::= -- with ASPECT_MARK [=> ASPECT_DEFINITION] {. @@ -482,7 +482,7 @@ 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 apostrophe Scan; -- past presumed CLASS OK := False; Index: sem_util.adb =================================================================== --- sem_util.adb (revision 169935) +++ sem_util.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2010, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- -- -- -- 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- -- @@ -73,7 +73,7 @@ -- safely used by New_Copy_Tree, since there is no case of a recursive -- call from the processing inside New_Copy_Tree. - NCT_Hash_Threshhold : constant := 20; + NCT_Hash_Threshold : constant := 20; -- If there are more than this number of pairs of entries in the -- map, then Hash_Tables_Used will be set, and the hash tables will -- be initialized and used for the searches. @@ -82,7 +82,7 @@ -- Set to True if hash tables are in use NCT_Table_Entries : Nat; - -- Count entries in table to see if threshhold is reached + -- Count entries in table to see if threshold is reached NCT_Hash_Table_Setup : Boolean := False; -- Set to True if hash table contains data. We set this True if we @@ -8245,7 +8245,7 @@ -- Itype references within the copied tree. -- The following hash tables are used if the Map supplied has more - -- than hash threshhold entries to speed up access to the map. If + -- than hash threshold entries to speed up access to the map. If -- there are fewer entries, then the map is searched sequentially -- (because setting up a hash table for only a few entries takes -- more time than it saves. @@ -8981,7 +8981,7 @@ else NCT_Table_Entries := NCT_Table_Entries + 1; - if NCT_Table_Entries > NCT_Hash_Threshhold then + if NCT_Table_Entries > NCT_Hash_Threshold then Build_NCT_Hash_Tables; end if; end if; @@ -9115,7 +9115,7 @@ Next_Elmt (Elmt); end loop; - if NCT_Table_Entries > NCT_Hash_Threshhold then + if NCT_Table_Entries > NCT_Hash_Threshold then Build_NCT_Hash_Tables; else NCT_Hash_Tables_Used := False; @@ -9974,7 +9974,7 @@ then return Original_Corresponding_Operation (Alias (S)); - -- If S overrides an inherted subprogram S2 the original corresponding + -- If S overrides an inherited subprogram S2 the original corresponding -- operation of S is the original corresponding operation of S2 elsif Present (Overridden_Operation (S)) then @@ -10470,11 +10470,11 @@ if Requires_Transient_Scope (Component_Type (Typ)) then return True; - -- Otherwise, we only need a transient scope if the size is not - -- known at compile time. + -- Otherwise, we only need a transient scope if the size depends on + -- the value of one or more discriminants. else - return not Size_Known_At_Compile_Time (Typ); + return Size_Depends_On_Discriminant (Typ); end if; -- All other cases do not require a transient scope Index: sem_util.ads =================================================================== --- sem_util.ads (revision 169935) +++ sem_util.ads (working copy) @@ -778,13 +778,13 @@ -- initialized (in particular in the record case, that at least one -- component has an initialization expression). Note that initialization -- resulting from the use of pragma Normalized_Scalars does not count. - -- Include_Implicit controls whether implicit initialiation of access + -- Include_Implicit controls whether implicit initialization of access -- values to null, and of discriminant values, is counted as making the -- type be partially initialized. For the default setting of True, these -- implicit cases do count, and discriminated types or types containing -- access values not explicitly initialized will return True. Otherwise -- if Include_Implicit is False, these cases do not count as making the - -- type be partially initialied. + -- type be partially initialized. function Is_Potentially_Persistent_Type (T : Entity_Id) return Boolean; -- Determines if type T is a potentially persistent type. A potentially Index: par.adb =================================================================== --- par.adb (revision 169935) +++ par.adb (working copy) @@ -354,7 +354,7 @@ Pbod : Boolean; -- True if proper body OK Rnam : Boolean; -- True if renaming declaration OK Stub : Boolean; -- True if body stub OK - Pexp : Boolean; -- True if parametried expression OK + Pexp : Boolean; -- True if parametrized expression OK Fil2 : Boolean; -- Filler to fill to 8 bits end record; pragma Pack (Pf_Rec); @@ -633,7 +633,7 @@ function P_Range_Or_Subtype_Mark (Allow_Simple_Expression : Boolean := False) return Node_Id; -- Scans out a range or subtype mark, and also permits a general simple - -- expression if Allow_Simple_Expresion is set to True. + -- expression if Allow_Simple_Expression is set to True. function Init_Expr_Opt (P : Boolean := False) return Node_Id; -- If an initialization expression is present (:= expression), then @@ -855,9 +855,9 @@ -- of generating appropriate messages if aspect specifications appear -- in versions of Ada prior to Ada 2012. The parameter strict can be -- set to True, to be rather strict about considering something to be - -- an aspect speficiation. If Strict is False, then the circuitry is + -- an aspect specification. If Strict is False, then the circuitry is -- rather more generous in considering something ill-formed to be an - -- attempt at an aspect speciciation. The default is more strict for + -- attempt at an aspect specification. The default is more strict for -- Ada versions before Ada 2012 (where aspect specifications are not -- permitted). Note: this routine never checks the terminator token -- for aspects so it does not matter whether the aspect speficiations Index: aspects.ads =================================================================== --- aspects.ads (revision 169935) +++ aspects.ads (working copy) @@ -31,7 +31,7 @@ -- This package defines the aspects that are recognized by GNAT in aspect -- specifications. It also contains the subprograms for storing/retrieving --- aspect speciciations from the tree. The semantic processing for aspect +-- aspect specifications from the tree. The semantic processing for aspect -- specifications is found in Sem_Ch13.Analyze_Aspect_Specifications. with Namet; use Namet; @@ -296,7 +296,7 @@ -- True (i.e. the declaration nodes defined in the RM as permitting the -- presence of Aspect_Specifications). However, it is possible for the -- flag Has_Aspects to be set on other nodes as a result of Rewrite and - -- Replace calls, and this function may be used to retrive the aspect + -- Replace calls, and this function may be used to retrieve the aspect -- specifications for the original rewritten node in such cases. procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id); @@ -324,6 +324,6 @@ -- Writes contents of Aspect_Specifications hash table to the tree file procedure Tree_Read; - -- Reads contents of Aspect_Specificatins hash table from the tree file + -- Reads contents of Aspect_Specifications hash table from the tree file end Aspects; Index: par-ch12.adb =================================================================== --- par-ch12.adb (revision 169935) +++ par-ch12.adb (working copy) @@ -278,7 +278,7 @@ begin -- Figure out if a generic actual part operation is present. Clearly -- there is no generic actual part if the current token is semicolon - -- or if we have apsect specifications present. + -- or if we have aspect specifications present. if Token = Tok_Semicolon or else Aspect_Specifications_Present then return No_List; Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 169935) +++ sem_ch13.adb (working copy) @@ -81,12 +81,12 @@ procedure Build_Predicate_Function (Typ : Entity_Id; N : Node_Id); -- If Typ has predicates (indicated by Has_Predicates being set for Typ, -- then either there are pragma Invariant entries on the rep chain for the - -- type (note that Predicate aspects are converted to pragam Predicate), or + -- type (note that Predicate aspects are converted to pragma Predicate), or -- there are inherited aspects from a parent type, or ancestor subtypes. -- This procedure builds the spec and body for the Predicate function that -- tests these predicates. N is the freeze node for the type. The spec of -- the function is inserted before the freeze node, and the body of the - -- funtion is inserted after the freeze node. + -- function is inserted after the freeze node. procedure Build_Static_Predicate (Typ : Entity_Id; @@ -96,7 +96,7 @@ -- whose predicate expression is Expr, tests if Expr is a static predicate, -- and if so, builds the predicate range list. Nam is the name of the one -- argument to the predicate function. Occurrences of the type name in the - -- predicate expression have been replaced by identifer references to this + -- predicate expression have been replaced by identifier references to this -- name, which is unique, so any identifier with Chars matching Nam must be -- a reference to the type. If the predicate is non-static, this procedure -- returns doing nothing. If the predicate is static, then the predicate @@ -211,7 +211,7 @@ -- The entity of the object being overlaid Off : Boolean; - -- Whether the address is offseted within Y + -- Whether the address is offset within Y end record; package Address_Clause_Checks is new Table.Table ( @@ -1055,8 +1055,8 @@ end; -- Invariant aspects generate a corresponding pragma with a - -- first argument that is the entity, and the second argument - -- is the expression and the third argument is an appropriate + -- first argument that is the entity, a second argument that is + -- the expression and a third argument that is an appropriate -- message. This is inserted right after the declaration, to -- get the required pragma placement. The pragma processing -- takes care of the required delay. @@ -4030,7 +4030,7 @@ procedure Replace_Type_References is new Replace_Type_References_Generic (Replace_Type_Reference); -- Traverse an expression changing every occurrence of an identifier - -- whose name mathches the name of the subtype with a reference to + -- whose name matches the name of the subtype with a reference to -- the formal parameter of the predicate function. ---------------------------- @@ -4315,7 +4315,7 @@ function Is_False (R : RList) return Boolean; pragma Inline (Is_False); -- Returns True if the given range list is empty, and thus represents - -- a False list of ranges that can never be satsified. + -- a False list of ranges that can never be satisfied. function Is_True (R : RList) return Boolean; -- Returns True if R trivially represents the True predicate by having