AI12-0042 specifies a couple of new rules for type invariants. The first is that when a type extension inherits a nonabstract subprogram that is a private operation of an ancestor type that has a class-wide invariant and the parent subprogram is visible at that point, the subprogram must be overridden. The second is the addition of a requirement to perform an invariant check on a conversion from a specific tagged expression to a class-wide type T'Class whose root type imposes a type invariant, when the conversion occurs within the immediate scope of T (checking the invariant on the part of the conversion expression that is of type T). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch4.adb (Expand_N_Type_Conversion): Handle the case of applying an invariant check for a conversion to a class-wide type whose root type has a type invariant, when the conversion appears within the immediate scope of the type and the expression is of a specific tagged type. * sem_ch3.adb (Is_Private_Primitive): New function to determine whether a primitive subprogram is a private operation. (Check_Abstract_Overriding): Enforce the restriction imposed by AI12-0042 of requiring overriding of an inherited nonabstract private operation when the ancestor has a class-wide type invariant and the ancestor's private operation is visible. (Derive_Subprogram): Set Requires_Overriding on a subprogram inherited from a visible private operation of an ancestor to which a Type_Invariant'Class expression applies.