diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-07-05 12:40:03 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2013-07-05 12:40:03 +0200 |
commit | 67a90476cfab907864d3c97decdba6373be1b8b7 (patch) | |
tree | cca2de79e678fafcd492db9efeafc5e1dc0e79e9 /gcc/ada/styleg.adb | |
parent | 6ee07c611ca3dd4f70bd9744cf0342e8ff536c69 (diff) | |
download | gcc-67a90476cfab907864d3c97decdba6373be1b8b7.zip gcc-67a90476cfab907864d3c97decdba6373be1b8b7.tar.gz gcc-67a90476cfab907864d3c97decdba6373be1b8b7.tar.bz2 |
[multiple changes]
2013-07-05 Claire Dross <dross@adacore.com>
* a-cfdlli.ads: Add preconditions when needed.
2013-07-05 Robert Dewar <dewar@adacore.com>
* sem_ch8.adb: Minor reformatting.
2013-07-05 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Access_Subprogram_Declaration): Use
Generate_Reference_To_Formals.
* lib-xref.adb (Generate_Reference_To_Formals): In the case of
access to subprograms, the formals are found in the designated
subprogram type.
2013-07-05 Robert Dewar <dewar@adacore.com>
* gnat_ugn.texi: Document that comments can be lined up with
previous non-blank line.
* styleg.adb (Check_Comment): Allow indentation to match previous
non-blank line (Same_Column_As_Previous_Line): New function
From-SVN: r200705
Diffstat (limited to 'gcc/ada/styleg.adb')
-rw-r--r-- | gcc/ada/styleg.adb | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/gcc/ada/styleg.adb b/gcc/ada/styleg.adb index 04634d1..6e4a442 100644 --- a/gcc/ada/styleg.adb +++ b/gcc/ada/styleg.adb @@ -351,7 +351,9 @@ package body Styleg is -- 6. In addition, the comment must be properly indented if comment -- indentation checking is active (Style_Check_Indentation non-zero). -- Either the start column must be a multiple of this indentation, - -- or the indentation must match that of the next non-blank line. + -- or the indentation must match that of the next non-blank line, + -- or must match the indentation of the immediately preciding line + -- if it is non-blank. procedure Check_Comment is S : Source_Ptr; @@ -369,6 +371,12 @@ package body Styleg is -- matches that of the next non-blank line in the source, then True is -- returned, otherwise False. + function Same_Column_As_Previous_Line return Boolean; + -- Called for a full line comment. If the previous line is blank, then + -- returns False. Otherwise, if the indentation of this comment matches + -- that of the previous line in the source, then True is returned, + -- otherwise False. + -------------------- -- Is_Box_Comment -- -------------------- @@ -429,6 +437,39 @@ package body Styleg is return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P); end Same_Column_As_Next_Non_Blank_Line; + ---------------------------------- + -- Same_Column_As_Previous_Line -- + ---------------------------------- + + function Same_Column_As_Previous_Line return Boolean is + S, P : Source_Ptr; + + begin + -- Point S to start of this line, and P to start of previous line + + S := Line_Start (Scan_Ptr); + P := S; + Backup_Line (P); + + -- Step P to first non-blank character on line + + loop + -- If we get back to start of current line, then the previous line + -- was blank, and we always return False in that situation. + + if P = S then + return False; + end if; + + exit when Source (P) /= ' ' and then Source (P) /= ASCII.HT; + P := P + 1; + end loop; + + -- Compare columns + + return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P); + end Same_Column_As_Previous_Line; + -- Start of processing for Check_Comment begin @@ -466,7 +507,9 @@ package body Styleg is if Style_Check_Indentation /= 0 then if Start_Column rem Style_Check_Indentation /= 0 then - if not Same_Column_As_Next_Non_Blank_Line then + if not Same_Column_As_Next_Non_Blank_Line + and then not Same_Column_As_Previous_Line + then Error_Msg_S -- CODEFIX ("(style) bad column"); end if; |