diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-14 13:16:59 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-14 13:16:59 +0000 |
commit | 7d6851fbbe990b60d2487070afecf9938c3857f4 (patch) | |
tree | 0f7f721405eed5f3477da90b21bd20778cbd6a8d /gcc/ada/prep.adb | |
parent | 78beb6359ada309266f91eaddd69024f237ba424 (diff) | |
download | gcc-7d6851fbbe990b60d2487070afecf9938c3857f4.tar.gz |
2013-10-14 Robert Dewar <dewar@adacore.com>
* s-valuti.adb, prep.adb, scng.adb, errout.adb: Minor reformatting.
2013-10-14 Eric Botcazou <ebotcazou@adacore.com>
* adaint.c: Further disable __gnat_get_executable_load_address
for Linux.
2013-10-14 Vincent Celier <celier@adacore.com>
* gnat_ugn.texi: Add documentation for comparing symbols to
integers in preprocessing expressions.
2013-10-14 Jose Ruiz <ruiz@adacore.com>
* sem_prag.adb (Analyze_Aspect_Specification): For
Priority and CPU aspects in subprograms, the expression in the
aspect is analyzed and exported.
(Analyze_Pragma): When having a Priority pragma in the
main subprogram, load a unit that will force the initialization
of the tasking run time, which is needed for setting the required
priority.
2013-10-14 Vincent Celier <celier@adacore.com>
* prj-nmsc.adb (Check_Interfaces): Put in Other_Interfaces all
non Ada interface files.
* prj.ads (Project_Data): New component Other_Interfaces.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203542 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/prep.adb')
-rw-r--r-- | gcc/ada/prep.adb | 121 |
1 files changed, 68 insertions, 53 deletions
diff --git a/gcc/ada/prep.adb b/gcc/ada/prep.adb index b48286e65d9..10ced63f4fd 100644 --- a/gcc/ada/prep.adb +++ b/gcc/ada/prep.adb @@ -147,21 +147,19 @@ package body Prep is type Pp_State is record If_Ptr : Source_Ptr; - -- The location of the #if statement. - -- Used to flag #if with no corresponding #end if, at the end. + -- The location of the #if statement (used to flag #if with no + -- corresponding #end if, at the end). Else_Ptr : Source_Ptr; - -- The location of the #else statement. - -- Used to detect multiple #else. + -- The location of the #else statement (used to detect multiple #else's) Deleting : Boolean; -- Set to True when the code should be deleted or commented out Match_Seen : Boolean; - -- Set to True when a condition in an #if or an #elsif is True. - -- Also set to True if Deleting at the previous level is True. - -- Used to decide if Deleting should be set to True in a following - -- #elsif or #else. + -- Set to True when a condition in an #if or an #elsif is True. Also set + -- to True if Deleting at the previous level is True. Used to decide if + -- Deleting should be set to True in a following #elsif or #else. end record; @@ -190,13 +188,13 @@ package body Prep is function Expression (Evaluate_It : Boolean; Complemented : Boolean := False) return Boolean; - -- Evaluate a condition in an #if or an #elsif statement. - -- If Evaluate_It is False, the condition is effectively evaluated, - -- otherwise, only the syntax is checked. + -- Evaluate a condition in an #if or an #elsif statement. If Evaluate_It + -- is False, the condition is effectively evaluated, otherwise, only the + -- syntax is checked. procedure Go_To_End_Of_Line; - -- Advance the scan pointer until we reach an end of line or the end - -- of the buffer. + -- Advance the scan pointer until we reach an end of line or the end of the + -- buffer. function Matching_Strings (S1, S2 : String_Id) return Boolean; -- Returns True if the two string parameters are equal (case insensitive) @@ -251,6 +249,7 @@ package body Prep is -- If no character '=', then the value is True if Index = 0 then + -- Put the symbol in the name buffer Name_Len := Definition'Length; @@ -377,8 +376,8 @@ package body Prep is Complemented : Boolean := False) return Boolean is Evaluation : Boolean := Evaluate_It; - -- Is set to False after an "or else" when left term is True and - -- after an "and then" when left term is False. + -- Is set to False after an "or else" when left term is True and after + -- an "and then" when left term is False. Final_Result : Boolean := False; @@ -405,12 +404,13 @@ package body Prep is Current_Result := False; - case Token is + -- Scan current term, starting with Token - when Tok_Left_Paren => + case Token is - -- ( expression ) + -- Handle parenthesized expression + when Tok_Left_Paren => Scan.all; Current_Result := Expression (Evaluation); @@ -422,14 +422,15 @@ package body Prep is ("`)` expected", Token_Ptr); end if; - when Tok_Not => - - -- not expression + -- Handle not expression + when Tok_Not => Scan.all; Current_Result := not Expression (Evaluation, Complemented => True); + -- Handle sequence starting with identifier + when Tok_Identifier => Symbol_Name1 := Token_Name; Symbol_Pos1 := Token_Ptr; @@ -454,11 +455,13 @@ package body Prep is Current_Result := Index_Of (Symbol_Name1) /= No_Symbol; end if; + -- Handle relational operator + elsif - Token = Tok_Equal or else - Token = Tok_Less or else + Token = Tok_Equal or else + Token = Tok_Less or else Token = Tok_Less_Equal or else - Token = Tok_Greater or else + Token = Tok_Greater or else Token = Tok_Greater_Equal then Relop := Token; @@ -476,7 +479,10 @@ package body Prep is declare Value : constant Int := UI_To_Int (Int_Literal_Value); Data : Symbol_Data; + Symbol_Value : Int; + -- Value of symbol as Int + begin if Evaluation then Symbol1 := Index_Of (Symbol_Name1); @@ -530,7 +536,7 @@ package body Prep is when Constraint_Error => Error_Msg_Name_1 := Symbol_Name1; Error_Msg - ("symbol % value is not integer", + ("symbol % value is not an integer", Symbol_Pos1); end; end if; @@ -540,9 +546,13 @@ package body Prep is Scan.all; end; + -- Error if relational operator other than = if not numbers + elsif Relop /= Tok_Equal then Error_Msg ("number expected", Token_Ptr); + -- Equality comparison of two strings + elsif Token = Tok_Identifier then -- symbol = symbol @@ -586,10 +596,11 @@ package body Prep is end if; if Symbol_Value1 /= No_String - and then Symbol_Value2 /= No_String + and then + Symbol_Value2 /= No_String then - Current_Result := Matching_Strings - (Symbol_Value1, Symbol_Value2); + Current_Result := + Matching_Strings (Symbol_Value1, Symbol_Value2); end if; end if; @@ -630,9 +641,9 @@ package body Prep is Token_Ptr); end if; - else - -- symbol (True or False) + -- Handle True or False + else if Evaluation then Symbol1 := Index_Of (Symbol_Name1); @@ -674,6 +685,8 @@ package body Prep is end if; end if; + -- Unrecognized sequence + when others => Error_Msg ("`(`, NOT or symbol expected", Token_Ptr); end case; @@ -691,7 +704,7 @@ package body Prep is Final_Result := Final_Result and Current_Result; end case; - -- Check the next operator + -- Handle AND if Token = Tok_And then if Complemented then @@ -714,6 +727,8 @@ package body Prep is end if; end if; + -- Handle OR + elsif Token = Tok_Or then if Complemented then Error_Msg @@ -735,9 +750,9 @@ package body Prep is end if; end if; - else - -- No operator: exit the term loop + -- No AND/OR operator, so exit from the loop through terms + else exit; end if; end loop; @@ -824,7 +839,6 @@ package body Prep is Get_Name_String (Mapping.Table (Order (Op1)).Symbol); S2 : constant String := Get_Name_String (Mapping.Table (Order (Op2)).Symbol); - begin return S1 < S2; end Lt; @@ -961,6 +975,8 @@ package body Prep is -- Parse_Def_File -- -------------------- + -- This procedure REALLY needs some more comments ??? + procedure Parse_Def_File is Symbol : Symbol_Id; Symbol_Name : Name_Id; @@ -1012,7 +1028,6 @@ package body Prep is begin Start_String; - while Ptr < Scan_Ptr loop Store_String_Char (Sinput.Source (Ptr)); Ptr := Ptr + 1; @@ -1102,9 +1117,10 @@ package body Prep is Symbol := Index_Of (Symbol_Name); if Symbol /= No_Symbol then + -- If we already have an entry for this symbol, replace it - -- with the new value, except if the symbol was declared - -- on the command line. + -- with the new value, except if the symbol was declared on + -- the command line. if Mapping.Table (Symbol).On_The_Command_Line then goto Continue; @@ -1299,8 +1315,8 @@ package body Prep is Scan.all; end if; - -- It is an error to have trailing characters after - -- the condition or "then". + -- It is an error to have trailing characters after the + -- condition or "then". if Token /= Tok_End_Of_Line and then Token /= Tok_EOF @@ -1313,8 +1329,9 @@ package body Prep is Go_To_End_Of_Line; end if; - -- Depending on the value of the condition, set the - -- new values of Deleting and Match_Seen. + -- Depending on the value of the condition, set the new + -- values of Deleting and Match_Seen. + if Pp_States.Last > 0 then if Pp_States.Table (Pp_States.Last).Match_Seen then Pp_States.Table (Pp_States.Last).Deleting := True; @@ -1343,8 +1360,7 @@ package body Prep is No_Error_Found := False; end if; - -- Set the possibly new values of Deleting and - -- Match_Seen. + -- Set the possibly new values of Deleting and Match_Seen if Pp_States.Last > 0 then if Pp_States.Table (Pp_States.Last).Match_Seen then @@ -1358,8 +1374,7 @@ package body Prep is False; end if; - -- Set the Else_Ptr to check for illegal #elsif - -- later. + -- Set the Else_Ptr to check for illegal #elsif later Pp_States.Table (Pp_States.Last).Else_Ptr := Token_Ptr; @@ -1367,7 +1382,8 @@ package body Prep is Scan.all; - -- It is an error to have characters after "#else" + -- Error of character present after "#else" + if Token /= Tok_End_Of_Line and then Token /= Tok_EOF then @@ -1404,8 +1420,8 @@ package body Prep is else Scan.all; - -- It is an error to have character after - -- "#end if;". + -- Error of character present after "#end if;" + if Token /= Tok_End_Of_Line and then Token /= Tok_EOF then @@ -1535,15 +1551,14 @@ package body Prep is pragma Assert (Token = Tok_End_Of_Line or else Token = Tok_EOF); - -- At this point, the token is either end of line or EOF. - -- The line to possibly output stops just before the token. + -- At this point, the token is either end of line or EOF. The line to + -- possibly output stops just before the token. Output_Line (Start_Of_Processing, Token_Ptr - 1); -- If we are at the end of a line, the scan pointer is at the first - -- non blank character, not necessarily the first character of the - -- line; so, we have to deduct Start_Of_Processing from the token - -- pointer. + -- non-blank character (may not be the first character of the line), + -- so we have to deduct Start_Of_Processing from the token pointer. if Token = Tok_End_Of_Line then if (Sinput.Source (Token_Ptr) = ASCII.CR |