]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Refactor checks for Refined_Depends in generic instances
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 8 Apr 2024 16:00:05 +0000 (18:00 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 10 Jun 2024 09:03:57 +0000 (11:03 +0200)
Code cleanup; semantics is unaffected.

gcc/ada/

* sem_prag.adb (Check_Dependency_Clause, Check_Output_States,
Report_Extra_Clauses): Remove multiple checks for being inside
an instance.
(Analyze_Refined_Depends_In_Decl_Part): Add single check for
being inside an instance.

gcc/ada/sem_prag.adb

index 86a25dc7d0cd91c9e4a407995d4837f31e1e15be..29f27652138578eaffbe7804f9235f8bae59993c 100644 (file)
@@ -27650,13 +27650,6 @@ package body Sem_Prag is
       --  Start of processing for Check_Dependency_Clause
 
       begin
-         --  Do not perform this check in an instance because it was already
-         --  performed successfully in the generic template.
-
-         if In_Instance then
-            return;
-         end if;
-
          --  Examine all refinement clauses and compare them against the
          --  dependence clause.
 
@@ -27910,16 +27903,10 @@ package body Sem_Prag is
       --  Start of processing for Check_Output_States
 
       begin
-         --  Do not perform this check in an instance because it was already
-         --  performed successfully in the generic template.
-
-         if In_Instance then
-            null;
-
          --  Inspect the outputs of pragma Depends looking for a state with a
          --  visible refinement.
 
-         elsif Present (Spec_Outputs) then
+         if Present (Spec_Outputs) then
             Item_Elmt := First_Elmt (Spec_Outputs);
             while Present (Item_Elmt) loop
                Item := Node (Item_Elmt);
@@ -28261,13 +28248,7 @@ package body Sem_Prag is
          Clause : Node_Id;
 
       begin
-         --  Do not perform this check in an instance because it was already
-         --  performed successfully in the generic template.
-
-         if In_Instance then
-            null;
-
-         elsif Present (Clauses) then
+         if Present (Clauses) then
             Clause := First (Clauses);
             while Present (Clause) loop
                SPARK_Msg_N
@@ -28369,6 +28350,13 @@ package body Sem_Prag is
 
       Analyze_Depends_In_Decl_Part (N);
 
+      --  Do not perform these checks in an instance because they were already
+      --  performed successfully in the generic template.
+
+      if In_Instance then
+         goto Leave;
+      end if;
+
       --  Do not match dependencies against refinements if Refined_Depends is
       --  illegal to avoid emitting misleading error.