From patchwork Thu Jan 6 17:13:18 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: 1576216 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yY2YRgzU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JVDB00vT1z9sXM for ; Fri, 7 Jan 2022 04:39:20 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F1E3F3858421 for ; Thu, 6 Jan 2022 17:39:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1E3F3858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641490758; bh=8NIOfYuiC9pKRiY9S5pLZ9ZCeLiVXRVR+gbAgW38l9k=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=yY2YRgzUyG4u+C7rI6fRJyE+q6BpFsyb6XwzIFkMKQpVargLqSnGUhbvZQhkq2DKp K+w+PcxWVlCxygLh66utUikyLHXZPV9uDSYWocAhG+hz1jnWdn4kAE+7AIbSg/KzdW up5qYrtXbbWBrhahMGR35hUjATLcNtk4K2HO7Hgc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 897A3385800A for ; Thu, 6 Jan 2022 17:13:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 897A3385800A Received: by mail-wm1-x32b.google.com with SMTP id f134-20020a1c1f8c000000b00345c05bc12dso1551421wmf.3 for ; Thu, 06 Jan 2022 09:13:20 -0800 (PST) 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=8NIOfYuiC9pKRiY9S5pLZ9ZCeLiVXRVR+gbAgW38l9k=; b=bnBDj4yNojWME59ePYOglagqsPFFvnAOd1ZYTZGjrzukYhvxWoXG+CBXeTtu6xSpAH IHP7lLrifl1NE+aK6xvziTS8Au6K7GJEJVzWL8Uyk9uoMKHbER+3y7tHpz8WrhPivhrB zinHNmL5tlCid7KiqDluqS1WKpjAZGY7M+THYK8NgJP8ZCFh3sApxZ9iQ1R/3QeG0wS6 9YuAFWH7dSazTQqyGH48uchkI5iGe++22+vMTw2DJthaqzEBYrnlHPQDv4vM18epgSEA qtorDD62le1p/RY455SHiYbY1T7HaduIYTB3ucseWDfPKat39AGAm7yJg32fE+2gOFmB RVug== X-Gm-Message-State: AOAM530qD/SJB0o2r0Nvk1NwnbVLAeX7BL/5FiSC4jaMfSQUYojxfPkE yPqFKESYA0D0fS3xQNxzCOEiiNnxcuneOw== X-Google-Smtp-Source: ABdhPJyArO0DBG+Vkdu6zng4WtZdrO907ESnLrFpI+0bdRiWkSwMR7PVs/rMfXnDe6frZ/GKTGKKEg== X-Received: by 2002:a1c:1f83:: with SMTP id f125mr7781560wmf.181.1641489199571; Thu, 06 Jan 2022 09:13:19 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id t8sm1582357wmq.19.2022.01.06.09.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 09:13:18 -0800 (PST) Date: Thu, 6 Jan 2022 17:13:18 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Remove unnecessary declare block Message-ID: <20220106171318.GA2921855@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Piotr Trojanek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Code cleanup related to handling of warnings-as-errors. Semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * errout.adb (Adjust_Name_Case): Remove unnecessary declare block. diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb --- a/gcc/ada/errout.adb +++ b/gcc/ada/errout.adb @@ -3391,60 +3391,57 @@ package body Errout is (Buf : in out Bounded_String; Loc : Source_Ptr) is + Src_Ind : constant Source_File_Index := Get_Source_File_Index (Loc); + Sbuffer : Source_Buffer_Ptr; + Ref_Ptr : Integer; + Src_Ptr : Source_Ptr; + begin -- We have an all lower case name from Namet, and now we want to set -- the appropriate case. If possible we copy the actual casing from -- the source. If not we use standard identifier casing. - declare - Src_Ind : constant Source_File_Index := Get_Source_File_Index (Loc); - Sbuffer : Source_Buffer_Ptr; - Ref_Ptr : Integer; - Src_Ptr : Source_Ptr; + Ref_Ptr := 1; + Src_Ptr := Loc; - begin - Ref_Ptr := 1; - Src_Ptr := Loc; + -- For standard locations, always use mixed case - -- For standard locations, always use mixed case + if Loc <= No_Location then + Set_Casing (Buf, Mixed_Case); - if Loc <= No_Location then - Set_Casing (Buf, Mixed_Case); + else + -- Determine if the reference we are dealing with corresponds to text + -- at the point of the error reference. This will often be the case + -- for simple identifier references, and is the case where we can + -- copy the casing from the source. + + Sbuffer := Source_Text (Src_Ind); + + while Ref_Ptr <= Buf.Length loop + exit when + Fold_Lower (Sbuffer (Src_Ptr)) /= + Fold_Lower (Buf.Chars (Ref_Ptr)); + Ref_Ptr := Ref_Ptr + 1; + Src_Ptr := Src_Ptr + 1; + end loop; - else - -- Determine if the reference we are dealing with corresponds to - -- text at the point of the error reference. This will often be - -- the case for simple identifier references, and is the case - -- where we can copy the casing from the source. + -- If we get through the loop without a mismatch, then output the + -- name the way it is cased in the source program. - Sbuffer := Source_Text (Src_Ind); + if Ref_Ptr > Buf.Length then + Src_Ptr := Loc; - while Ref_Ptr <= Buf.Length loop - exit when - Fold_Lower (Sbuffer (Src_Ptr)) /= - Fold_Lower (Buf.Chars (Ref_Ptr)); - Ref_Ptr := Ref_Ptr + 1; + for J in 1 .. Buf.Length loop + Buf.Chars (J) := Sbuffer (Src_Ptr); Src_Ptr := Src_Ptr + 1; end loop; - -- If we get through the loop without a mismatch, then output the - -- name the way it is cased in the source program - - if Ref_Ptr > Buf.Length then - Src_Ptr := Loc; + -- Otherwise set the casing using the default identifier casing - for J in 1 .. Buf.Length loop - Buf.Chars (J) := Sbuffer (Src_Ptr); - Src_Ptr := Src_Ptr + 1; - end loop; - - -- Otherwise set the casing using the default identifier casing - - else - Set_Casing (Buf, Identifier_Casing (Src_Ind)); - end if; + else + Set_Casing (Buf, Identifier_Casing (Src_Ind)); end if; - end; + end if; end Adjust_Name_Case; ---------------------------