-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TGen: Reject constrained array types with too many elements
TGen already rejected at runtime unconstrained array values exceeding a configurable limit. With this change, constrained array types are also rejected when they define a type with more elements than the configured limit.
- Loading branch information
Showing
8 changed files
with
192 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package Pkg is | ||
|
||
type Long_Array is array (Integer range 1 .. Integer'Last) of Integer; | ||
|
||
type Long_Array_2 is array (Integer) of Integer; | ||
|
||
subtype Large_Int is Positive range 1 .. 100000; | ||
|
||
subtype Long_Array_3 is String (Large_Int); | ||
|
||
type Big_Rec is record | ||
Long_Component : String (Large_Int); | ||
end record; | ||
|
||
function First (Arr : Long_Array) return Integer is (Arr (1)); | ||
|
||
function First (Arr : Long_Array_2) return Integer is (Arr (Integer'First)); | ||
|
||
function First (Arr : Long_Array_3) return Character is (Arr (1)); | ||
|
||
function First (X : Big_Rec) return Character is (X.Long_Component (1)); | ||
|
||
function Dummy (X : Positive) return Positive is (X); | ||
-- Just here so there is something to generate. | ||
|
||
end Pkg; |
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,5 @@ | ||
project Prj is | ||
|
||
for Object_Dir use "obj"; | ||
|
||
end Prj; |
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,23 @@ | ||
gnattest: Error while processing <ExprFunction ["First"] pkg.ads:15:4-15:66>: | ||
pkg.first.Arr: pkg.long_array is not supported (array type has more elements (2147483647) than the configured limit (1000)) | ||
|
||
gnattest: Error while processing <ExprFunction ["First"] pkg.ads:17:4-17:80>: | ||
pkg.first.Arr: pkg.long_array_2 is not supported (array type has more elements (4294967296) than the configured limit (1000)) | ||
|
||
gnattest: Error while processing <ExprFunction ["First"] pkg.ads:19:4-19:70>: | ||
pkg.first.Arr: pkg.long_array_3 is not supported (array type has more elements (100000) than the configured limit (1000)) | ||
|
||
gnattest: Error while processing <ExprFunction ["First"] pkg.ads:21:4-21:76>: | ||
Failed to translate type of component<ComponentDecl ["Long_Component"] pkg.ads:12:7-12:43>: array type has more elements (100000) than the configured limit (1000) | ||
|
||
pkg.ads:23:4: info: corresponding test PASSED | ||
pkg.ads:23:4: info: corresponding test PASSED | ||
pkg.ads:23:4: info: corresponding test PASSED | ||
pkg.ads:23:4: info: corresponding test PASSED | ||
pkg.ads:23:4: info: corresponding test PASSED | ||
pkg.ads:15:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:45) | ||
pkg.ads:17:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:66) | ||
pkg.ads:19:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:87) | ||
pkg.ads:21:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:108) | ||
pkg.ads:23:4: error: corresponding test FAILED: Test not implemented. (pkg-test_data-tests.adb:129) | ||
10 tests run: 5 passed; 5 failed; 0 crashed. |
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,5 @@ | ||
#!/bin/bash | ||
|
||
gnattest -P prj.gpr --gen-test-vectors | ||
gprbuild -P obj/gnattest/harness/test_driver.gpr -q | ||
./obj/gnattest/harness/test_runner |
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,10 @@ | ||
description: | ||
Check that TGen properly rejects constrained array types which are over the | ||
configured array size limit. | ||
We do this by attempting to generate tests with gnattest for a big array type, | ||
and checking the emitted warnings. | ||
|
||
driver: shell_script | ||
|
||
control: | ||
- [XFAIL, 'x86', 'Marshalling not working for 32bits (UB03-008)'] |