]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Casing style on record components
authorBob Duff <duff@adacore.com>
Thu, 7 Apr 2022 14:59:32 +0000 (10:59 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 19 May 2022 14:05:28 +0000 (14:05 +0000)
This patch fixes a bug where the -gnatyr switch fails to detect
incorrect casing of record components.

gcc/ada/

* style.adb (Check_Identifier): Deal with the case where a
record component definition has been transformed; we want to
warn if the original came from source.
* libgnat/s-objrea.ads, libgnat/s-objrea.adb: Fix casing of MF
to be consistent.
* uname.adb: Fix casing of Chars to be consistent.
* sem_util.ads: Minor comment fix.

gcc/ada/libgnat/s-objrea.adb
gcc/ada/libgnat/s-objrea.ads
gcc/ada/sem_util.ads
gcc/ada/style.adb
gcc/ada/uname.adb

index 854bbb290e4b52d30c745e5ff250714f717314b8..843ccf5915a349c8163893bc5464c00be068d5c6 100644 (file)
@@ -979,7 +979,7 @@ package body System.Object_Reader is
 
          --  Map section table
 
-         Opt_Stream := Create_Stream (Res.Mf, Signature_Loc_Offset, 4);
+         Opt_Stream := Create_Stream (Res.MF, Signature_Loc_Offset, 4);
          Hdr_Offset := Offset (uint32'(Read (Opt_Stream)));
          Close (Opt_Stream);
          Res.Sectab_Stream := Create_Stream
@@ -999,7 +999,7 @@ package body System.Object_Reader is
                Opt_32 : Optional_Header_PE32;
             begin
                Opt_Stream := Create_Stream
-                 (Res.Mf, Opt_Offset, Opt_32'Size / SSU);
+                 (Res.MF, Opt_Offset, Opt_32'Size / SSU);
                Read_Raw
                  (Opt_Stream, Opt_32'Address, uint32 (Opt_32'Size / SSU));
                Res.ImageBase := uint64 (Opt_32.ImageBase);
@@ -1011,7 +1011,7 @@ package body System.Object_Reader is
                Opt_64 : Optional_Header_PE64;
             begin
                Opt_Stream := Create_Stream
-                 (Res.Mf, Opt_Offset, Opt_64'Size / SSU);
+                 (Res.MF, Opt_Offset, Opt_64'Size / SSU);
                Read_Raw
                  (Opt_Stream, Opt_64'Address, uint32 (Opt_64'Size / SSU));
                Res.ImageBase := Opt_64.ImageBase;
@@ -1367,7 +1367,7 @@ package body System.Object_Reader is
          Strtab_Sz : uint32;
 
       begin
-         Res.Mf := F;
+         Res.MF := F;
          Res.In_Exception := In_Exception;
 
          Res.Arch := PPC;
@@ -1515,14 +1515,14 @@ package body System.Object_Reader is
    end Arch;
 
    function Create_Stream
-     (Mf : Mapped_File;
+     (MF : Mapped_File;
       File_Offset : File_Size;
       File_Length : File_Size)
      return Mapped_Stream
    is
       Region : Mapped_Region;
    begin
-      Read (Mf, Region, File_Offset, File_Length, False);
+      Read (MF, Region, File_Offset, File_Length, False);
       return (Region, 0, Offset (File_Length));
    end Create_Stream;
 
@@ -1531,7 +1531,7 @@ package body System.Object_Reader is
       Sec : Object_Section) return Mapped_Stream
    is
    begin
-      return Create_Stream (Obj.Mf, File_Size (Sec.Off), File_Size (Sec.Size));
+      return Create_Stream (Obj.MF, File_Size (Sec.Off), File_Size (Sec.Size));
    end Create_Stream;
 
    procedure Tell (Obj : in out Mapped_Stream; Off : out Offset) is
@@ -1573,7 +1573,7 @@ package body System.Object_Reader is
             null;
       end case;
 
-      Close (Obj.Mf);
+      Close (Obj.MF);
    end Close;
 
    ------------------------
index fc440ffc5db1dab58dae2e1d5f947b83ca1f3b71..ee72114819bb76073c1251078e2079048a94a47a 100644 (file)
@@ -187,7 +187,7 @@ package System.Object_Reader is
    type Mapped_Stream is private;
    --  Provide an abstraction of a stream on a memory mapped file
 
-   function Create_Stream (Mf : System.Mmap.Mapped_File;
+   function Create_Stream (MF : System.Mmap.Mapped_File;
                            File_Offset : System.Mmap.File_Size;
                            File_Length : System.Mmap.File_Size)
                           return Mapped_Stream;
@@ -381,7 +381,7 @@ private
    subtype Any_PECOFF is Object_Format range PECOFF .. PECOFF_PLUS;
 
    type Object_File (Format : Object_Format) is record
-      Mf   : System.Mmap.Mapped_File := System.Mmap.Invalid_Mapped_File;
+      MF   : System.Mmap.Mapped_File := System.Mmap.Invalid_Mapped_File;
       Arch : Object_Arch := Unknown;
 
       Num_Sections : uint32 := 0;
index f9903b8ebdd6c8990abb10261942e85eac1e5c34..1eca815c9d69dd789369eb27ff0d8cf5d4a7e821 100644 (file)
@@ -3169,9 +3169,8 @@ package Sem_Util is
    --  This procedure has the same calling sequence as Set_Entity, but it
    --  performs additional checks as follows:
    --
-   --    If Style_Check is set, then it calls a style checking routine which
-   --    can check identifier spelling style. This procedure also takes care
-   --    of checking the restriction No_Implementation_Identifiers.
+   --    If Style_Check is set, then it calls a style checking routine that
+   --    can check identifier spelling style.
    --
    --    If restriction No_Abort_Statements is set, then it checks that the
    --    entity is not Ada.Task_Identification.Abort_Task.
index 60bfc9370f9a38d0b9d6b6dc98075eb3467f851e..cf7bc19980b57ef2c82b481e6ea50d97be016b5e 100644 (file)
@@ -126,9 +126,14 @@ package body Style is
       elsif Error_Posted (Ref) or else Error_Posted (Def) then
          return;
 
-      --  Case of definition comes from source
+      --  Case of definition comes from source, or a record component whose
+      --  Original_Record_Component comes from source.
 
-      elsif Comes_From_Source (Def) then
+      elsif Comes_From_Source (Def) or else
+        (Ekind (Def) in Record_Field_Kind
+           and then Present (Original_Record_Component (Def))
+           and then Comes_From_Source (Original_Record_Component (Def)))
+      then
 
          --  Check same casing if we are checking references
 
index 60ef2b6686a36c800e17d11e7d56bc06f5160812..200c036eee5df796c701c0340b8dff7e70d0bbb4 100644 (file)
@@ -715,7 +715,7 @@ package body Uname is
       Buf : Bounded_String;
    begin
       Get_Unit_Name_String (Buf, N);
-      Write_Str (Buf.chars (1 .. Buf.Length));
+      Write_Str (Buf.Chars (1 .. Buf.Length));
    end Write_Unit_Name;
 
    -------------------------------