summaryrefslogtreecommitdiffstats
path: root/gcc/ada/einfo.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-21 10:30:24 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-21 10:30:24 +0000
commitf54f1dff2ff9c50f6403ff7d603db4dca4d8caa0 (patch)
tree82e1e9c9a50526d9512c41952beb3d596c952bb7 /gcc/ada/einfo.adb
parentb3f5eb3697c6ef2083fcbc4df8ff6b0e49e2a435 (diff)
downloadppe42-gcc-f54f1dff2ff9c50f6403ff7d603db4dca4d8caa0.tar.gz
ppe42-gcc-f54f1dff2ff9c50f6403ff7d603db4dca4d8caa0.zip
2010-10-21 Robert Dewar <dewar@adacore.com>
* einfo.ads, einfo.adb: Add handling of predicates. Rework handling of invariants. * exp_ch3.adb, exp_ch4.adb, exp_util.adb, sem_ch6.adb: Minor changes to handing of invariants. * par-prag.adb: Add dummy entry for pragma Predicate * sem_ch13.adb (Analyze_Aspect_Specifications): Add processing for Predicate aspects. * sem_prag.adb: Add implementation of pragma Predicate. * snames.ads-tmpl: Add entries for pragma Predicate. 2010-10-21 Robert Dewar <dewar@adacore.com> * elists.adb: Minor reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165763 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/einfo.adb')
-rw-r--r--gcc/ada/einfo.adb156
1 files changed, 136 insertions, 20 deletions
diff --git a/gcc/ada/einfo.adb b/gcc/ada/einfo.adb
index ca61c201207..ca6bbf0e4d2 100644
--- a/gcc/ada/einfo.adb
+++ b/gcc/ada/einfo.adb
@@ -230,7 +230,7 @@ package body Einfo is
-- Extra_Formals Node28
-- Underlying_Record_View Node28
- -- Invariant_Procedure Node29
+ -- Subprograms_For_Type Node29
---------------------------------------------
-- Usage of Flags in Defining Entity Nodes --
@@ -513,8 +513,8 @@ package body Einfo is
-- OK_To_Rename Flag247
-- Has_Inheritable_Invariants Flag248
-- OK_To_Reference Flag249
+ -- Has_Predicates Flag250
- -- (unused) Flag250
-- (unused) Flag251
-- (unused) Flag252
-- (unused) Flag253
@@ -1287,7 +1287,7 @@ package body Einfo is
function Has_Invariants (Id : E) return B is
begin
- pragma Assert (Is_Type (Id));
+ pragma Assert (Is_Type (Id) or else Ekind (Id) = E_Procedure);
return Flag232 (Id);
end Has_Invariants;
@@ -1409,6 +1409,12 @@ package body Einfo is
return Flag212 (Id);
end Has_Pragma_Unreferenced_Objects;
+ function Has_Predicates (Id : E) return B is
+ begin
+ pragma Assert (Is_Type (Id) or else Ekind (Id) = E_Procedure);
+ return Flag250 (Id);
+ end Has_Predicates;
+
function Has_Primitive_Operations (Id : E) return B is
begin
pragma Assert (Is_Type (Id));
@@ -1566,12 +1572,6 @@ package body Einfo is
return Elist25 (Id);
end Interfaces;
- function Invariant_Procedure (Id : E) return N is
- begin
- pragma Assert (Is_Type (Id));
- return Node29 (Id);
- end Invariant_Procedure;
-
function In_Package_Body (Id : E) return B is
begin
return Flag48 (Id);
@@ -2651,6 +2651,12 @@ package body Einfo is
return Node15 (Id);
end String_Literal_Low_Bound;
+ function Subprograms_For_Type (Id : E) return E is
+ begin
+ pragma Assert (Is_Type (Id) or else Is_Subprogram (Id));
+ return Node29 (Id);
+ end Subprograms_For_Type;
+
function Suppress_Elaboration_Warnings (Id : E) return B is
begin
return Flag148 (Id);
@@ -3722,7 +3728,9 @@ package body Einfo is
procedure Set_Has_Invariants (Id : E; V : B := True) is
begin
- pragma Assert (Is_Type (Id));
+ pragma Assert (Is_Type (Id)
+ or else Ekind (Id) = E_Procedure
+ or else Ekind (Id) = E_Void);
Set_Flag232 (Id, V);
end Set_Has_Invariants;
@@ -3853,6 +3861,14 @@ package body Einfo is
Set_Flag212 (Id, V);
end Set_Has_Pragma_Unreferenced_Objects;
+ procedure Set_Has_Predicates (Id : E; V : B := True) is
+ begin
+ pragma Assert (Is_Type (Id)
+ or else Ekind (Id) = E_Procedure
+ or else Ekind (Id) = E_Void);
+ Set_Flag250 (Id, V);
+ end Set_Has_Predicates;
+
procedure Set_Has_Primitive_Operations (Id : E; V : B := True) is
begin
pragma Assert (Id = Base_Type (Id));
@@ -4012,12 +4028,6 @@ package body Einfo is
Set_Elist25 (Id, V);
end Set_Interfaces;
- procedure Set_Invariant_Procedure (Id : E; V : N) is
- begin
- pragma Assert (Is_Type (Id));
- Set_Node29 (Id, V);
- end Set_Invariant_Procedure;
-
procedure Set_In_Package_Body (Id : E; V : B := True) is
begin
Set_Flag48 (Id, V);
@@ -5146,6 +5156,12 @@ package body Einfo is
Set_Node15 (Id, V);
end Set_String_Literal_Low_Bound;
+ procedure Set_Subprograms_For_Type (Id : E; V : E) is
+ begin
+ pragma Assert (Is_Type (Id) or else Is_Subprogram (Id));
+ Set_Node29 (Id, V);
+ end Set_Subprograms_For_Type;
+
procedure Set_Suppress_Elaboration_Warnings (Id : E; V : B := True) is
begin
Set_Flag148 (Id, V);
@@ -6129,6 +6145,33 @@ package body Einfo is
end if;
end Implementation_Base_Type;
+ -------------------------
+ -- Invariant_Procedure --
+ -------------------------
+
+ function Invariant_Procedure (Id : E) return E is
+ S : Entity_Id;
+
+ begin
+ pragma Assert (Is_Type (Id) and then Has_Invariants (Id));
+
+ if No (Subprograms_For_Type (Id)) then
+ return Empty;
+
+ else
+ S := Subprograms_For_Type (Id);
+ while Present (S) loop
+ if Has_Invariants (S) then
+ return S;
+ else
+ S := Subprograms_For_Type (S);
+ end if;
+ end loop;
+
+ return Empty;
+ end if;
+ end Invariant_Procedure;
+
---------------------
-- Is_Boolean_Type --
---------------------
@@ -6222,6 +6265,33 @@ package body Einfo is
Ekind (Id) = E_Generic_Package;
end Is_Package_Or_Generic_Package;
+ -------------------------
+ -- Predicate_Procedure --
+ -------------------------
+
+ function Predicate_Procedure (Id : E) return E is
+ S : Entity_Id;
+
+ begin
+ pragma Assert (Is_Type (Id) and then Has_Predicates (Id));
+
+ if No (Subprograms_For_Type (Id)) then
+ return Empty;
+
+ else
+ S := Subprograms_For_Type (Id);
+ while Present (S) loop
+ if Has_Predicates (S) then
+ return S;
+ else
+ S := Subprograms_For_Type (S);
+ end if;
+ end loop;
+
+ return Empty;
+ end if;
+ end Predicate_Procedure;
+
---------------
-- Is_Prival --
---------------
@@ -6766,6 +6836,54 @@ package body Einfo is
end case;
end Set_Component_Alignment;
+ -----------------------------
+ -- Set_Invariant_Procedure --
+ -----------------------------
+
+ procedure Set_Invariant_Procedure (Id : E; V : E) is
+ S : Entity_Id;
+
+ begin
+ pragma Assert (Is_Type (Id) and then Has_Invariants (Id));
+
+ S := Subprograms_For_Type (Id);
+ Set_Subprograms_For_Type (Id, V);
+
+ while Present (S) loop
+ if Has_Invariants (S) then
+ raise Program_Error;
+ else
+ S := Subprograms_For_Type (S);
+ end if;
+ end loop;
+
+ Set_Subprograms_For_Type (Id, V);
+ end Set_Invariant_Procedure;
+
+ -----------------------------
+ -- Set_Predicate_Procedure --
+ -----------------------------
+
+ procedure Set_Predicate_Procedure (Id : E; V : E) is
+ S : Entity_Id;
+
+ begin
+ pragma Assert (Is_Type (Id) and then Has_Predicates (Id));
+
+ S := Subprograms_For_Type (Id);
+ Set_Subprograms_For_Type (Id, V);
+
+ while Present (S) loop
+ if Has_Predicates (S) then
+ raise Program_Error;
+ else
+ S := Subprograms_For_Type (S);
+ end if;
+ end loop;
+
+ Set_Subprograms_For_Type (Id, V);
+ end Set_Predicate_Procedure;
+
-----------------
-- Size_Clause --
-----------------
@@ -7063,6 +7181,7 @@ package body Einfo is
W ("Has_Pragma_Unmodified", Flag233 (Id));
W ("Has_Pragma_Unreferenced", Flag180 (Id));
W ("Has_Pragma_Unreferenced_Objects", Flag212 (Id));
+ W ("Has_Predicates", Flag250 (Id));
W ("Has_Primitive_Operations", Flag120 (Id));
W ("Has_Private_Declaration", Flag155 (Id));
W ("Has_Qualified_Name", Flag161 (Id));
@@ -8246,9 +8365,6 @@ package body Einfo is
procedure Write_Field28_Name (Id : Entity_Id) is
begin
case Ekind (Id) is
- when Private_Kind =>
- Write_Str ("Invariant_Procedure");
-
when E_Procedure | E_Function | E_Entry =>
Write_Str ("Extra_Formals");
@@ -8264,7 +8380,7 @@ package body Einfo is
begin
case Ekind (Id) is
when Type_Kind =>
- Write_Str ("Invariant_Procedure");
+ Write_Str ("Subprograms_For_Type");
when others =>
Write_Str ("Field29??");
OpenPOWER on IntegriCloud