This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Fix incorrect style warning
- To: gcc-patches at gcc dot gnu dot org
- Subject: [Ada] Fix incorrect style warning
- From: bosch at gnat dot com
- Date: Tue, 30 Oct 2001 19:54:16 -0500 (EST)
Tested on GNU Linux/x86.
-Geert
2001-10-30 Robert Dewar <dewar@gnat.com>
* style.adb:
(Check_Identifier): Rewrite circuit to be compatible with use of letters
in the upper half of ASCII.
(Check_Identifier): Minor reformatting
*** style.adb 2001/02/05 16:26:14 1.48
--- style.adb 2001/10/14 14:18:51 1.49
***************
*** 409,418 ****
(Ref : Node_Or_Entity_Id;
Def : Node_Or_Entity_Id)
is
! SRef : Source_Ptr := Sloc (Ref);
! SDef : Source_Ptr := Sloc (Def);
! TRef : Source_Buffer_Ptr;
! TDef : Source_Buffer_Ptr;
Nlen : Nat;
Cas : Casing_Type;
--- 409,418 ----
(Ref : Node_Or_Entity_Id;
Def : Node_Or_Entity_Id)
is
! Sref : Source_Ptr := Sloc (Ref);
! Sdef : Source_Ptr := Sloc (Def);
! Tref : Source_Buffer_Ptr;
! Tdef : Source_Buffer_Ptr;
Nlen : Nat;
Cas : Casing_Type;
***************
*** 429,473 ****
-- Check same casing if we are checking references
if Style_Check_References then
! TRef := Source_Text (Get_Source_File_Index (SRef));
! TDef := Source_Text (Get_Source_File_Index (SDef));
-- Ignore operator name case completely. This also catches the
-- case of where one is an operator and the other is not. This
-- is a phenomenon from rewriting of operators as functions,
-- and is to be ignored.
! if TRef (SRef) = '"' or else TDef (SDef) = '"' then
return;
else
! for J in 1 .. Length_Of_Name (Chars (Ref)) loop
! if TRef (SRef) /= TDef (SDef) then
! Error_Msg_Node_1 := Def;
! Error_Msg_Sloc := Sloc (Def);
! Error_Msg
! ("(style) bad casing of & declared#", SRef);
return;
- end if;
! SRef := SRef + 1;
! SDef := SDef + 1;
end loop;
end if;
end if;
-- Case of definition in package Standard
! elsif SDef = Standard_Location then
-- Check case of identifiers in Standard
if Style_Check_Standard then
! TRef := Source_Text (Get_Source_File_Index (SRef));
-- Ignore operators
! if TRef (SRef) = '"' then
null;
-- Special case of ASCII
--- 429,494 ----
-- Check same casing if we are checking references
if Style_Check_References then
! Tref := Source_Text (Get_Source_File_Index (Sref));
! Tdef := Source_Text (Get_Source_File_Index (Sdef));
-- Ignore operator name case completely. This also catches the
-- case of where one is an operator and the other is not. This
-- is a phenomenon from rewriting of operators as functions,
-- and is to be ignored.
! if Tref (Sref) = '"' or else Tdef (Sdef) = '"' then
return;
else
! while Tref (Sref) = Tdef (Sdef) loop
!
! -- If end of identifier, all done
!
! if not Identifier_Char (Tref (Sref)) then
return;
! -- Otherwise loop continues
!
! else
! Sref := Sref + 1;
! Sdef := Sdef + 1;
! end if;
end loop;
+
+ -- Fall through loop when mismatch between identifiers
+ -- If either identifier is not terminated, error.
+
+ if Identifier_Char (Tref (Sref))
+ or else
+ Identifier_Char (Tdef (Sdef))
+ then
+ Error_Msg_Node_1 := Def;
+ Error_Msg_Sloc := Sloc (Def);
+ Error_Msg
+ ("(style) bad casing of & declared#", Sref);
+ return;
+
+ -- Else end of identifiers, and they match
+
+ else
+ return;
+ end if;
end if;
end if;
-- Case of definition in package Standard
! elsif Sdef = Standard_Location then
-- Check case of identifiers in Standard
if Style_Check_Standard then
! Tref := Source_Text (Get_Source_File_Index (Sref));
-- Ignore operators
! if Tref (Sref) = '"' then
null;
-- Special case of ASCII
***************
*** 491,497 ****
Nlen := Length_Of_Name (Chars (Ref));
if Determine_Casing
! (TRef (SRef .. SRef + Source_Ptr (Nlen) - 1)) = Cas
then
null;
else
--- 512,518 ----
Nlen := Length_Of_Name (Chars (Ref));
if Determine_Casing
! (Tref (Sref .. Sref + Source_Ptr (Nlen) - 1)) = Cas
then
null;
else