Index: style.ads =================================================================== --- style.ads (revision 213263) +++ style.ads (working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, 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- -- @@ -79,7 +79,7 @@ renames Style_Inst.Check_Apostrophe; -- Called after scanning an apostrophe to check spacing - procedure Check_Arrow + procedure Check_Arrow (Inside_Depends : Boolean := False) renames Style_Inst.Check_Arrow; -- Called after scanning out an arrow to check spacing @@ -180,7 +180,7 @@ -- procedure is called only if THEN appears at the start of a line with -- Token_Ptr pointing to the THEN keyword. - procedure Check_Unary_Plus_Or_Minus + procedure Check_Unary_Plus_Or_Minus (Inside_Depends : Boolean := False) renames Style_Inst.Check_Unary_Plus_Or_Minus; -- Called after scanning a unary plus or minus to check spacing Index: par-ch13.adb =================================================================== --- par-ch13.adb (revision 213263) +++ par-ch13.adb (working copy) @@ -170,6 +170,8 @@ Scan; -- past WITH Aspects := Empty_List; + -- Loop to scan aspects + loop OK := True; @@ -445,6 +447,12 @@ end if; end if; + -- Note if inside Depends aspect + + if A_Id = Aspect_Depends then + Inside_Depends := True; + end if; + -- Parse the aspect definition depening on the expected -- argument kind. @@ -460,6 +468,10 @@ Aspect_Argument (A_Id) = Optional_Expression); Set_Expression (Aspect, P_Expression); end if; + + -- Unconditionally reset flag for Inside_Depends + + Inside_Depends := False; end if; -- Add the aspect to the resulting list only when it was properly Index: scng.adb =================================================================== --- scng.adb (revision 213263) +++ scng.adb (working copy) @@ -1571,7 +1571,7 @@ Token := Tok_Arrow; if Style_Check then - Style.Check_Arrow; + Style.Check_Arrow (Inside_Depends); end if; return; Index: par-ch2.adb =================================================================== --- par-ch2.adb (revision 213263) +++ par-ch2.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, 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- -- @@ -298,13 +298,19 @@ Import_Check_Required := False; end if; + -- Set global to indicate if we are within a Depends pragma + + if Chars (Ident_Node) = Name_Depends then + Inside_Depends := True; + end if; + -- Scan arguments. We assume that arguments are present if there is -- a left paren, or if a semicolon is missing and there is another -- token on the same line as the pragma name. if Token = Tok_Left_Paren or else (Token /= Tok_Semicolon - and then not Token_Is_At_Start_Of_Line) + and then not Token_Is_At_Start_Of_Line) then Set_Pragma_Argument_Associations (Prag_Node, New_List); T_Left_Paren; @@ -349,6 +355,11 @@ Semicolon_Loc := Token_Ptr; + -- Cancel indication of being within Depends pragm. Can be done + -- unconditionally, since quicker than doing a test. + + Inside_Depends := False; + -- Now we have two tasks left, we need to scan out the semicolon -- following the pragma, and we have to call Par.Prag to process -- the pragma. Normally we do them in this order, however, there Index: par-ch4.adb =================================================================== --- par-ch4.adb (revision 213263) +++ par-ch4.adb (working copy) @@ -2106,7 +2106,7 @@ Node1 := New_Op_Node (P_Unary_Adding_Operator, Tokptr); if Style_Check then - Style.Check_Unary_Plus_Or_Minus; + Style.Check_Unary_Plus_Or_Minus (Inside_Depends); end if; Scan; -- past operator Index: scans.ads =================================================================== --- scans.ads (revision 213263) +++ scans.ads (working copy) @@ -472,6 +472,10 @@ -- Is it really right for this to be a Name rather than a String, what -- about the case of Wide_Wide_Characters??? + Inside_Depends : Boolean := False; + -- Flag set True for parsing the argument of a Depends pragma or aspect + -- (used to allow/require non-standard style rules for =>+ with -gnatyt). + Inside_If_Expression : Nat := 0; -- This is a counter that is set non-zero while scanning out an if -- expression (incremented on entry, decremented on exit). It is used to Index: styleg.adb =================================================================== --- styleg.adb (revision 213263) +++ styleg.adb (working copy) @@ -126,13 +126,32 @@ -- Check_Arrow -- ----------------- - -- In check tokens mode (-gnatys), arrow must be surrounded by spaces + -- In check tokens mode (-gnatys), arrow must be surrounded by spaces, + -- except that within the argument of a Depends macro the required format + -- is =>+ rather than => +). - procedure Check_Arrow is + procedure Check_Arrow (Inside_Depends : Boolean := False) is begin if Style_Check_Tokens then Require_Preceding_Space; - Require_Following_Space; + + if not Inside_Depends then + Require_Following_Space; + + -- Special handling for Inside_Depends + + else + if Source (Scan_Ptr) = ' ' + and then Source (Scan_Ptr + 1) = '+' + then + Error_Space_Not_Allowed (Scan_Ptr); + + elsif Source (Scan_Ptr) /= ' ' + and then Source (Scan_Ptr) /= '+' + then + Require_Following_Space; + end if; + end if; end if; end Check_Arrow; @@ -1032,10 +1051,17 @@ -- In check token mode (-gnatyt), unary plus or minus must not be -- followed by a space. - procedure Check_Unary_Plus_Or_Minus is + -- Annoying exception: if we have the sequence =>+ within a Depends pragma + -- or aspect, then we insist on a space rather than forbidding it. + + procedure Check_Unary_Plus_Or_Minus (Inside_Depends : Boolean := False) is begin if Style_Check_Tokens then - Check_No_Space_After; + if not Inside_Depends then + Check_No_Space_After; + else + Require_Following_Space; + end if; end if; end Check_Unary_Plus_Or_Minus; Index: styleg.ads =================================================================== --- styleg.ads (revision 213263) +++ styleg.ads (working copy) @@ -2,11 +2,11 @@ -- -- -- GNAT COMPILER COMPONENTS -- -- -- --- S T Y L E G -- +-- S T Y L E G -- -- -- -- S p e c -- -- -- --- Copyright (C) 1992-2013, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2014, 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- -- @@ -52,8 +52,10 @@ procedure Check_Apostrophe; -- Called after scanning an apostrophe to check spacing - procedure Check_Arrow; - -- Called after scanning out an arrow to check spacing + procedure Check_Arrow (Inside_Depends : Boolean := False); + -- Called after scanning out an arrow to check spacing. Inside_Depends is + -- true if the call is from an argument of the Depends pragma (where the + -- allowed/required format is =>+). procedure Check_Attribute_Name (Reserved : Boolean); -- The current token is an attribute designator. Check that it @@ -143,8 +145,10 @@ -- would interfere with coverage testing). Handles case of THEN ABORT as -- an exception, as well as PRAGMA after ELSE. - procedure Check_Unary_Plus_Or_Minus; - -- Called after scanning a unary plus or minus to check spacing + procedure Check_Unary_Plus_Or_Minus (Inside_Depends : Boolean := False); + -- Called after scanning a unary plus or minus to check spacing. The flag + -- Inside_Depends is set if we are scanning within a Depends pragma or + -- Aspect, in which case =>+ requires a following space). procedure Check_Vertical_Bar; -- Called after scanning a vertical bar to check spacing