Some legal Ada 83 programs are illegal (i.e., they will fail to compile) in Ada 95 and thus also in Ada 2005:
Wide_Characteras a new predefined character type, some uses of character literals that were legal in Ada 83 are illegal in Ada 95. For example:
for Char in 'A' .. 'Z' loop ... end loop;
The problem is that
'Z' could be from either
Wide_Character. The simplest correction
is to make the type explicit; e.g.:
for Char in Character range 'A' .. 'Z' loop ... end loop;
untilare reserved in Ada 95. Existing Ada 83 code using any of these identifiers must be edited to use some alternative name.
A particular case is that representation pragmas
cannot be applied to a subprogram body. If necessary, a separate subprogram
declaration must be introduced to which the pragma can be applied.
Requires_Body, which must then be given a dummy procedure body in the package body, which then becomes required. Another approach (assuming that this does not introduce elaboration circularities) is to add an
Elaborate_Bodypragma to the package spec, since one effect of this pragma is to require the presence of a package body.
Numeric_Erroris now the same as
Numeric_Erroris a renaming of
Constraint_Error. This means that it is illegal to have separate exception handlers for the two exceptions. The fix is simply to remove the handler for the
Numeric_Errorcase (since even in Ada 83, a compiler was free to raise
Constraint_Errorin place of
Numeric_Errorin all cases).
String) as the actual for a generic formal private type, but then the instantiation would be illegal if there were any instances of declarations of variables of this type in the generic body. In Ada 95, to avoid this clear violation of the methodological principle known as the “contract model”, the generic declaration explicitly indicates whether or not such instantiations are permitted. If a generic formal parameter has explicit unknown discriminants, indicated by using
(<>)after the subtype name, then it can be instantiated with indefinite types, but no stand-alone variables can be declared of this type. Any attempt to declare such a variable will result in an illegality at the time the generic is declared. If the
(<>)notation is not used, then it is illegal to instantiate the generic with an indefinite type. This is the potential incompatibility issue when porting Ada 83 code to Ada 95. It will show up as a compile time error, and the fix is usually simply to add the
(<>)to the generic declaration.