+2019-07-03 Bob Duff <duff@adacore.com>
+
+ * par-ch3.adb (P_Defining_Identifier): Call
+ Check_Defining_Identifier_Casing.
+ * style.ads, styleg.ads, styleg.adb
+ (Check_Defining_Identifier_Casing): New procedure to check for
+ mixed-case defining identifiers.
+ * stylesw.ads, stylesw.adb (Style_Check_Mixed_Case_Decls): New
+ flag for checking for mixed-case defining identifiers.
+ * doc/gnat_ugn/building_executable_programs_with_gnat.rst:
+ Document new feature.
+ * gnat_ugn.texi: Regenerate.
+
2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
* doc/gnat_ugn/building_executable_programs_with_gnat.rst
allowed).
+.. index:: -gnatyD (gcc)
+
+:switch:`-gnatyD`
+ *Check declared identifiers in mixed case.*
+
+ Declared identifiers must be in mixed case, as in
+ This_Is_An_Identifier. Use -gnatyr in addition to ensure
+ that references match declarations.
+
+
.. index:: -gnatye (gcc)
:switch:`-gnatye`
allowed).
@end table
+@geindex -gnatyD (gcc)
+
+
+@table @asis
+
+@item @code{-gnatyD}
+
+@emph{Check declared identifiers in mixed case.}
+
+Declared identifiers must be in mixed case, as in
+This_Is_An_Identifier. Use -gnatyr in addition to ensure
+that references match declarations.
+@end table
+
@geindex -gnatye (gcc)
raise Error_Resync;
end if;
+ if Style_Check then
+ Style.Check_Defining_Identifier_Casing;
+ end if;
+
Ident_Node := Token_Node;
- Scan; -- past the reserved identifier
+ Scan; -- past the identifier
-- If we already have a defining identifier, clean it out and make
-- a new clean identifier. This situation arises in some error cases
-- Called with Scan_Ptr pointing to the first minus sign of a comment.
-- Intended for checking any specific rules for comment placement/format.
+ procedure Check_Defining_Identifier_Casing
+ renames Style_Inst.Check_Defining_Identifier_Casing;
+
procedure Check_Dot_Dot
renames Style_Inst.Check_Dot_Dot;
-- Called after scanning out dot dot to check spacing
-- lower case letters. On entry Token_Ptr points to the keyword token.
-- This is not used for keywords appearing as attribute designators,
-- where instead Check_Attribute_Name (True) is called.
+
end Style;
end if;
end Check_Comment;
+ --------------------------------------
+ -- Check_Defining_Identifier_Casing --
+ --------------------------------------
+
+ procedure Check_Defining_Identifier_Casing is
+ begin
+ if Style_Check_Mixed_Case_Decls then
+ case Determine_Token_Casing is
+ when All_Upper_Case | All_Lower_Case =>
+ Error_Msg_SC -- CODEFIX
+ ("(style) bad capitalization, mixed case required");
+
+ -- The Unknown case is something like A_B_C, which is both all
+ -- caps and mixed case.
+
+ when Mixed_Case | Unknown =>
+ null; -- OK
+ end case;
+ end if;
+ end Check_Defining_Identifier_Casing;
+
-------------------
-- Check_Dot_Dot --
-------------------
-- Called with Scan_Ptr pointing to the first minus sign of a comment.
-- Intended for checking any specific rules for comment placement/format.
+ procedure Check_Defining_Identifier_Casing;
+ -- The current token is an identifier that will be a defining
+ -- identifier. Check that it is mixed case, if the appropriate
+ -- switch is set.
+
procedure Check_Dot_Dot;
-- Called after scanning out dot dot to check spacing
Style_Check_Boolean_And_Or := False;
Style_Check_Comments := False;
Style_Check_DOS_Line_Terminator := False;
+ Style_Check_Mixed_Case_Decls := False;
Style_Check_End_Labels := False;
Style_Check_Form_Feeds := False;
Style_Check_Horizontal_Tabs := False;
end if;
Add ('d', Style_Check_DOS_Line_Terminator);
+ Add ('D', Style_Check_Mixed_Case_Decls);
Add ('e', Style_Check_End_Labels);
Add ('f', Style_Check_Form_Feeds);
Add ('h', Style_Check_Horizontal_Tabs);
when 'd' =>
Style_Check_DOS_Line_Terminator := True;
+ when 'D' =>
+ Style_Check_Mixed_Case_Decls := True;
+
when 'e' =>
Style_Check_End_Labels := True;
when 'd' =>
Style_Check_DOS_Line_Terminator := False;
+ when 'D' =>
+ Style_Check_Mixed_Case_Decls := False;
+
when 'e' =>
Style_Check_End_Labels := False;
-- the line terminator must be a single LF, without an associated CR (e.g.
-- DOS line terminator sequence CR/LF not allowed).
+ Style_Check_Mixed_Case_Decls : Boolean := False;
+ -- This can be set True by using the -gnatyD switch. If it is True, then
+ -- declared identifiers must be in Mixed_Case.
+
Style_Check_End_Labels : Boolean := False;
-- This can be set True by using the -gnatye switch. If it is True, then
-- optional END labels must always be present.