From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id A1CE6383642C for ; Wed, 11 May 2022 08:54:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1CE6383642C Received: by mail-wr1-x435.google.com with SMTP id x18so2019370wrc.0 for ; Wed, 11 May 2022 01:54:34 -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=bzFOPcS4MOp+VKFvX9n/OCUswsPbAJnh4ttpJQhkeWA=; b=WDYUGbJv0U1gbLzBeuhBIyV6teBqTV6XTtDIQzCcN8Pj/YP/MyQrmHCEVTNpFZqEdz +w0pm8ViPcUQoB8MH6QYHn0QY1Y7iHtp4ew4siW5FaC7qijGrMi4DKHxlLkt3hxmTNXF du8ooXxBEHW8eh4AMvc6Uy7MaQN3Gp9xxfPTcxDo/fEqR6enkbko6bQ/K7ANzm1SDSaG ING1mbwg/fEXYePMjfB4kmMuOd0HhITR26MGPPvoKcLH0MfLG7MriLotncRpWF2N6cdL g8DQVCKT2HIteJPZ6jnCaAxKW1/JItWXzcPLn6oDngYcccFF0pPzykeRLPm9ILUm3rYb CqJw== X-Gm-Message-State: AOAM531OuWkKtVQVRlhE80yxwjNkt941zIrSFfMqwJrj/IGTCJq0Jhug ueVgYGbkFn15KC2jKjXi2WUt0lP3vpYMcA== X-Google-Smtp-Source: ABdhPJyJaXdvd3drrxdoRzZTof8ZRP34S3PxFYsgkTVgvYVTlEBYRocoyT+knVmuVXm2tgfgxQFE8A== X-Received: by 2002:a05:6000:10a:b0:20a:e2aa:6848 with SMTP id o10-20020a056000010a00b0020ae2aa6848mr21514232wrx.464.1652259274167; Wed, 11 May 2022 01:54:34 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id m36-20020a05600c3b2400b003942a244edbsm1874052wms.32.2022.05.11.01.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 01:54:33 -0700 (PDT) Date: Wed, 11 May 2022 08:54:33 +0000 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Use pygments for Ada code examples of elaboration control Message-ID: <20220511085433.GA2166696@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="45Z9DzgjV8m4Oswq" 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.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-List-Received-Date: Wed, 11 May 2022 08:54:37 -0000 --45Z9DzgjV8m4Oswq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Only enhancement of formatting. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * doc/gnat_ugn/elaboration_order_handling_in_gnat.rst: Change blocks from plain code to Ada. --45Z9DzgjV8m4Oswq Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/doc/gnat_ugn/elaboration_order_handling_in_gnat.rst b/gcc/ada/doc/gnat_ugn/elaboration_order_handling_in_gnat.rst --- a/gcc/ada/doc/gnat_ugn/elaboration_order_handling_in_gnat.rst +++ b/gcc/ada/doc/gnat_ugn/elaboration_order_handling_in_gnat.rst @@ -93,7 +93,7 @@ Elaboration code may appear in two distinct contexts: [body] compilation unit, ignoring any other package [body] declarations in between. - :: + .. code-block:: ada with Server; package Client is @@ -116,7 +116,7 @@ Elaboration code may appear in two distinct contexts: bounded by the region starting from the ``begin`` keyword of the package body and ending at the ``end`` keyword of the package body. - :: + .. code-block:: ada package body Client is procedure Proc is @@ -142,7 +142,7 @@ executed is referred to as **elaboration order**. Within a single unit, elaboration code is executed in sequential order. - :: + .. code-block:: ada package body Client is Result : ... := Server.Func; @@ -190,13 +190,13 @@ factors: A program may have several elaboration orders depending on its structure. - :: + .. code-block:: ada package Server is function Func (Index : Integer) return Integer; end Server; - :: + .. code-block:: ada package body Server is Results : array (1 .. 5) of Integer := (1, 2, 3, 4, 5); @@ -207,14 +207,14 @@ A program may have several elaboration orders depending on its structure. end Func; end Server; - :: + .. code-block:: ada with Server; package Client is Val : constant Integer := Server.Func (3); end Client; - :: + .. code-block:: ada with Client; procedure Main is begin null; end Main; @@ -320,7 +320,7 @@ the desired elaboration order and avoiding ABE problems altogether. A library package which does not require a completing body does not suffer from ABE problems. - :: + .. code-block:: ada package Pack is generic @@ -358,7 +358,7 @@ the desired elaboration order and avoiding ABE problems altogether. scenario can invoke a server target before the target body has been elaborated because the spec and body are effectively "glued" together. - :: + .. code-block:: ada package Server is pragma Elaborate_Body; @@ -366,7 +366,7 @@ the desired elaboration order and avoiding ABE problems altogether. function Func return Integer; end Server; - :: + .. code-block:: ada package body Server is function Func return Integer is @@ -375,7 +375,7 @@ the desired elaboration order and avoiding ABE problems altogether. end Func; end Server; - :: + .. code-block:: ada with Server; package Client is @@ -425,13 +425,13 @@ depend on. be elaborated prior to the unit with the pragma. Note that other unrelated units may be elaborated in between the spec and the body. - :: + .. code-block:: ada package Server is function Func return Integer; end Server; - :: + .. code-block:: ada package body Server is function Func return Integer is @@ -440,7 +440,7 @@ depend on. end Func; end Server; - :: + .. code-block:: ada with Server; pragma Elaborate (Server); @@ -479,13 +479,13 @@ depend on. |withed| by the spec and body of the argument, recursively. Note that other unrelated units may be elaborated in between the spec and the body. - :: + .. code-block:: ada package Math is function Factorial (Val : Natural) return Natural; end Math; - :: + .. code-block:: ada package body Math is function Factorial (Val : Natural) return Natural is @@ -494,7 +494,7 @@ depend on. end Factorial; end Math; - :: + .. code-block:: ada package Computer is type Operation_Kind is (None, Op_Factorial); @@ -504,7 +504,7 @@ depend on. Op : Operation_Kind) return Natural; end Computer; - :: + .. code-block:: ada with Math; package body Computer is @@ -520,7 +520,7 @@ depend on. end Compute; end Computer; - :: + .. code-block:: ada with Computer; pragma Elaborate_All (Computer); @@ -738,7 +738,7 @@ execution. The warnings can be suppressed selectively with ``pragma Warnings A *guaranteed ABE* arises when the body of a target is not elaborated early enough, and causes *all* scenarios that directly invoke the target to fail. - :: + .. code-block:: ada package body Guaranteed_ABE is function ABE return Integer; @@ -765,7 +765,7 @@ the declaration of ``Val``. This invokes function ``ABE``, however the body of A *conditional ABE* arises when the body of a target is not elaborated early enough, and causes *some* scenarios that directly invoke the target to fail. - :: + .. code-block:: ada 1. package body Conditional_ABE is 2. procedure Force_Body is null; @@ -850,19 +850,19 @@ clauses, elaboration-control pragmas, or invocations in elaboration code. The following example exhibits an elaboration circularity. - :: + .. code-block:: ada with B; pragma Elaborate (B); package A is end A; - :: + .. code-block:: ada package B is procedure Force_Body; end B; - :: + .. code-block:: ada with C; package body B is @@ -871,13 +871,13 @@ The following example exhibits an elaboration circularity. Elab : constant Integer := C.Func; end B; - :: + .. code-block:: ada package C is function Func return Integer; end C; - :: + .. code-block:: ada with A; package body C is --45Z9DzgjV8m4Oswq--