errutil.adb, errout.adb: Minor comment updates on Line_Terminator references

2005-03-29  Robert Dewar  <dewar@adacore.com>

	* errutil.adb, errout.adb:
	Minor comment updates on Line_Terminator references

	* par-ch10.adb: Add ??? comment about line terminator

	* styleg.adb (Check_Line_Terminator): Add check for new switch -gnatyd
	(check dos line terminator).
	(Check_Line_Max_Length): New procedure, split off from the existing
	Check_Line_Terminator routine. Separating this out allows -gnatyf to
	be properly recognized.

	* styleg.adb: Add ??? comment for line terminator reference

	* scng.adb (Check_End_Of_Line): Fix bug of -gnatyf being ignored
	(Check_End_Of_Line): Add -gnatyd handling (check dos line terminators)

	* styleg.ads (Check_Line_Terminator): Add check for new switch -gnatyd
	(check dos line terminator).
	(Check_Line_Max_Length): New procedure, split off from the existing
	Check_Line_Terminator routine. Separating this out allows -gnatyf to
	be properly recognized.

	* stylesw.ads, stylesw.adb:
	Add handling for new -gnatyd switch (check dos line terminator)

	* switch-c.adb: Recognize new -gnatyd switch (check dos line terminator)
	Recognize -gnatwb/-gnatwB switches
	Include Warn_On_Bad_Fixed_Value for -gnatg

	* usage.adb:
	Add line for new -gnatyd switch (check dos line terminator)

	* usage.adb: Add lines for -gnatwb/-gnatwB

	* vms_data.ads: Add entry for NOCRLF (-gnatyd)

	* vms_data.ads: [NO_]BAD_FIXED_VALUES synonym for -gnatwb/-gnatwB

	* gnat_ugn.texi: Fix overlong lines
	Document new -gnatyd switch
	Document new -gnatwb/-gnatwB switches

From-SVN: r97169
This commit is contained in:
Robert Dewar 2005-03-29 18:14:20 +02:00 committed by Arnaud Charlet
parent d127f91b1d
commit debe0ab674
12 changed files with 181 additions and 77 deletions

View File

@ -493,6 +493,9 @@ package body Errout is
-- since there may be white space inside the literal and we don't want
-- to stop on that white space.
-- Note: since this is an error recovery issue anyway, it is not worth
-- worrying about special UTF_32 line terminator characters here.
if Prev_Token = Tok_String_Literal then
loop
S1 := S1 + 1;
@ -512,7 +515,10 @@ package body Errout is
-- Otherwise we search forward for the end of the current token, marked
-- by a line terminator, white space, a comment symbol or if we bump
-- into the following token (i.e. the current token)
-- into the following token (i.e. the current token).
-- Again, it is not worth worrying about UTF_32 special line terminator
-- characters in this context, since this is only for error recovery.
else
while Source (S1) not in Line_Terminator
@ -528,7 +534,6 @@ package body Errout is
-- S1 is now set to the location for the flag
Error_Msg (Msg, S1);
end Error_Msg_AP;
------------------

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1991-2003 Free Software Foundation, Inc. --
-- Copyright (C) 1991-2005 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- --
@ -100,6 +100,10 @@ package body Errutil is
-- since there may be white space inside the literal and we don't want
-- to stop on that white space.
-- Note that it is not worth worrying about special UTF_32 line
-- terminator characters in this context, since this is only about
-- error recovery anyway.
if Prev_Token = Tok_String_Literal then
loop
S1 := S1 + 1;
@ -121,6 +125,10 @@ package body Errutil is
-- by a line terminator, white space, a comment symbol or if we bump
-- into the following token (i.e. the current token)
-- Note that it is not worth worrying about special UTF_32 line
-- terminator characters in this context, since this is only about
-- error recovery anyway.
else
while Source (S1) not in Line_Terminator
and then Source (S1) /= ' '

View File

@ -4567,6 +4567,26 @@ This switch suppresses all optional warning messages, see remaining list
in this section for details on optional warning messages that can be
individually controlled.
@item -gnatwb
@emph{Activate warnings on bad fixed values.}
@cindex @option{-gnatwb} (@command{gcc})
@cindex Bad fixed values
@cindex Fixed-point Small value
@cindex Small value
This switch activates warnings for static fixed-point expressions whose
value is not an exact multiple of Small. Such values are implementation
dependent, since an implementation is free to choose either of the multiples
that surround the value. GNAT always chooses the closer one, but this is not
required behavior, and it is better to specify a value that is an exact
multiple, ensuring predictable execution. The default is that such warnings
are not generated.
@item -gnatwB
@emph{Suppress warnings on bad fixed values.}
@cindex @option{-gnatwB} (@command{gcc})
This switch suppresses warnings for static fixed-point expressions whose
value is not an exact multiple of Small.
@item -gnatwc
@emph{Activate warnings on conditionals.}
@cindex @option{-gnatwc} (@command{gcc})
@ -5341,6 +5361,12 @@ example:
@end smallexample
@end itemize
@item ^d^DOS_LINE_ENDINGS^
@emph{Check no DOS line terminators present.}
If the ^letter d^word NOCRLF^ appears in the string after @option{-gnaty}
then all lines must be terminated by a single ASCII.LF character (in
particular the DOS line terminator sequence CR/LF is not allowed).
@item ^e^END^
@emph{Check end/exit labels.}
If the ^letter e^word END^ appears in the string after @option{-gnaty} then
@ -14646,7 +14672,8 @@ Align @code{:=} in assignment statements
Align @code{=>} in associations
@item ^-A5^/ALIGN=COMPONENT_CLAUSES^
Align @code{at} keywords in the component clauses in record representation clauses
Align @code{at} keywords in the component clauses in record
representation clauses
@end table
@noindent
@ -15420,8 +15447,9 @@ the casing defined by the dictionary; no subwords are checked for this word
@item
for every subword @command{gnatpp} checks if the dictionary contains the
corresponding string of the form @code{*@var{simple_identifier}*}, and if it does, the
casing of this @var{simple_identifier} is used for this subword
corresponding string of the form @code{*@var{simple_identifier}*},
and if it does, the casing of this @var{simple_identifier} is used
for this subword
@item
if the whole name does not contain any ``_'' inside, and if for this name

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005 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- --
@ -1090,6 +1090,8 @@ package body Ch10 is
loop
exit when Loc = Token_Ptr;
-- Should we worry about UTF_32 line terminators here
if Source (Loc) in Line_Terminator then
Skip_Line_Terminators (Loc, Physical);
exit when Physical;

View File

@ -342,8 +342,14 @@ package body Scng is
Len : constant Int := Int (Scan_Ptr) - Int (Current_Line_Start);
begin
if Style_Check and Style_Check_Max_Line_Length then
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. Note that we take this from Opt.Max_Line_Length

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005 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- --
@ -265,6 +265,8 @@ package body Styleg is
S : Source_Ptr;
begin
-- Do we need to worry about UTF_32 line terminators here ???
S := Scan_Ptr + 3;
while Source (S) not in Line_Terminator loop
S := S + 1;
@ -461,6 +463,24 @@ package body Styleg is
end if;
end Check_Left_Paren;
---------------------------
-- Check_Line_Max_Length --
---------------------------
-- In check max line length mode (-gnatym), the line length must
-- not exceed the permitted maximum value.
procedure Check_Line_Max_Length (Len : Int) is
begin
if Style_Check_Max_Line_Length then
if Len > Style_Max_Line_Length then
Error_Msg
("(style) this line is too long",
Current_Line_Start + Source_Ptr (Style_Max_Line_Length));
end if;
end if;
end Check_Line_Max_Length;
---------------------------
-- Check_Line_Terminator --
---------------------------
@ -468,12 +488,12 @@ package body Styleg is
-- In check blanks at end mode (-gnatyb), lines may not end with a
-- trailing space.
-- In check max line length mode (-gnatym), the line length must
-- not exceed the permitted maximum value.
-- In check form feeds mode (-gnatyf), the line terminator may not
-- be either of the characters FF or VT.
-- In check DOS line terminators node (-gnatyd), the line terminator
-- must be a single LF, without a following CR.
procedure Check_Line_Terminator (Len : Int) is
S : Source_Ptr;
@ -483,18 +503,30 @@ package body Styleg is
if Style_Check_Form_Feeds then
if Source (Scan_Ptr) = ASCII.FF then
Error_Msg_S ("(style) form feed not allowed");
elsif Source (Scan_Ptr) = ASCII.VT then
Error_Msg_S ("(style) vertical tab not allowed");
end if;
end if;
-- We are now possibly going to check for trailing spaces and maximum
-- line length. There is no point in doing this if the current line is
-- empty. It is actually wrong in the case of trailing spaces, because
-- we scan backwards for this purpose, so we would end up looking at a
-- different line, or even at invalid buffer locations if we have the
-- first source line at hand.
-- Check DOS line terminator (ignore EOF, since we only get called
-- with an EOF if it is the last character in the buffer, and was
-- therefore not present in the sources
if Style_Check_DOS_Line_Terminator then
if Source (Scan_Ptr) = EOF then
null;
elsif Source (Scan_Ptr) /= LF
or else Source (Scan_Ptr + 1) = CR
then
Error_Msg_S ("(style) incorrect line terminator");
end if;
end if;
-- We are now possibly going to check for trailing spaces. There is no
-- point in doing this if the current line is empty. It is actually
-- wrong to do so, because we scan backwards for this purpose, so we
-- would end up looking at different line, or even at invalid buffer
-- locations if we have the first source line at hand.
if Len = 0 then
return;
@ -515,17 +547,6 @@ package body Styleg is
end if;
end if;
end if;
-- Check max line length
if Style_Check_Max_Line_Length then
if Len > Style_Max_Line_Length then
Error_Msg
("(style) this line is too long",
Current_Line_Start + Source_Ptr (Style_Max_Line_Length));
end if;
end if;
end Check_Line_Terminator;
--------------------------

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2004 Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005 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- --
@ -104,11 +104,15 @@ package Styleg is
procedure Check_Left_Paren;
-- Called after scanning out a left parenthesis to check spacing.
procedure Check_Line_Max_Length (Len : Int);
-- Called with Scan_Ptr pointing to the first line terminator character
-- terminating the current line. Used to check for appropriate line length.
-- The parameter Len is the length of the current line.
procedure Check_Line_Terminator (Len : Int);
-- Called with Scan_Ptr pointing to the first line terminator terminating
-- the current line, used to check for appropriate line terminator and
-- to check the line length (Len is the length of the current line).
-- Note that the terminator may be the EOF character.
-- the current line, used to check for appropriate line terminator usage.
-- The parameter Len is the length of the current line.
procedure Check_Pragma_Name;
-- The current token is a pragma identifier. Check that it is spelled

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005, 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- --
@ -34,25 +34,26 @@ package body Stylesw is
procedure Reset_Style_Check_Options is
begin
Style_Check_Indentation := 0;
Style_Check_Attribute_Casing := False;
Style_Check_Blanks_At_End := False;
Style_Check_Comments := False;
Style_Check_End_Labels := False;
Style_Check_Form_Feeds := False;
Style_Check_Horizontal_Tabs := False;
Style_Check_If_Then_Layout := False;
Style_Check_Keyword_Casing := False;
Style_Check_Layout := False;
Style_Check_Max_Line_Length := False;
Style_Check_Max_Nesting_Level := False;
Style_Check_Order_Subprograms := False;
Style_Check_Pragma_Casing := False;
Style_Check_References := False;
Style_Check_Specs := False;
Style_Check_Standard := False;
Style_Check_Tokens := False;
Style_Check_Xtra_Parens := False;
Style_Check_Indentation := 0;
Style_Check_Attribute_Casing := False;
Style_Check_Blanks_At_End := False;
Style_Check_Comments := False;
Style_Check_DOS_Line_Terminator := False;
Style_Check_End_Labels := False;
Style_Check_Form_Feeds := False;
Style_Check_Horizontal_Tabs := False;
Style_Check_If_Then_Layout := False;
Style_Check_Keyword_Casing := False;
Style_Check_Layout := False;
Style_Check_Max_Line_Length := False;
Style_Check_Max_Nesting_Level := False;
Style_Check_Order_Subprograms := False;
Style_Check_Pragma_Casing := False;
Style_Check_References := False;
Style_Check_Specs := False;
Style_Check_Standard := False;
Style_Check_Tokens := False;
Style_Check_Xtra_Parens := False;
end Reset_Style_Check_Options;
------------------------------
@ -107,6 +108,7 @@ package body Stylesw is
Add ('a', Style_Check_Attribute_Casing);
Add ('b', Style_Check_Blanks_At_End);
Add ('c', Style_Check_Comments);
Add ('d', Style_Check_DOS_Line_Terminator);
Add ('e', Style_Check_End_Labels);
Add ('f', Style_Check_Form_Feeds);
Add ('h', Style_Check_Horizontal_Tabs);
@ -186,31 +188,34 @@ package body Stylesw is
:= Character'Pos (C) - Character'Pos ('0');
when 'a' =>
Style_Check_Attribute_Casing := True;
Style_Check_Attribute_Casing := True;
when 'b' =>
Style_Check_Blanks_At_End := True;
Style_Check_Blanks_At_End := True;
when 'c' =>
Style_Check_Comments := True;
Style_Check_Comments := True;
when 'd' =>
Style_Check_DOS_Line_Terminator := True;
when 'e' =>
Style_Check_End_Labels := True;
Style_Check_End_Labels := True;
when 'f' =>
Style_Check_Form_Feeds := True;
Style_Check_Form_Feeds := True;
when 'h' =>
Style_Check_Horizontal_Tabs := True;
Style_Check_Horizontal_Tabs := True;
when 'i' =>
Style_Check_If_Then_Layout := True;
Style_Check_If_Then_Layout := True;
when 'k' =>
Style_Check_Keyword_Casing := True;
Style_Check_Keyword_Casing := True;
when 'l' =>
Style_Check_Layout := True;
Style_Check_Layout := True;
when 'L' =>
Style_Max_Nesting_Level := 0;
@ -242,11 +247,11 @@ package body Stylesw is
Style_Check_Max_Nesting_Level := Style_Max_Nesting_Level /= 0;
when 'm' =>
Style_Check_Max_Line_Length := True;
Style_Max_Line_Length := 79;
Style_Check_Max_Line_Length := True;
Style_Max_Line_Length := 79;
when 'n' =>
Style_Check_Standard := True;
Style_Check_Standard := True;
when 'N' =>
Reset_Style_Check_Options;
@ -281,22 +286,22 @@ package body Stylesw is
Style_Check_Max_Line_Length := Style_Max_Line_Length /= 0;
when 'o' =>
Style_Check_Order_Subprograms := True;
Style_Check_Order_Subprograms := True;
when 'p' =>
Style_Check_Pragma_Casing := True;
Style_Check_Pragma_Casing := True;
when 'r' =>
Style_Check_References := True;
Style_Check_References := True;
when 's' =>
Style_Check_Specs := True;
Style_Check_Specs := True;
when 't' =>
Style_Check_Tokens := True;
Style_Check_Tokens := True;
when 'x' =>
Style_Check_Xtra_Parens := True;
Style_Check_Xtra_Parens := True;
when ' ' =>
null;

View File

@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005, 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- --
@ -84,6 +84,11 @@ package Stylesw is
-- Note: the reason for the last two conditions is to allow "boxed"
-- comments where only a single space separates the comment characters.
Style_Check_DOS_Line_Terminator : Boolean := False;
-- This can be set true by using the -gnatg or -gnatyd switches. If
-- it is True, then the line terminator must be a single LF, without an
-- associated CR (e.g. DOS line terminator sequence CR/LF not allowed).
Style_Check_End_Labels : Boolean := False;
-- This can be set True by using the -gnatg or -gnatye switches. If
-- it is True, then optional END labels must always be present.
@ -242,7 +247,7 @@ package Stylesw is
procedure Set_Default_Style_Check_Options;
-- This procedure is called to set the default style checking options
-- in response to a -gnatg switch or -gnaty with no suboptions.
-- in response to a -gnaty switch with no suboptions.
procedure Set_Style_Check_Options
(Options : String;

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2004 Free Software Foundation, Inc. --
-- Copyright (C) 2001-2005 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- --
@ -485,7 +485,7 @@ package body Switch.C is
System_Extend_Unit := Empty;
Warning_Mode := Treat_As_Error;
-- Set default warnings (basically -gnatwa)
-- Set default warnings for -gnatg (same set as -gnatwa)
Check_Unreferenced := True;
Check_Unreferenced_Formals := True;
@ -493,6 +493,7 @@ package body Switch.C is
Constant_Condition_Warnings := True;
Implementation_Unit_Warnings := True;
Ineffective_Inline_Warnings := True;
Warn_On_Bad_Fixed_Value := True;
Warn_On_Constant := True;
Warn_On_Export_Import := True;
Warn_On_Modified_Unread := True;
@ -502,7 +503,7 @@ package body Switch.C is
Warn_On_Unchecked_Conversion := True;
Warn_On_Unrecognized_Pragma := True;
Set_Default_Style_Check_Options;
Set_Style_Check_Options ("3abcdefhiklmnprst");
-- Processing for G switch
@ -762,6 +763,7 @@ package body Switch.C is
Constant_Condition_Warnings := True;
Implementation_Unit_Warnings := True;
Ineffective_Inline_Warnings := True;
Warn_On_Bad_Fixed_Value := True;
Warn_On_Constant := True;
Warn_On_Export_Import := True;
Warn_On_Modified_Unread := True;
@ -779,6 +781,7 @@ package body Switch.C is
Elab_Warnings := False;
Implementation_Unit_Warnings := False;
Ineffective_Inline_Warnings := False;
Warn_On_Bad_Fixed_Value := False;
Warn_On_Constant := False;
Warn_On_Dereference := False;
Warn_On_Export_Import := False;
@ -790,6 +793,12 @@ package body Switch.C is
Warn_On_Unchecked_Conversion := False;
Warn_On_Unrecognized_Pragma := False;
when 'b' =>
Warn_On_Bad_Fixed_Value := True;
when 'B' =>
Warn_On_Bad_Fixed_Value := False;
when 'c' =>
Constant_Condition_Warnings := True;

View File

@ -346,6 +346,10 @@ begin
Write_Line ("Enable selected warning modes, xx = list of parameters:");
Write_Line (" a turn on all optional warnings (except d,h,l)");
Write_Line (" A turn off all optional warnings");
Write_Line (" b turn on warnings for bad fixed value " &
"(not multiple of small)");
Write_Line (" B* turn off warnings for bad fixed value " &
"(not multiple of small)");
Write_Line (" c turn on warnings for constant conditional");
Write_Line (" C* turn off warnings for constant conditional");
Write_Line (" d turn on warnings for implicit dereference");
@ -430,6 +434,7 @@ begin
Write_Line (" a check attribute casing");
Write_Line (" b check no blanks at end of lines");
Write_Line (" c check comment format");
Write_Line (" d check no DOS line terminators");
Write_Line (" e check end/exit labels present");
Write_Line (" f check no form feeds/vertical tabs in source");
Write_Line (" h check no horizontal tabs in source");

View File

@ -1800,6 +1800,8 @@ package VMS_Data is
"-gnatyb " &
"COMMENTS " &
"-gnatyc " &
"NOCRLF" &
"-gnatyd " &
"END " &
"-gnatye " &
"VTABS " &
@ -2357,6 +2359,10 @@ package VMS_Data is
"-gnatwA " &
"ALL_GCC " &
"-Wall " &
"BAD_FIXED_VALUES " &
"-gnatwb " &
"NO_BAD_FIXED_VALUES " &
"-gnatwB " &
"CONDITIONALS " &
"-gnatwc " &
"NOCONDITIONALS " &