diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-01-27 17:52:29 +0100 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-01-27 17:52:29 +0100 |
commit | 29077c18417c523c5fd2790613ba4ea2988660c4 (patch) | |
tree | e5e8e81614a2a9517430d8c729e77035019f2b70 /gcc/ada/scng.adb | |
parent | 2757c5bf1817db84c51f0297ae8c27acfaea2ad3 (diff) | |
download | gcc-29077c18417c523c5fd2790613ba4ea2988660c4.zip gcc-29077c18417c523c5fd2790613ba4ea2988660c4.tar.gz gcc-29077c18417c523c5fd2790613ba4ea2988660c4.tar.bz2 |
[multiple changes]
2014-01-27 Robert Dewar <dewar@adacore.com>
* scn.adb (Check_End_Of_Line): Removed.
(Error_Long_Line): Removed.
(Determine_License): Use versions of above routines from Scanner.
* scng.adb (Check_End_Of_Line): Moved to spec.
(Error_Long_Line): Removed, no longer used.
* scng.ads (Check_End_Of_Line): Moved here from body.
2014-01-27 Tristan Gingold <gingold@adacore.com>
* exp_ch7.adb (Build_Cleanup_Statements): Call
Build_Protected_Subprogram_Call_Cleanup to insert the cleanup
for protected body.
* exp_ch9.adb (Build_Protected_Subprogram_Body): Likewise.
Remove Service_Name variable.
(Build_Protected_SUbprogam_Call_Cleanup): New procedure that
factorize code from the above subprograms.
* exp_ch9.ads (Build_Protected_Subprogram_Call_Cleanup): New procedure.
From-SVN: r207143
Diffstat (limited to 'gcc/ada/scng.adb')
-rw-r--r-- | gcc/ada/scng.adb | 166 |
1 files changed, 76 insertions, 90 deletions
diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb index ef3d665..8b08949 100644 --- a/gcc/ada/scng.adb +++ b/gcc/ada/scng.adb @@ -259,6 +259,82 @@ package body Scng is end case; end Accumulate_Token_Checksum_GNAT_5_03; + ----------------------- + -- Check_End_Of_Line -- + ----------------------- + + procedure Check_End_Of_Line is + Len : constant Int := + Int (Scan_Ptr) - + Int (Current_Line_Start) - + Wide_Char_Byte_Count; + + -- Start of processing for Check_End_Of_Line + + begin + if Style_Check then + Style.Check_Line_Terminator (Len); + end if; + + -- Deal with checking maximum line length + + if Style_Check and Style_Check_Max_Line_Length then + Style.Check_Line_Max_Length (Len); + + -- If style checking is inactive, check maximum line length against + -- standard value. + + elsif Len > Max_Line_Length then + Error_Msg + ("this line is too long", + Current_Line_Start + Source_Ptr (Max_Line_Length)); + end if; + + -- Now one more checking circuit. Normally we are only enforcing a limit + -- of physical characters, with tabs counting as one character. But if + -- after tab expansion we would have a total line length that exceeded + -- 32766, that would really cause trouble, because column positions + -- would exceed the maximum we allow for a column count. Note: the limit + -- is 32766 rather than 32767, since we use a value of 32767 for special + -- purposes (see Sinput). Now we really do not want to go messing with + -- tabs in the normal case, so what we do is to check for a line that + -- has more than 4096 physical characters. Any shorter line could not + -- be a problem, even if it was all tabs. + + if Len >= 4096 then + declare + Col : Natural; + Ptr : Source_Ptr; + + begin + Col := 1; + Ptr := Current_Line_Start; + loop + exit when Ptr = Scan_Ptr; + + if Source (Ptr) = ASCII.HT then + Col := (Col - 1 + 8) / 8 * 8 + 1; + else + Col := Col + 1; + end if; + + if Col > 32766 then + Error_Msg + ("this line is longer than 32766 characters", + Current_Line_Start); + raise Unrecoverable_Error; + end if; + + Ptr := Ptr + 1; + end loop; + end; + end if; + + -- Reset wide character byte count for next line + + Wide_Char_Byte_Count := 0; + end Check_End_Of_Line; + ---------------------------- -- Determine_Token_Casing -- ---------------------------- @@ -336,10 +412,6 @@ package body Scng is Wptr : Source_Ptr; -- Used to remember start of last wide character scanned - procedure Check_End_Of_Line; - -- Called when end of line encountered. Checks that line is not too - -- long, and that other style checks for the end of line are met. - function Double_Char_Token (C : Character) return Boolean; -- This function is used for double character tokens like := or <>. It -- checks if the character following Source (Scan_Ptr) is C, and if so @@ -359,9 +431,6 @@ package body Scng is -- past the illegal character, which may still leave us pointing to -- junk, not much we can do if the escape sequence is messed up! - procedure Error_Long_Line; - -- Signal error of excessively long line - procedure Error_No_Double_Underline; -- Signal error of two underline or punctuation characters in a row. -- Called with Scan_Ptr pointing to second underline/punctuation char. @@ -389,78 +458,6 @@ package body Scng is -- character sequence, does not modify the scan pointer in any case. ----------------------- - -- Check_End_Of_Line -- - ----------------------- - - procedure Check_End_Of_Line is - Len : constant Int := - Int (Scan_Ptr) - - Int (Current_Line_Start) - - Wide_Char_Byte_Count; - - begin - if Style_Check then - Style.Check_Line_Terminator (Len); - end if; - - -- Deal with checking maximum line length - - if Style_Check and Style_Check_Max_Line_Length then - Style.Check_Line_Max_Length (Len); - - -- If style checking is inactive, check maximum line length against - -- standard value. - - elsif Len > Max_Line_Length then - Error_Long_Line; - end if; - - -- Now one more checking circuit. Normally we are only enforcing a - -- limit of physical characters, with tabs counting as one character. - -- But if after tab expansion we would have a total line length that - -- exceeded 32766, that would really cause trouble, because column - -- positions would exceed the maximum we allow for a column count. - -- Note: the limit is 32766 rather than 32767, since we use a value - -- of 32767 for special purposes (see Sinput). Now we really do not - -- want to go messing with tabs in the normal case, so what we do is - -- to check for a line that has more than 4096 physical characters. - -- Any shorter line could not be a problem, even if it was all tabs. - - if Len >= 4096 then - declare - Col : Natural; - Ptr : Source_Ptr; - - begin - Col := 1; - Ptr := Current_Line_Start; - loop - exit when Ptr = Scan_Ptr; - - if Source (Ptr) = ASCII.HT then - Col := (Col - 1 + 8) / 8 * 8 + 1; - else - Col := Col + 1; - end if; - - if Col > 32766 then - Error_Msg - ("this line is longer than 32766 characters", - Current_Line_Start); - raise Unrecoverable_Error; - end if; - - Ptr := Ptr + 1; - end loop; - end; - end if; - - -- Reset wide character byte count for next line - - Wide_Char_Byte_Count := 0; - end Check_End_Of_Line; - - ----------------------- -- Double_Char_Token -- ----------------------- @@ -505,17 +502,6 @@ package body Scng is Error_Msg ("illegal wide character", Wptr); end Error_Illegal_Wide_Character; - --------------------- - -- Error_Long_Line -- - --------------------- - - procedure Error_Long_Line is - begin - Error_Msg - ("this line is too long", - Current_Line_Start + Source_Ptr (Max_Line_Length)); - end Error_Long_Line; - ------------------------------- -- Error_No_Double_Underline -- ------------------------------- |