]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/ada/sem_prag.adb
exp_ch9.adb (Build_Corresponding_Record): Propagate type invariants to the correspond...
[gcc.git] / gcc / ada / sem_prag.adb
index 9e216c642fe7aff5b704906ee5fc05aff33c502e..602c411e05613ed37a4c31422f64fe98cb3f8ad2 100644 (file)
@@ -15277,6 +15277,11 @@ package body Sem_Prag is
             if Typ = Any_Type then
                return;
 
+            --  Invariants allowed in interface types (RM 7.3.2(3/3))
+
+            elsif Is_Interface (Typ) then
+               null;
+
             --  An invariant must apply to a private type, or appear in the
             --  private part of a package spec and apply to a completion.
             --  a class-wide invariant can only appear on a private declaration
@@ -15318,8 +15323,14 @@ package body Sem_Prag is
             --  procedure declaration, so that calls to it can be generated
             --  before the body is built (e.g. within an expression function).
 
-            Insert_After_And_Analyze
-              (N, Build_Invariant_Procedure_Declaration (Typ));
+            --  Interface types have no invariant procedure; their invariants
+            --  are propagated to the build invariant procedure of all the
+            --  types covering the interface type.
+
+            if not Is_Interface (Typ) then
+               Insert_After_And_Analyze
+                 (N, Build_Invariant_Procedure_Declaration (Typ));
+            end if;
 
             if Class_Present (N) then
                Set_Has_Inheritable_Invariants (Typ);
This page took 0.04749 seconds and 5 git commands to generate.