Version 1.3 of ai12s/ai12-0135-1.txt

Unformatted version of ai12s/ai12-0135-1.txt version 1.3
Other versions for file ai12s/ai12-0135-1.txt

!standard B.1(14/3)          15-01-26 AI12-0135-1/02
!standard B.1(41/3)
!class Amendment 14-10-09
!status work item 14-10-09
!status work item 15-01-26
!status received 14-08-18
!priority Low
!difficulty Easy
!subject Enumeration types should be eligible for convention C
!summary
Enumeration types are eligible for all languages that interface with Ada, subject to a limitation on their range of internal codes.
!problem
It is convenient to map C enumeration types to Ada enumeration types. However, enumeration types are not eligible for convention C. An implementation can allow enumeration types to have convention C via B.1(20), but this depends on the implementer, and thus impacts portability.
!proposal
Require support for interfacing with Ada enumeration types, so long as the number of internal codes is within some implementation defined range.
!wording
Add after B.1(14/3):
* T is an enumeration type such that all internal codes (whether assigned by default or explicitly) are within an implementation-defined range that includes at least the range of values 0 .. 2**16-1;
Modify the last sentence of B.1(41/3):
Specifying the Convention aspect need not be supported for scalar types{, other than enumeration types whose internal codes fall within the range 0 .. 2**16-1}.
!discussion
For some reason, B.1(12-21/3) do not require any scalar types to be eligible for convention L. Perhaps that is because using the scalar types in the various interface packages is preferred.
That's not sensible in the case of enumeration types, however. Many languages have some type similar to Ada's enumerations, and direct mapping should be supported if possible. Therefore we have chosen to require support for enumeration types in all languages that interface with Ada, subject to an implementation-defined limitation on the range of internal codes.
!ASIS
No impact.
!ACATS test
!appendix

!topic Enumeration types should be eligible for convention C
!reference Ada 2012 B.1(14/3)
!from Victor Porton 80-07-21
!keywords convention, C, eligible, enumeration type
!discussion

Enumeration types should be eligible for convention C.

There is one difficult thing here:

An enumeration type may be declared as having convention C before its
representation values are specified.

So to work around of this, convention C should become effective only
after enumeration representation clause is met or when it is too late.
(Define "too late" precisely. By the way I do not see in the RM when it is
too late for a enumeration representation clause. Should we start and other
correction procedure to specify when enumeration representation clause is
disallowed, because the enumeration values are already used?)

Note that in GNAT enumeration types are already eligible for convention C.

***************************************************************


Questions? Ask the ACAA Technical Agent