From patchwork Fri May 7 09:38:23 2021 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: 1475429 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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@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 ozlabs.org (Postfix) with ESMTPS id 4Fc54x5v3qz9sj5 for ; Fri, 7 May 2021 19:39:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A1223938C21; Fri, 7 May 2021 09:38:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 82C6F3893672 for ; Fri, 7 May 2021 09:38:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 82C6F3893672 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=derodat@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B3DA756356; Fri, 7 May 2021 05:38:25 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RGB3KBHJFtWU; Fri, 7 May 2021 05:38:25 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 788C456361; Fri, 7 May 2021 05:38:23 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id 77AE9FA; Fri, 7 May 2021 05:38:23 -0400 (EDT) Date: Fri, 7 May 2021 05:38:23 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Small cleanup in C header file Message-ID: <20210507093823.GA140715@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Eric Botcazou Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This fixes a few deviations from the GCC Coding Conventions, differences between declarations and definitions of functions and minor other things. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * atree.h (Parent): Remove duplicate declaration. (Get_1_Bit_Field): Also use INLINE specifier in the declaration, fix formatting and use gcc_unreachable for the default case. (Get_2_Bit_Field): Likewise. (Get_4_Bit_Field): Likewise. (Get_8_Bit_Field): Likewise. (Get_32_Bit_Field): Likewise. (Get_32_Bit_Field_With_Default): Likewise. diff --git a/gcc/ada/atree.h b/gcc/ada/atree.h --- a/gcc/ada/atree.h +++ b/gcc/ada/atree.h @@ -41,14 +41,14 @@ extern Node_Id Parent (Node_Id); #define Original_Node atree__original_node extern Node_Id Original_Node (Node_Id); -/* Type used for union of Node_Id, List_Id, Elist_Id. */ +/* Type used for union of Node_Id, List_Id, Elist_Id. */ typedef Int Tree_Id; /* These two functions can only be used for Node_Id and List_Id values and they work in the C version because Empty = No_List = 0. */ -static Boolean No (Tree_Id); -static Boolean Present (Tree_Id); +INLINE Boolean No (Tree_Id); +INLINE Boolean Present (Tree_Id); INLINE Boolean No (Tree_Id N) @@ -62,33 +62,32 @@ Present (Tree_Id N) return !No (N); } -extern Node_Id Parent (Tree_Id); - #define Current_Error_Node atree__current_error_node extern Node_Id Current_Error_Node; -// The following code corresponds to the Get_n_Bit_Field functions (for -// various n) in package Atree. The low-level getters in sinfo.h call -// these even-lower-level getters. +/* The following code corresponds to the Get_n_Bit_Field functions (for + various n) in package Atree. The low-level getters in sinfo.h call + these even-lower-level getters. */ extern Field_Offset *Node_Offsets_Ptr; -extern slot* Slots_Ptr; +extern slot *Slots_Ptr; -static Union_Id Get_1_Bit_Field(Node_Id N, Field_Offset Offset); -static Union_Id Get_2_Bit_Field(Node_Id N, Field_Offset Offset); -static Union_Id Get_4_Bit_Field(Node_Id N, Field_Offset Offset); -static Union_Id Get_8_Bit_Field(Node_Id N, Field_Offset Offset); -static Union_Id Get_32_Bit_Field(Node_Id N, Field_Offset Offset); -static Union_Id Get_32_Bit_Field_With_Default - (Node_Id N, Field_Offset Offset, Union_Id Default_Value); +INLINE Union_Id Get_1_Bit_Field (Node_Id N, Field_Offset Offset); +INLINE Union_Id Get_2_Bit_Field (Node_Id N, Field_Offset Offset); +INLINE Union_Id Get_4_Bit_Field (Node_Id N, Field_Offset Offset); +INLINE Union_Id Get_8_Bit_Field (Node_Id N, Field_Offset Offset); +INLINE Union_Id Get_32_Bit_Field (Node_Id N, Field_Offset Offset); +INLINE Union_Id Get_32_Bit_Field_With_Default (Node_Id N, Field_Offset Offset, + Union_Id Default_Value); INLINE Union_Id -Get_1_Bit_Field(Node_Id N, Field_Offset Offset) +Get_1_Bit_Field (Node_Id N, Field_Offset Offset) { - const Field_Offset L = 32; - slot_1_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset/L))->slot_1; + const Field_Offset L = 32; + + slot_1_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset / L))->slot_1; - switch (Offset%L) + switch (Offset % L) { case 0: return slot.f0; case 1: return slot.f1; @@ -122,17 +121,18 @@ Get_1_Bit_Field(Node_Id N, Field_Offset Offset) case 29: return slot.f29; case 30: return slot.f30; case 31: return slot.f31; - default: gcc_assert(false); + default: gcc_unreachable (); } } INLINE Union_Id -Get_2_Bit_Field(Node_Id N, Field_Offset Offset) +Get_2_Bit_Field (Node_Id N, Field_Offset Offset) { - const Field_Offset L = 16; - slot_2_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset/L))->slot_2; + const Field_Offset L = 16; + + slot_2_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset / L))->slot_2; - switch (Offset%L) + switch (Offset % L) { case 0: return slot.f0; case 1: return slot.f1; @@ -150,17 +150,18 @@ Get_2_Bit_Field(Node_Id N, Field_Offset Offset) case 13: return slot.f13; case 14: return slot.f14; case 15: return slot.f15; - default: gcc_assert(false); + default: gcc_unreachable (); } } INLINE Union_Id -Get_4_Bit_Field(Node_Id N, Field_Offset Offset) +Get_4_Bit_Field (Node_Id N, Field_Offset Offset) { - const Field_Offset L = 8; - slot_4_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset/L))->slot_4; + const Field_Offset L = 8; - switch (Offset%L) + slot_4_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset / L))->slot_4; + + switch (Offset % L) { case 0: return slot.f0; case 1: return slot.f1; @@ -170,46 +171,46 @@ Get_4_Bit_Field(Node_Id N, Field_Offset Offset) case 5: return slot.f5; case 6: return slot.f6; case 7: return slot.f7; - default: gcc_assert(false); + default: gcc_unreachable (); } } INLINE Union_Id -Get_8_Bit_Field(Node_Id N, Field_Offset Offset) +Get_8_Bit_Field (Node_Id N, Field_Offset Offset) { - const Field_Offset L = 4; - slot_8_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset/L))->slot_8; + const Field_Offset L = 4; + + slot_8_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset / L))->slot_8; - switch (Offset%L) + switch (Offset % L) { case 0: return slot.f0; case 1: return slot.f1; case 2: return slot.f2; case 3: return slot.f3; - default: gcc_assert(false); + default: gcc_unreachable (); } } INLINE Union_Id -Get_32_Bit_Field(Node_Id N, Field_Offset Offset) +Get_32_Bit_Field (Node_Id N, Field_Offset Offset) { - const Field_Offset L = 1; - slot_32_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset/L))->slot_32; - return slot; + const Field_Offset L = 1; + + slot_32_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset / L))->slot_32; + + return slot; } INLINE Union_Id -Get_32_Bit_Field_With_Default(Node_Id N, Field_Offset Offset, Union_Id Default_Value) +Get_32_Bit_Field_With_Default (Node_Id N, Field_Offset Offset, + Union_Id Default_Value) { - const Field_Offset L = 1; - slot_32_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset/L))->slot_32; + const Field_Offset L = 1; - if (slot == Empty) - { - return Default_Value; - } + slot_32_bit slot = (Slots_Ptr + (Node_Offsets_Ptr[N] + Offset / L))->slot_32; - return slot; + return slot == Empty ? Default_Value : slot; } #ifdef __cplusplus