[gcc r11-4251] [Ada] Fix parser not detecting casing issues in keywords

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Thu Oct 22 12:13:30 GMT 2020


https://gcc.gnu.org/g:e354dca60268ea14f3b20fb865b23e27af751022

commit r11-4251-ge354dca60268ea14f3b20fb865b23e27af751022
Author: Ghjuvan Lacambre <lacambre@adacore.com>
Date:   Thu Aug 20 17:17:39 2020 +0200

    [Ada] Fix parser not detecting casing issues in keywords
    
    gcc/ada/
    
            * scng.adb (Scan): Check if any letter of the token is
            uppercase.

Diff:
---
 gcc/ada/scng.adb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/scng.adb b/gcc/ada/scng.adb
index 162d8829fa7..0d5cff84d5d 100644
--- 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


More information about the Gcc-cvs mailing list