public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1898] [Ada] Fix the -gnatyr switch so it works in record rep clauses
@ 2021-06-29 14:26 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-06-29 14:26 UTC (permalink / raw)
  To: gcc-cvs

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

commit r12-1898-gbfe2554f052b11ecf07d93cb04137f3fca5c6e6d
Author: Bob Duff <duff@adacore.com>
Date:   Sun Apr 18 09:45:04 2021 -0400

    [Ada] Fix the -gnatyr switch so it works in record rep clauses
    
    gcc/ada/
    
            * sem_ch13.adb (Analyze_Record_Representation_Clause): Call
            Set_Entity_With_Checks instead of Set_Entity, so we perform the
            check for correct casing.
            * style.adb (Check_Identifier): Minor comment improvement.
            Cleanup overly complicated code.

Diff:
---
 gcc/ada/sem_ch13.adb |  2 +-
 gcc/ada/style.adb    | 50 ++++++++++++++++++++++----------------------------
 2 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index d7667f27026..dcd5954851a 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -8561,7 +8561,7 @@ package body Sem_Ch13 is
 
                      Generate_Reference
                        (Comp, Component_Name (CC), Set_Ref => False);
-                     Set_Entity (Component_Name (CC), Comp);
+                     Set_Entity_With_Checks (Component_Name (CC), Comp);
 
                      --  Update Fbit and Lbit to the actual bit number
 
diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb
index a34d3e01822..1409cc61d19 100644
--- a/gcc/ada/style.adb
+++ b/gcc/ada/style.adb
@@ -136,48 +136,42 @@ package body Style is
             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.
+            --  Ignore case of operator names. This also catches the case
+            --  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
+               loop
+                  --  If end of identifiers, all done. Note that they are the
+                  --  same length.
 
-                  --  If end of identifier, all done
+                  pragma Assert
+                    (Identifier_Char (Tref (Sref)) =
+                     Identifier_Char (Tdef (Sdef)));
 
                   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.
+                  --  Case mismatch
 
-               if Identifier_Char (Tref (Sref))
-                    or else
-                  Identifier_Char (Tdef (Sdef))
-               then
-                  Error_Msg_Node_1 := Def;
-                  Error_Msg_Sloc := Sloc (Def);
-                  Error_Msg -- CODEFIX
-                    ("(style) bad casing of & declared#", Sref, Ref);
-                  return;
+                  if Tref (Sref) /= Tdef (Sdef) then
+                     Error_Msg_Node_1 := Def;
+                     Error_Msg_Sloc := Sloc (Def);
+                     Error_Msg -- CODEFIX
+                       ("(style) bad casing of & declared#", Sref, Ref);
+                     return;
+                  end if;
 
-               --  Else end of identifiers, and they match
+                  Sref := Sref + 1;
+                  Sdef := Sdef + 1;
+               end loop;
 
-               else
-                  return;
-               end if;
+               pragma Assert (False);
             end if;
          end if;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-29 14:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-29 14:26 [gcc r12-1898] [Ada] Fix the -gnatyr switch so it works in record rep clauses Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).