diff options
author | Bob Duff <duff@adacore.com> | 2006-10-31 18:58:48 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2006-10-31 18:58:48 +0100 |
commit | 88b32fc3a7728aac518bb52c53cb7596c49b720c (patch) | |
tree | b27b24d9bf1dfcca04c420002e7632e08960845e /gcc/ada/g-awk.adb | |
parent | bae7876b4d3c0e1c5532b00f744a86d1f31d403e (diff) | |
download | gcc-88b32fc3a7728aac518bb52c53cb7596c49b720c.zip gcc-88b32fc3a7728aac518bb52c53cb7596c49b720c.tar.gz gcc-88b32fc3a7728aac518bb52c53cb7596c49b720c.tar.bz2 |
g-awk.adb (Default_Session, [...]): Compile this file in Ada 95 mode, because it violates the new rules for AI-318.
2006-10-31 Bob Duff <duff@adacore.com>
Robert Dewar <dewar@adacore.com>
Ed Schonberg <schonberg@adacore.com>
* g-awk.adb (Default_Session, Current_Session): Compile this file in
Ada 95 mode, because it violates the new rules for AI-318.
* g-awk.ads: Use overloaded subprograms in every case where we used to
have a default of Current_Session. This makes the code closer to be
correct for both Ada 95 and 2005.
* g-moreex.adb (Occurrence): Turn off warnings for illegal-in-Ada-2005
code, relying on the fact that the compiler generates a warning
instead of an error in -gnatg mode.
* lib-xref.ads (Xref_Entity_Letters): Add entry for new
E_Return_Statement entity kind.
Add an entry for E_Incomplete_Subtype in Xref_Entity_Letters.
* par.adb (P_Interface_Type_Definition): Addition of one formal to
report an error if the reserved word abstract has been previously found.
(SS_End_Type): Add E_Return for new extended_return_statement syntax.
* par-ch4.adb (P_Aggregate_Or_Paren_Expr): Improve message for
parenthesized range attribute usage
(P_Expression_No_Right_Paren): Add missing comment about error recovery.
* par-ch6.adb (P_Return_Object_Declaration): AI-318: Allow "constant"
in the syntax for extended_return_statement. This is not in the latest
RM, but the ARG is expected to issue an AI allowing this.
(P_Return_Subtype_Indication,P_Return_Subtype_Indication): Remove
N_Return_Object_Declaration. We now use N_Object_Declaration instead.
(P_Return_Object_Declaration, P_Return_Subtype_Indication,
P_Return_Statement): Parse the new syntax for extended_return_statement.
* par-endh.adb (Check_End, Output_End_Deleted, Output_End_Expected,
Output_End_Missing): Add error-recovery code for the new
extended_return_statement syntax; that is, the new E_Return entry on
the scope stack.
* s-auxdec-vms_64.ads, s-auxdec.ads (AST_Handler): Change type from
limited to nonlimited, because otherwise we violate the new Ada 2005
rules about returning limited types in function Create_AST_Handler in
s-asthan.adb.
* sem.adb (Analyze): Add cases for new node kinds
N_Extended_Return_Statement and N_Return_Object_Declaration.
* sem_aggr.adb (Aggregate_Constraint_Checks): Verify that component
type is in the same category as type of context before applying check,
to prevent anomalies in instantiations.
(Resolve_Aggregate): Remove test for limited components in aggregates.
It's unnecessary in Ada 95, because if it has limited components, then
it must be limited. It's wrong in Ada 2005, because limited aggregates
are now allowed.
(Resolve_Record_Aggregate): Move check for limited types later, because
OK_For_Limited_Init requires its argument to have been resolved.
(Get_Value): When copying the component default expression for a
defaulted association in an aggregate, use the sloc of the aggregate
and not that of the original expression, to prevent spurious
elaboration errors, when the expression includes function calls.
(Check_Non_Limited_Type): Correct code for AI-287, extension aggregates
were missing. We also didn't handle qualified expressions. Now also
allow function calls. Use new common routine OK_For_Limited_Init.
(Resolve_Extension_Aggregate): Minor fix to bad error message (started
with space can upper case letter).
* sem_ch3.ads, sem_ch3.adb (Create_Constrained_Components): Set
Has_Static_Discriminants flag
(Record_Type_Declaration): Diagnose an attempt to declare an interface
type with discriminants.
(Process_Range_Expr_In_Decl): Do validity checks on range
(Build_Discriminant_Constraints): Use updated form of
Denotes_Discriminant.
(Process_Subtype): If the subtype is a private subtype whose full view
is a concurrent subtype, introduce an itype reference to prevent scope
anomalies in gigi.
(Build_Derived_Record_Type, Collect_Interface_Primitives,
Record_Type_Declaration): The functionality of the subprograms
Collect_Abstract_Interfaces and Collect_All_Abstract_Interfaces
is now performed by a single routine.
(Build_Derived_Record_Type): If the type definition includes an explicit
indication of limitedness, then the type must be marked as limited here
to ensure that any access discriminants will not be treated as having
a local anonymous access type.
(Check_Abstract_Overriding): Issue a detailed error message when an
abstract subprogram was not overridden due to incorrect mode of its
first parameter.
(Analyze_Private_Extension_Declaration): Add support for the analysis of
synchronized private extension declarations. Verify that the ancestor is
a limited or synchronized interface or in the generic case, the ancestor
is a tagged limited type or synchronized interface and all progenitors
are either limited or synchronized interfaces.
Derived_Type_Declaration): Check for presence of private extension when
dealing with synchronized formal derived types.
Process_Full_View): Enchance the check done on the usage of "limited" by
testing whether the private view is synchronized.
Verify that a synchronized private view is completed by a protected or
task type.
(OK_For_Limited_Init_In_05): New function.
(Analyze_Object_Declaration): Move check for limited types later,
because OK_For_Limited_Init requires its argument to have been resolved.
Add -gnatd.l --Use Ada 95 semantics for limited function returns,
in order to alleviate the upward compatibility introduced by AI-318.
(Constrain_Corresponding_Record): If the constraint is for a component
subtype, mark the itype as frozen, to avoid out-of-scope references to
discriminants in the back-end.
(Collect_Implemented_Interfaces): Protect the recursive algorithm of
this subprogram against wrong sources.
(Get_Discr_Value, Is_Discriminant): Handle properly references to a
discriminant of limited type completed with a protected type, when the
discriminant is used to constrain a private component of the type, and
expansion is disabled.
(Find_Type_Of_Object): Do not treat a return subtype that is an
anonymous subtype as a local_anonymous_type, because its accessibility
level is the return type of the enclosing function.
(Check_Initialization): In -gnatg mode, turn the error "cannot
initialize entities of limited type" into a warning.
(OK_For_Limited_Init): Return true for generated nodes, since it
sometimes violates the legality rules.
(Make_Incomplete_Declaration): If the type for which an incomplete
declaration is created happens to be the currently visible entity,
preserve the homonym chain when removing it from visibility.
(Check_Conventions): Add support for Ada 2005 (AI-430): Conventions of
inherited subprograms.
(Access_Definition): If this is an access to function that is the return
type of an access_to_function definition, context is a type declaration
and the scope of the anonymous type is the current one.
(Analyze_Subtype_Declaration): Add the defining identifier of a regular
incomplete subtype to the set of private dependents of the original
incomplete type.
(Constrain_Discriminated_Type): Emit an error message whenever an
incomplete subtype is being constrained.
(Process_Incomplete_Dependents): Transform an incomplete subtype into a
corresponding subtype of the full view of the original incomplete type.
(Check_Incomplete): Properly detect invalid usage of incomplete types
and subtypes.
From-SVN: r118273
Diffstat (limited to 'gcc/ada/g-awk.adb')
-rw-r--r-- | gcc/ada/g-awk.adb | 259 |
1 files changed, 230 insertions, 29 deletions
diff --git a/gcc/ada/g-awk.adb b/gcc/ada/g-awk.adb index d39ef84..e530efc 100644 --- a/gcc/ada/g-awk.adb +++ b/gcc/ada/g-awk.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2000-2005 AdaCore -- +-- Copyright (C) 2000-2006 AdaCore -- -- -- -- 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- -- @@ -31,6 +31,11 @@ -- -- ------------------------------------------------------------------------------ +pragma Ada_95; +-- This is needed because the pragmas Warnings (Off) in Current_Session and +-- Default_Session (see below) do not work when compiling clients of this +-- package that instantiate generic units herein. + pragma Style_Checks (All_Checks); -- Turn off alpha ordering check for subprograms, since we cannot -- Put Finalize and Initialize in alpha order (see comments). @@ -332,13 +337,13 @@ package body GNAT.AWK is -- A function that always returns True function Apply_Filters - (Session : Session_Type := Current_Session) return Boolean; + (Session : Session_Type) return Boolean; -- Apply any filters for which the Pattern is True for Session. It returns -- True if a least one filters has been applied (i.e. associated action -- callback has been called). procedure Open_Next_File - (Session : Session_Type := Current_Session); + (Session : Session_Type); pragma Inline (Open_Next_File); -- Open next file for Session closing current file if needed. It raises -- End_Error if there is no more file in the table. @@ -580,7 +585,7 @@ package body GNAT.AWK is procedure Add_File (Filename : String; - Session : Session_Type := Current_Session) + Session : Session_Type) is Files : File_Table.Instance renames Session.Data.Files; @@ -596,6 +601,14 @@ package body GNAT.AWK is end if; end Add_File; + procedure Add_File + (Filename : String) + is + + begin + Add_File (Filename, Cur_Session); + end Add_File; + --------------- -- Add_Files -- --------------- @@ -604,7 +617,7 @@ package body GNAT.AWK is (Directory : String; Filenames : String; Number_Of_Files_Added : out Natural; - Session : Session_Type := Current_Session) + Session : Session_Type) is use Directory_Operations; @@ -636,6 +649,16 @@ package body GNAT.AWK is Session); end Add_Files; + procedure Add_Files + (Directory : String; + Filenames : String; + Number_Of_Files_Added : out Natural) + is + + begin + Add_Files (Directory, Filenames, Number_Of_Files_Added, Cur_Session); + end Add_Files; + ----------------- -- Always_True -- ----------------- @@ -650,7 +673,7 @@ package body GNAT.AWK is ------------------- function Apply_Filters - (Session : Session_Type := Current_Session) return Boolean + (Session : Session_Type) return Boolean is Filters : Pattern_Action_Table.Instance renames Session.Data.Filters; Results : Boolean := False; @@ -715,7 +738,13 @@ package body GNAT.AWK is function Current_Session return Session_Type is begin + pragma Warnings (Off); return Cur_Session; + -- ???The above return statement violates the Ada 2005 rule forbidding + -- copying of limited objects (see RM-7.5(2.8/2)). When compiled with + -- -gnatg, the compiler gives a warning instead of an error, so we can + -- turn it off. + pragma Warnings (On); end Current_Session; --------------------- @@ -724,7 +753,13 @@ package body GNAT.AWK is function Default_Session return Session_Type is begin + pragma Warnings (Off); return Def_Session; + -- ???The above return statement violates the Ada 2005 rule forbidding + -- copying of limited objects (see RM-7.5(2.8/2)). When compiled with + -- -gnatg, the compiler gives a warning instead of an error, so we can + -- turn it off. + pragma Warnings (On); end Default_Session; -------------------- @@ -733,42 +768,63 @@ package body GNAT.AWK is function Discrete_Field (Rank : Count; - Session : Session_Type := Current_Session) return Discrete + Session : Session_Type) return Discrete is begin return Discrete'Value (Field (Rank, Session)); end Discrete_Field; + function Discrete_Field_Current_Session + (Rank : Count) return Discrete is + function Do_It is new Discrete_Field (Discrete); + begin + return Do_It (Rank, Cur_Session); + end Discrete_Field_Current_Session; + ----------------- -- End_Of_Data -- ----------------- function End_Of_Data - (Session : Session_Type := Current_Session) return Boolean + (Session : Session_Type) return Boolean is begin return Session.Data.File_Index = File_Table.Last (Session.Data.Files) and then End_Of_File (Session); end End_Of_Data; + function End_Of_Data + return Boolean + is + begin + return End_Of_Data (Cur_Session); + end End_Of_Data; + ----------------- -- End_Of_File -- ----------------- function End_Of_File - (Session : Session_Type := Current_Session) return Boolean + (Session : Session_Type) return Boolean is begin return Text_IO.End_Of_File (Session.Data.Current_File); end End_Of_File; + function End_Of_File + return Boolean + is + begin + return End_Of_File (Cur_Session); + end End_Of_File; + ----------- -- Field -- ----------- function Field (Rank : Count; - Session : Session_Type := Current_Session) return String + Session : Session_Type) return String is Fields : Field_Table.Instance renames Session.Data.Fields; @@ -793,8 +849,15 @@ package body GNAT.AWK is end Field; function Field + (Rank : Count) return String + is + begin + return Field (Rank, Cur_Session); + end Field; + + function Field (Rank : Count; - Session : Session_Type := Current_Session) return Integer + Session : Session_Type) return Integer is begin return Integer'Value (Field (Rank, Session)); @@ -809,8 +872,15 @@ package body GNAT.AWK is end Field; function Field + (Rank : Count) return Integer + is + begin + return Field (Rank, Cur_Session); + end Field; + + function Field (Rank : Count; - Session : Session_Type := Current_Session) return Float + Session : Session_Type) return Float is begin return Float'Value (Field (Rank, Session)); @@ -824,12 +894,19 @@ package body GNAT.AWK is Session); end Field; + function Field + (Rank : Count) return Float + is + begin + return Field (Rank, Cur_Session); + end Field; + ---------- -- File -- ---------- function File - (Session : Session_Type := Current_Session) return String + (Session : Session_Type) return String is Files : File_Table.Instance renames Session.Data.Files; @@ -841,6 +918,13 @@ package body GNAT.AWK is end if; end File; + function File + return String + is + begin + return File (Cur_Session); + end File; + -------------------- -- For_Every_Line -- -------------------- @@ -849,7 +933,7 @@ package body GNAT.AWK is (Separators : String := Use_Current; Filename : String := Use_Current; Callbacks : Callback_Mode := None; - Session : Session_Type := Current_Session) + Session : Session_Type) is Quit : Boolean; @@ -879,13 +963,23 @@ package body GNAT.AWK is Close (Session); end For_Every_Line; + procedure For_Every_Line_Current_Session + (Separators : String := Use_Current; + Filename : String := Use_Current; + Callbacks : Callback_Mode := None) + is + procedure Do_It is new For_Every_Line (Action); + begin + Do_It (Separators, Filename, Callbacks, Cur_Session); + end For_Every_Line_Current_Session; + -------------- -- Get_Line -- -------------- procedure Get_Line (Callbacks : Callback_Mode := None; - Session : Session_Type := Current_Session) + Session : Session_Type) is Filter_Active : Boolean; @@ -915,51 +1009,86 @@ package body GNAT.AWK is end loop; end Get_Line; + procedure Get_Line + (Callbacks : Callback_Mode := None) + is + begin + Get_Line (Callbacks, Cur_Session); + end Get_Line; + ---------------------- -- Number_Of_Fields -- ---------------------- function Number_Of_Fields - (Session : Session_Type := Current_Session) return Count + (Session : Session_Type) return Count is begin return Count (Field_Table.Last (Session.Data.Fields)); end Number_Of_Fields; + function Number_Of_Fields + return Count + is + begin + return Number_Of_Fields (Cur_Session); + end Number_Of_Fields; + -------------------------- -- Number_Of_File_Lines -- -------------------------- function Number_Of_File_Lines - (Session : Session_Type := Current_Session) return Count + (Session : Session_Type) return Count is begin return Count (Session.Data.FNR); end Number_Of_File_Lines; + function Number_Of_File_Lines + return Count + is + begin + return Number_Of_File_Lines (Cur_Session); + end Number_Of_File_Lines; + --------------------- -- Number_Of_Files -- --------------------- function Number_Of_Files - (Session : Session_Type := Current_Session) return Natural + (Session : Session_Type) return Natural is Files : File_Table.Instance renames Session.Data.Files; begin return File_Table.Last (Files); end Number_Of_Files; + function Number_Of_Files + return Natural + is + begin + return Number_Of_Files (Cur_Session); + end Number_Of_Files; + --------------------- -- Number_Of_Lines -- --------------------- function Number_Of_Lines - (Session : Session_Type := Current_Session) return Count + (Session : Session_Type) return Count is begin return Count (Session.Data.NR); end Number_Of_Lines; + function Number_Of_Lines + return Count + is + begin + return Number_Of_Lines (Cur_Session); + end Number_Of_Lines; + ---------- -- Open -- ---------- @@ -967,7 +1096,7 @@ package body GNAT.AWK is procedure Open (Separators : String := Use_Current; Filename : String := Use_Current; - Session : Session_Type := Current_Session) + Session : Session_Type) is begin if Text_IO.Is_Open (Session.Data.Current_File) then @@ -990,12 +1119,20 @@ package body GNAT.AWK is raise File_Error; end Open; + procedure Open + (Separators : String := Use_Current; + Filename : String := Use_Current) + is + begin + Open (Separators, Filename, Cur_Session); + end Open; + -------------------- -- Open_Next_File -- -------------------- procedure Open_Next_File - (Session : Session_Type := Current_Session) + (Session : Session_Type) is Files : File_Table.Instance renames Session.Data.Files; @@ -1025,7 +1162,7 @@ package body GNAT.AWK is procedure Parse (Separators : String := Use_Current; Filename : String := Use_Current; - Session : Session_Type := Current_Session) + Session : Session_Type) is Filter_Active : Boolean; pragma Unreferenced (Filter_Active); @@ -1041,6 +1178,14 @@ package body GNAT.AWK is Close (Session); end Parse; + procedure Parse + (Separators : String := Use_Current; + Filename : String := Use_Current) + is + begin + Parse (Separators, Filename, Cur_Session); + end Parse; + --------------------- -- Raise_With_Info -- --------------------- @@ -1143,7 +1288,7 @@ package body GNAT.AWK is (Field : Count; Pattern : String; Action : Action_Callback; - Session : Session_Type := Current_Session) + Session : Session_Type) is Filters : Pattern_Action_Table.Instance renames Session.Data.Filters; U_Pattern : constant Unbounded_String := To_Unbounded_String (Pattern); @@ -1158,9 +1303,18 @@ package body GNAT.AWK is procedure Register (Field : Count; + Pattern : String; + Action : Action_Callback) + is + begin + Register (Field, Pattern, Action, Cur_Session); + end Register; + + procedure Register + (Field : Count; Pattern : GNAT.Regpat.Pattern_Matcher; Action : Action_Callback; - Session : Session_Type := Current_Session) + Session : Session_Type) is Filters : Pattern_Action_Table.Instance renames Session.Data.Filters; @@ -1177,8 +1331,17 @@ package body GNAT.AWK is procedure Register (Field : Count; Pattern : GNAT.Regpat.Pattern_Matcher; + Action : Action_Callback) + is + begin + Register (Field, Pattern, Action, Cur_Session); + end Register; + + procedure Register + (Field : Count; + Pattern : GNAT.Regpat.Pattern_Matcher; Action : Match_Action_Callback; - Session : Session_Type := Current_Session) + Session : Session_Type) is Filters : Pattern_Action_Table.Instance renames Session.Data.Filters; @@ -1193,9 +1356,18 @@ package body GNAT.AWK is end Register; procedure Register + (Field : Count; + Pattern : GNAT.Regpat.Pattern_Matcher; + Action : Match_Action_Callback) + is + begin + Register (Field, Pattern, Action, Cur_Session); + end Register; + + procedure Register (Pattern : Pattern_Callback; Action : Action_Callback; - Session : Session_Type := Current_Session) + Session : Session_Type) is Filters : Pattern_Action_Table.Instance renames Session.Data.Filters; @@ -1208,13 +1380,28 @@ package body GNAT.AWK is end Register; procedure Register + (Pattern : Pattern_Callback; + Action : Action_Callback) + is + begin + Register (Pattern, Action, Cur_Session); + end Register; + + procedure Register (Action : Action_Callback; - Session : Session_Type := Current_Session) + Session : Session_Type) is begin Register (Always_True'Access, Action, Session); end Register; + procedure Register + (Action : Action_Callback) + is + begin + Register (Action, Cur_Session); + end Register; + ----------------- -- Set_Current -- ----------------- @@ -1230,7 +1417,7 @@ package body GNAT.AWK is procedure Set_Field_Separators (Separators : String := Default_Separators; - Session : Session_Type := Current_Session) + Session : Session_Type) is begin Free (Session.Data.Separators); @@ -1246,13 +1433,20 @@ package body GNAT.AWK is end if; end Set_Field_Separators; + procedure Set_Field_Separators + (Separators : String := Default_Separators) + is + begin + Set_Field_Separators (Separators, Cur_Session); + end Set_Field_Separators; + ---------------------- -- Set_Field_Widths -- ---------------------- procedure Set_Field_Widths (Field_Widths : Widths_Set; - Session : Session_Type := Current_Session) + Session : Session_Type) is begin Free (Session.Data.Separators); @@ -1268,6 +1462,13 @@ package body GNAT.AWK is end if; end Set_Field_Widths; + procedure Set_Field_Widths + (Field_Widths : Widths_Set) + is + begin + Set_Field_Widths (Field_Widths, Cur_Session); + end Set_Field_Widths; + ---------------- -- Split_Line -- ---------------- |