public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Casing style on record components
@ 2022-05-19 14:15 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-05-19 14:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bob Duff

[-- Attachment #1: Type: text/plain, Size: 497 bytes --]

This patch fixes a bug where the -gnatyr switch fails to detect
incorrect casing of record components.

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

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.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 5570 bytes --]

diff --git a/gcc/ada/libgnat/s-objrea.adb b/gcc/ada/libgnat/s-objrea.adb
--- a/gcc/ada/libgnat/s-objrea.adb
+++ b/gcc/ada/libgnat/s-objrea.adb
@@ -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;
 
    ------------------------


diff --git a/gcc/ada/libgnat/s-objrea.ads b/gcc/ada/libgnat/s-objrea.ads
--- a/gcc/ada/libgnat/s-objrea.ads
+++ b/gcc/ada/libgnat/s-objrea.ads
@@ -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;


diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -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.


diff --git a/gcc/ada/style.adb b/gcc/ada/style.adb
--- a/gcc/ada/style.adb
+++ b/gcc/ada/style.adb
@@ -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
 


diff --git a/gcc/ada/uname.adb b/gcc/ada/uname.adb
--- a/gcc/ada/uname.adb
+++ b/gcc/ada/uname.adb
@@ -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;
 
    -------------------------------



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

only message in thread, other threads:[~2022-05-19 14:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 14:15 [Ada] Casing style on record components 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).