From patchwork Thu May 19 14:15:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 54210 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CAF493877020 for ; Thu, 19 May 2022 14:20:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAF493877020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652970020; bh=SAHruuncFMujUd26toVtFIcN7YDERsDmdKsIsa8z9wo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gbHp5ASLnhp1J4zVemKJC1+hafWglCUQ1HSegg4TGFceCE9pGid3YEUXTP2A1gJUE KMDdwGkWZ5lPAXdUyiUN3GcVDkoJIAcYTe2Xsqt2UFxjXrTANvOCg24nGq+X5ZQ/OQ my7ys0OzamTo6fc3K18qjR/1bW+66pCyOqr+1clY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by sourceware.org (Postfix) with ESMTPS id 34CB1383D800 for ; Thu, 19 May 2022 14:16:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 34CB1383D800 Received: by mail-wr1-x429.google.com with SMTP id t6so7383452wra.4 for ; Thu, 19 May 2022 07:16:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=SAHruuncFMujUd26toVtFIcN7YDERsDmdKsIsa8z9wo=; b=KewkyXp9GVEViM5lgYtZOgNkdqZPr1c2uNOWDUK3UqmjsPXPIAMBekHBp95wHCUP24 DnY9ozHM7nnOFYXkcVaMAHATzMoBpHbe+extVdYWwawoWAvjHYAeoj4o1Q+MVQxjv5oN 9M1NL97cvHVIb0C2PS9KJGCGaVrpaWYGvd5EnyVSijjJkjR6GUj1Jud0/GHabWX72hMD aDSelo0LqW2ea5AzQBB2B7UeoBShXVYEfjvtFNzKZr9Dpzz85Kex5HJ+erzqcUj9dDfV LL3NHGCW/owN023kVJbka0Z063EyVtmpsJCE1Glmo2LtA/RjcEU+wzGDuX5ZJuqpMaUV mh1w== X-Gm-Message-State: AOAM533og7GxkxIqt3y+krK/KtNj2JkPMkiQWAI5qIl0Gr1bmx1EaEYx BT9qNB/x16QvEE5jaZsD++OfX8898fUtnw== X-Google-Smtp-Source: ABdhPJy6L+12IC/LUdkbisdd1BscAAa5uK5Dq9zYbke8cxNvda1N/JLhZV1MXyq8SwCxU5g7lR6r3w== X-Received: by 2002:a05:6000:154b:b0:20c:4ca6:6f18 with SMTP id 11-20020a056000154b00b0020c4ca66f18mr4291651wry.704.1652969757976; Thu, 19 May 2022 07:15:57 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id r30-20020adfb1de000000b0020c5253d90csm5071554wra.88.2022.05.19.07.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 07:15:57 -0700 (PDT) Date: Thu, 19 May 2022 14:15:56 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Casing style on record components Message-ID: <20220519141556.GA3723121@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Bob Duff Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. 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; -------------------------------