I wrote:
What's missing is a test where the formal discriminants are of a subrange type and the actual discriminants (in `New' or a variable declaration) are out of range.
Initialization of types, variables and typed constants. (I.e., variables (or fields) or subrange type with an out-of-range initializer; must be locally, otherwise GPC won't accept non-constants initializers.)
The `FillChar' test (fsc20.pas) shouldn't (I think) work like this since it takes an untyped parameter. (Some people (ab)use it for strange purposes.) Instead, the 3rd parameter may also be an integer, so it's an error if it's < 0 or > Ord (MaxChar).
I've found some more missing cases:
- `Return' (where the result type is a subrange and the `Return' value is out of range)
- `Pack', `Unpack' (the index parameter)
- `Include', `Exclude'
- `Inc', `Dec'
- 4th parameter of `BlockRead', `BlockWrite' (not obvious, but GPC allows a subrange here which may be too small for the actual result)
- `Val' (2nd and 3rd parameter)
- `and', `or', `xor', `shl', `shr' used as procedures, e.g., if a is of type 1 .. 10: a := 5; or (a, 8) (whereas normal use as operators will be covered by assignments or whatever is done with them)
- Conformant arrays (i.e., where the index type in the conformant array in the formal parameter list is a subrange, and the actual parameter's range is too big -- check both bounds)
- `New' with variant records (where the variant tag is of subrange type)
- sets (e.g., assigning a set of a larger range to one of a smaller range where the former contains out of range elements)
Frank