-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'topic/958' into 'master'
Support Subtype Predicates self-reference Closes #958 See merge request eng/libadalang/libadalang!1326
- Loading branch information
Showing
13 changed files
with
996 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
testsuite/tests/name_resolution/type_predicates/conflict.adb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- This test ensure that `Name` in the CallExpr `Name (Name'First)` is correctly | ||
-- resolved to the `To_String`'s Name parameter while `Name (1 .. 4)` in the | ||
-- `Predicate` pragma is correctly bind to the subtype `Name`. | ||
|
||
procedure Conflict is | ||
subtype Name is String (1 .. 10); | ||
|
||
function To_String (Name : String) return String is | ||
(Name (Name'First) & "!"); | ||
pragma Test_Statement; | ||
|
||
pragma Predicate (Name, Name (1 .. 4) = "FAIL"); | ||
pragma Test_Statement; | ||
|
||
function P (N : String) return Boolean is (True); | ||
|
||
pragma Predicate (Name, P (Name (1 .. 4))); | ||
pragma Test_Statement; | ||
begin | ||
null; | ||
end Conflict; |
33 changes: 33 additions & 0 deletions
33
testsuite/tests/name_resolution/type_predicates/derived.adb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
procedure Derived is | ||
function F (S : String) return Boolean is (True); | ||
|
||
type String_T is new String with | ||
Dynamic_Predicate => F (String (String_T (1 .. 90))); | ||
pragma Test_Block; | ||
|
||
type Count is new Integer with | ||
Static_Predicate => Count /= 10; | ||
pragma Test_Block; | ||
|
||
type String_T2 is new String with | ||
Predicate => F (String (String_T2 (1 .. 90))); | ||
pragma Test_Block; | ||
|
||
type Count2 is new Integer with | ||
Predicate => Count2 /= 10; | ||
pragma Test_Block; | ||
|
||
type String_T3 is new String; | ||
pragma Predicate | ||
(Entity => String_T3, | ||
Check => F (String (String_T3 (1 .. 90)))); | ||
pragma Test_Statement; | ||
|
||
type Count3 is new Integer; | ||
pragma Predicate | ||
(Entity => Count3, | ||
Check => Count3 /= 10); | ||
pragma Test_Statement; | ||
begin | ||
null; | ||
end Derived; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
procedure Other is | ||
type Color is (White, Red, Yellow, Green, Blue, Brown, Black) | ||
with Static_Predicate => Color in Red; | ||
pragma Test_Block; | ||
|
||
type Column is range 1 .. 72 | ||
with Predicate => Column mod 2 = 1; | ||
pragma Test_Block; | ||
|
||
type Table is array (1 .. 10) of Integer; | ||
pragma Predicate (Table, Table'First = 1); | ||
pragma Test_Statement; | ||
|
||
type R is record | ||
I : Integer; | ||
end record with Predicate => R.I = 1; | ||
pragma Test_Block; | ||
begin | ||
null; | ||
end Other; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
procedure Test is | ||
function F (S : String) return Boolean is (True); | ||
|
||
subtype String_T is String (1 .. 99) with | ||
Dynamic_Predicate => F (String_T (1 .. 90)); | ||
pragma Test_Block; | ||
|
||
subtype Count is Integer with | ||
Static_Predicate => Count /= 10; | ||
pragma Test_Block; | ||
|
||
subtype String_T2 is String (1 .. 99) with | ||
Predicate => F (String_T2 (1 .. 90)); | ||
pragma Test_Block; | ||
|
||
subtype Count2 is Integer with | ||
Predicate => Count2 /= 10; | ||
pragma Test_Block; | ||
|
||
subtype String_T3 is String (1 .. 99); | ||
pragma Predicate | ||
(Entity => String_T3, | ||
Check => F (String_T3 (1 .. 90))); | ||
pragma Test_Statement; | ||
|
||
subtype Count3 is Integer; | ||
pragma Predicate | ||
(Entity => Count3, | ||
Check => Count3 /= 10); | ||
pragma Test_Statement; | ||
begin | ||
null; | ||
end Test; |
Oops, something went wrong.