]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Inspect deferred constant completions in missing contexts
authorRaphaël AMIARD <amiard@adacore.com>
Wed, 4 Sep 2024 08:24:26 +0000 (08:24 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 25 Oct 2024 09:08:59 +0000 (11:08 +0200)
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

gcc/ada/sem_ch4.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads

index 9afaa896e20bbc3e2de255e20581f6de0a44a991..2d9177772109cb41606f46c379ca3d08c78d5521 100644 (file)
@@ -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",
index 30fee6e65001235d91140f4ce6f0594de42d4877..131195a78c7c2bbf6719ec30033103c580798077 100644 (file)
@@ -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);
index ac64b1ca549617f8a9abd4972675379474951a1a..12437cc5a4c817e74990e802b8a31ecf0c22d5e6 100644 (file)
@@ -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;
index eccbd4351d017c5c07e7501c165765cdd4be8551..22ee23aa4ab08c07295254daca7d192e9df3e330 100644 (file)
@@ -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