Casing issues are not detected when using `-gnaty` if the keyword does
not start with a capital letter. This is fixed by checking if any letter
in the keywoard is uppercase.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

        * scng.adb (Scan): Check if any letter of the token is
        uppercase.
diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb
--- a/gcc/ada/scng.adb
+++ b/gcc/ada/scng.adb
@@ -1180,6 +1180,8 @@ package body Scng is
          end if;
       end Start_Of_Wide_Character;
 
+      Token_Contains_Uppercase : Boolean;
+
    --  Start of processing for Scan
 
    begin
@@ -1241,6 +1243,8 @@ package body Scng is
 
          Token_Ptr := Scan_Ptr;
 
+         Token_Contains_Uppercase := False;
+
          --  Here begins the main case statement which transfers control on the
          --  basis of the non-blank character we have encountered.
 
@@ -1999,6 +2003,7 @@ package body Scng is
          --  Upper case letters
 
          when 'A' .. 'Z' =>
+            Token_Contains_Uppercase := True;
             Name_Len := 1;
             Underline_Found := False;
             Name_Buffer (1) :=
@@ -2347,6 +2352,8 @@ package body Scng is
                Accumulate_Checksum (Source (Scan_Ptr));
 
             elsif Source (Scan_Ptr) in 'A' .. 'Z' then
+               Token_Contains_Uppercase := True;
+
                Name_Buffer (Name_Len + 1) :=
                  Character'Val (Character'Pos (Source (Scan_Ptr)) + 32);
                Accumulate_Checksum (Name_Buffer (Name_Len + 1));
@@ -2601,7 +2608,7 @@ package body Scng is
                --  Ada 2005 (AI-340): Do not apply the style check in case of
                --  MOD attribute.
 
-               if Source (Token_Ptr) <= 'Z'
+               if Token_Contains_Uppercase
                  and then (Prev_Token /= Tok_Apostrophe
                            or else
                              (Token /= Tok_Access and then


Reply via email to