-- 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;
-- 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
-- S1 is now set to the location for the flag
Error_Msg (Msg, S1);
-
end Error_Msg_AP;
------------------
-- --
-- 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- --
-- 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;
-- 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) /= ' '
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})
@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
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
@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
-- --
-- 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- --
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;
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
-- --
-- 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- --
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;
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 --
---------------------------
-- 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;
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;
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;
--------------------------
-- --
-- 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- --
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
-- --
-- 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- --
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;
------------------------------
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);
:= 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;
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;
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;
-- --
-- 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- --
-- 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.
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;
-- --
-- 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- --
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;
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;
Warn_On_Unchecked_Conversion := True;
Warn_On_Unrecognized_Pragma := True;
- Set_Default_Style_Check_Options;
+ Set_Style_Check_Options ("3abcdefhiklmnprst");
-- Processing for G switch
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;
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;
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;
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");
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");
"-gnatyb " &
"COMMENTS " &
"-gnatyc " &
+ "NOCRLF" &
+ "-gnatyd " &
"END " &
"-gnatye " &
"VTABS " &
"-gnatwA " &
"ALL_GCC " &
"-Wall " &
+ "BAD_FIXED_VALUES " &
+ "-gnatwb " &
+ "NO_BAD_FIXED_VALUES " &
+ "-gnatwB " &
"CONDITIONALS " &
"-gnatwc " &
"NOCONDITIONALS " &