From patchwork Fri Oct 25 09:10:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 99532 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 B64703858427 for ; Fri, 25 Oct 2024 09:12:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 2EBA73858401 for ; Fri, 25 Oct 2024 09:11:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2EBA73858401 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 2EBA73858401 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729847485; cv=none; b=me6odS3OrEsdBR4qTS1dCa2Iceoqc7fbCuq4SsKEAq0siQf9PEG8zmocoSXY58H8D40paiW66HuSITbaQ/OwVxV5EOWxz4MSa0NjWdwxse2WXEjSxhqWfYkKEkPGGSRB0qbQ/R3xd8tU9/76s4dKvofS2XGd7xaSHZzmr5t7w6U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729847485; c=relaxed/simple; bh=X2mWQuMvX9CbV8Tisod4CNKBWSYZ2/hrBS4uuk+HjT4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=DwNQKuWJrzIL4nthTl4k5VXHtgmUq6mE0nR1/bMeNeDd7UMS9iJZgsPt8gqP4eaFFstGSqj+/TctygVD9xi5pI8zE4ITltNCP3w9WY9KE2W4gHt9L/FdttEEzA4/tqwdyZnuXiXVK/2mHNtAklEX5ypaJvdh36RzznKfI1cC2sI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43162cf1eaaso24037315e9.0 for ; Fri, 25 Oct 2024 02:11:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1729847480; x=1730452280; 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=di6kTzLvzV/Jd1HbbEon8AhEoPBaG2rhFuME/nQGynk=; b=ITp05u/xPYYTfs3x6J97U2FgBoBpu385FtjqFYZitzcxPC4ALOU/LRLrRiswtHMcoQ HP+OdMUPxCN7QgOZMnB1hFAol+YNtbYoqmSV1b3eYIDat+kpuUaEEC1sd8PhYQZol74n FciOUCzzyCxwxUIskbjJNX7yAdsngrXbDV2dw5BGi8PrLReCQiCWdz2VLIABkzaAyoUJ YDdvmTSXnxnTJ395YI+pNw6SVXR6zEmMoHZqdKGZYo20vUiG397QSvpWP11jFFsRVB29 cPqp82gUzOmFPwuNrHt+FfnRhEAdWxyaQPH/zsUItyue4PRCYKqIY4FPDkwRJw+oNibW zWpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729847480; x=1730452280; 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=di6kTzLvzV/Jd1HbbEon8AhEoPBaG2rhFuME/nQGynk=; b=J4kGTM14h0O0wkumY9oanslRt8riFCjqZzqeu0GBjarICQZXVzn10SupqsN62wOL04 dZyXjf9qZ67A1Xa8iG0JmdBZ+PxVxMdwwJfJX8oeHipj4Dpx5wPDcQNDef530gRHegSr VZIOTiz7+kC1YxIdn+jJTRndwpJYS9Qgj3HztRP25uT/XvlHCu30jDWZiPOfzyPcNDny 9SK5u4RkjjpqOpoqrj1F5eZTOdpSQ/5kKaoWT3T/VcpI75rVgxNLl4abuK4AaWnSI1/h H9T/JdFAdMGZ+fw8jmdvexLvgl5BvBnOjwgx33wOr4xY0orc5qNiyQbDCCZaTGM/H4bG Yq8A== X-Gm-Message-State: AOJu0Yy/OCKiQJshvLsV7IJx+fjWGTxHdAkm4O0071blsQHnhHXnQXz5 H+vkcWMXSoeyVUdz5smVg24v8Q5teMzFP+soYya6XPcA88BH89rwnFcrG5snn8uX+zjAWvmEU/o = X-Google-Smtp-Source: AGHT+IEwmGxfhozmNl0rwBKX3vV7QALoxC4ZS5RKAhZ91w0SB1xBtH5SxyVGcBYyKuduzc6t6HR2Ig== X-Received: by 2002:a5d:4bca:0:b0:37d:49be:9581 with SMTP id ffacd0b85a97d-37efcf7be67mr7082085f8f.37.1729847479745; Fri, 25 Oct 2024 02:11:19 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:2626:b78c:6271:6c01]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b47aa8sm1013079f8f.51.2024.10.25.02.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 02:11:19 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Rapha=C3=ABl_AMIARD?= Subject: [COMMITTED 02/35] ada: Inspect deferred constant completions in missing contexts Date: Fri, 25 Oct 2024 11:10:31 +0200 Message-ID: <20241025091107.485741-2-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025091107.485741-1-poulhies@adacore.com> References: <20241025091107.485741-1-poulhies@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 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.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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Raphaƫl AMIARD Namely declare expressions and statement lists, which can have object declarations in -gnatX mode. gcc/ada/ChangeLog: * sem_util.ads: Introduce Inspect_Deferred_Constant_Completion on a single object declaration, to better factorize the code * sem_util.adb: Introduce aforementioned overload * sem_ch4.adb (Analyze_Expression_With_Actions): Check deferred constant completions * sem_ch5.adb (Analyze_Statements): Check deferred constant completions Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch4.adb | 2 ++ gcc/ada/sem_ch5.adb | 2 ++ gcc/ada/sem_util.adb | 16 ++++++++++------ gcc/ada/sem_util.ads | 5 +++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 9afaa896e20..2d917777210 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -2414,6 +2414,8 @@ package body Sem_Ch4 is case Nkind (A) is when N_Object_Declaration => + Inspect_Deferred_Constant_Completion (A); + if Nkind (Object_Definition (A)) = N_Access_Definition then Error_Msg_N ("anonymous access type not allowed in declare_expression", diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb index 30fee6e6500..131195a78c7 100644 --- a/gcc/ada/sem_ch5.adb +++ b/gcc/ada/sem_ch5.adb @@ -4255,6 +4255,8 @@ package body Sem_Ch5 is ("implicit label declaration for & is hidden#", Identifier (S)); end if; + else + Inspect_Deferred_Constant_Completion (S); end if; Next (S); diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index ac64b1ca549..12437cc5a4c 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -14811,13 +14811,8 @@ package body Sem_Util is -- Inspect_Deferred_Constant_Completion -- ------------------------------------------ - procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is - Decl : Node_Id; - + procedure Inspect_Deferred_Constant_Completion (Decl : Node_Id) is begin - Decl := First (Decls); - while Present (Decl) loop - -- Deferred constant signature if Nkind (Decl) = N_Object_Declaration @@ -14838,6 +14833,15 @@ package body Sem_Util is Defining_Identifier (Decl)); end if; + end Inspect_Deferred_Constant_Completion; + + procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is + Decl : Node_Id; + + begin + Decl := First (Decls); + while Present (Decl) loop + Inspect_Deferred_Constant_Completion (Decl); Next (Decl); end loop; end Inspect_Deferred_Constant_Completion; diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index eccbd4351d0..22ee23aa4ab 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -1718,6 +1718,11 @@ package Sem_Util is -- prefix is an access type, rewrite the access type node N (which is the -- prefix, e.g. of an indexed component) as an explicit dereference. + procedure Inspect_Deferred_Constant_Completion (Decl : Node_Id); + -- If Decl is a constant object declaration without a default value, check + -- whether it has been completed by a full constant declaration or an + -- Import pragma. Emit an error message if that is not the case. + procedure Inspect_Deferred_Constant_Completion (Decls : List_Id); -- Examine all deferred constants in the declaration list Decls and check -- whether they have been completed by a full constant declaration or an