From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id A8294384AB72 for ; Thu, 16 May 2024 09:26:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8294384AB72 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A8294384AB72 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::233 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851574; cv=none; b=engOk0vEbBd0ulx9z+64AWVOf6J4y7T49QQxrhHMxk8TuVcYeu4Cx7B21fqgxSMnnFkr5CZBNd8TRJkXJusdut8RMgJzAahKUQ1ZSxNZQW0d5l+2Voc8gMoefI/+jIWF4EnN4IVgIQz3gxxcMl9hCELNr7F4/sBXYSVdDT0RaL4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715851574; c=relaxed/simple; bh=cf7MKBdc45F/XQUowQmf1l9V4bhZOxZo4wvzDDiV3Qw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oyP47EUPGMBrDp1gPaPC1wwnDVKzFWCpryg+Y4/KiBGjZMZoHOUFt4on7hfJsImvhiOiNAUYEId+ORTuskLQbkMRQaPEpOpYwzYYiclQpGDGaCDCVMY5orisVz44TpxbJ1wrbHDFgWHRjY7afpb/AS5qMW61f0aiRELSJLPSg6M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2e0933d3b5fso6369471fa.2 for ; Thu, 16 May 2024 02:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1715851569; x=1716456369; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6nNWtHB3pWK/rWdGWeRAFgIEQP1i7oQfXj9mTc7M1vU=; b=gT4KcxrdWa5SXU/yA+0UjWUyHtETpjP0xDLSMNJ47wZx9ID9aSEW/AwwCWd1VxQIMd fyhVBramNq5QvmiYCEY3zcsknqyjdY57TEWgE3YJ86vV30K3lJ8kz+L59knHfp/tewY1 SOyQ4m3EoVIOIk8qKCX86k5VX421ln/5XHEu2VazPeUZ3/TQQTbJi79ko3EiMNseOWJs r9DHdqQHrRC5Kj7cZ9cjEJAaT7jerDC48T8C9U+IHLgfDKEFUSCI3cRZe09ser5+xeH/ f9JnVNkB7CawCLtP3sPU7HWY2HZnxgnUSTHvwUnmJNcThlLP5wKol5VLxK/46vYIdXga LSuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715851569; x=1716456369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6nNWtHB3pWK/rWdGWeRAFgIEQP1i7oQfXj9mTc7M1vU=; b=ou0tAgV2SN4njh+VlAr0T8/hyUhpe1IK6ooQubohW2qYzPAoEbawj91j/JDWl2nxU+ 6XKgGce8Njcik8iif25dsTf1qB+L20JyonCsZE9XXtSd+SGsNxnpPV4je3OOUwQQDu2c GbcWGUK19Z7NWO2BtBTqn6wrIrtiztTw8A9zrkgc9+O0jIKfu0b04WB7ddc779/r3aYF MrEnzX5LtzKf83xqN8aZuXP0lhPNcoZHMSID1gFuC3KPLeZJss7Gu52HEk4nGZs+C9Tq zbP8fddIf0mxsuR64xqTc+KQzKxo06zYvhXIIOAXa0XEQ8rj4sQp9Y40z08yfRAgKR0I usMg== X-Gm-Message-State: AOJu0YyV0W0xn3Xh2z6507Bh+9n5rNvMp/qwqHNLcotEh/O64bhb8LC8 7xubS1PfvWCf1pu5q9XtdT1g1Q90vJHNFiaqEGYm4AzhcLfIweyK9hLGJlf3Wf1MAOMhLEoNC54 = X-Google-Smtp-Source: AGHT+IGOxxAY5mzZ8ezFWt81of9RNrZsyy7DjM7VqGmTw6Sd9Nyy7K/hNmiXq0xPsSQSLn04+y4DXw== X-Received: by 2002:a2e:83ce:0:b0:2d9:f68a:d82c with SMTP id 38308e7fff4ca-2e52038a91bmr95934001fa.41.1715851569035; Thu, 16 May 2024 02:26:09 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-41fd10cf8besm135802635e9.1.2024.05.16.02.26.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 02:26:08 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED 03/35] ada: Fix ordering of code for pragma Preelaborable_Initialization Date: Thu, 16 May 2024 11:25:32 +0200 Message-ID: <20240516092606.41242-3-poulhies@adacore.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240516092606.41242-1-poulhies@adacore.com> References: <20240516092606.41242-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Piotr Trojanek Code cleanup. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Move case alternative to match to alphabetic order. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_prag.adb | 160 +++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 105cc73eba3..2fc46ab0cd2 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -21889,86 +21889,6 @@ package body Sem_Prag is Check_Arg_Is_One_Of (Arg1, Name_Semaphore, Name_No); end if; - ---------------------------------- - -- Preelaborable_Initialization -- - ---------------------------------- - - -- pragma Preelaborable_Initialization (DIRECT_NAME); - - when Pragma_Preelaborable_Initialization => Preelab_Init : declare - Ent : Entity_Id; - - begin - Ada_2005_Pragma; - Check_Arg_Count (1); - Check_No_Identifiers; - Check_Arg_Is_Identifier (Arg1); - Check_Arg_Is_Local_Name (Arg1); - Check_First_Subtype (Arg1); - Ent := Entity (Get_Pragma_Arg (Arg1)); - - -- A pragma that applies to a Ghost entity becomes Ghost for the - -- purposes of legality checks and removal of ignored Ghost code. - - Mark_Ghost_Pragma (N, Ent); - - -- The pragma may come from an aspect on a private declaration, - -- even if the freeze point at which this is analyzed in the - -- private part after the full view. - - if Has_Private_Declaration (Ent) - and then From_Aspect_Specification (N) - then - null; - - -- Check appropriate type argument - - elsif Is_Private_Type (Ent) - or else Is_Protected_Type (Ent) - or else (Is_Generic_Type (Ent) and then Is_Derived_Type (Ent)) - - -- AI05-0028: The pragma applies to all composite types. Note - -- that we apply this binding interpretation to earlier versions - -- of Ada, so there is no Ada 2012 guard. Seems a reasonable - -- choice since there are other compilers that do the same. - - or else Is_Composite_Type (Ent) - then - null; - - else - Error_Pragma_Arg - ("pragma % can only be applied to private, formal derived, " - & "protected, or composite type", Arg1); - end if; - - -- Give an error if the pragma is applied to a protected type that - -- does not qualify (due to having entries, or due to components - -- that do not qualify). - - if Is_Protected_Type (Ent) - and then not Has_Preelaborable_Initialization (Ent) - then - Error_Msg_N - ("protected type & does not have preelaborable " - & "initialization", Ent); - - -- Otherwise mark the type as definitely having preelaborable - -- initialization. - - else - Set_Known_To_Have_Preelab_Init (Ent); - end if; - - if Has_Pragma_Preelab_Init (Ent) - and then Warn_On_Redundant_Constructs - then - Error_Pragma ("?r?duplicate pragma%!"); - else - Set_Has_Pragma_Preelab_Init (Ent); - end if; - end Preelab_Init; - -------------------- -- Persistent_BSS -- -------------------- @@ -22057,6 +21977,86 @@ package body Sem_Prag is end if; end Persistent_BSS; + ---------------------------------- + -- Preelaborable_Initialization -- + ---------------------------------- + + -- pragma Preelaborable_Initialization (DIRECT_NAME); + + when Pragma_Preelaborable_Initialization => Preelab_Init : declare + Ent : Entity_Id; + + begin + Ada_2005_Pragma; + Check_Arg_Count (1); + Check_No_Identifiers; + Check_Arg_Is_Identifier (Arg1); + Check_Arg_Is_Local_Name (Arg1); + Check_First_Subtype (Arg1); + Ent := Entity (Get_Pragma_Arg (Arg1)); + + -- A pragma that applies to a Ghost entity becomes Ghost for the + -- purposes of legality checks and removal of ignored Ghost code. + + Mark_Ghost_Pragma (N, Ent); + + -- The pragma may come from an aspect on a private declaration, + -- even if the freeze point at which this is analyzed in the + -- private part after the full view. + + if Has_Private_Declaration (Ent) + and then From_Aspect_Specification (N) + then + null; + + -- Check appropriate type argument + + elsif Is_Private_Type (Ent) + or else Is_Protected_Type (Ent) + or else (Is_Generic_Type (Ent) and then Is_Derived_Type (Ent)) + + -- AI05-0028: The pragma applies to all composite types. Note + -- that we apply this binding interpretation to earlier versions + -- of Ada, so there is no Ada 2012 guard. Seems a reasonable + -- choice since there are other compilers that do the same. + + or else Is_Composite_Type (Ent) + then + null; + + else + Error_Pragma_Arg + ("pragma % can only be applied to private, formal derived, " + & "protected, or composite type", Arg1); + end if; + + -- Give an error if the pragma is applied to a protected type that + -- does not qualify (due to having entries, or due to components + -- that do not qualify). + + if Is_Protected_Type (Ent) + and then not Has_Preelaborable_Initialization (Ent) + then + Error_Msg_N + ("protected type & does not have preelaborable " + & "initialization", Ent); + + -- Otherwise mark the type as definitely having preelaborable + -- initialization. + + else + Set_Known_To_Have_Preelab_Init (Ent); + end if; + + if Has_Pragma_Preelab_Init (Ent) + and then Warn_On_Redundant_Constructs + then + Error_Pragma ("?r?duplicate pragma%!"); + else + Set_Has_Pragma_Preelab_Init (Ent); + end if; + end Preelab_Init; + -------------------- -- Rename_Pragma -- -------------------- -- 2.43.2