-- RM 3.7.2(2) -- For a prefix A that is of a discriminated type ... -- the following attribute [A'constrained] is defined procedure Test_247017 is generic type T1 (<>) is private; procedure p1(x: out T1); procedure p1 (x: out T1) is b: boolean := x'constrained; --ERROR: not a discriminated type begin null; end p1; begin null; end Test_247017; I expect an error message like this: test_247017.adb:11:20: "x" has no discriminants, Constraint attribute not defined But the compiler says nothing.
I do get a warning on the mainline: test_247017.adb:8:18: warning: "x" is never assigned a value
Confirmed.
Confirmed on 4.3.0 20071213
Confirmed on 4.4.1.
confirmed 4.6.1
confirm 4.9-20140218
In addition to the usage of this attribute in the Ada RM, GNAT also permits the use of the 'Constrained attribute in a generic template for any type, including types without discriminants. The value of this attribute in the generic instance when applied to a scalar type or a record type without discriminants is always True. This usage is compatible with older Ada compilers, including notably DEC Ada.