This changes makes it so that the compiler issues the same diagnostics on invalid bit-packed array types with atomic component whatever the origin of the Atomic aspect. For the following package:
package P is type Arr1 is array (1 .. 16) of Boolean; pragma Atomic_Components (Arr1); for Arr1'Component_Size use 1; type Arr2 is array (1 .. 16) of Boolean; pragma Atomic_Components (Arr2); pragma Pack (Arr2); type My_Boolean is new Boolean; pragma Atomic (My_Boolean); type Arr3 is array (1 .. 16) of My_Boolean; for Arr3'Component_Size use 1; type Arr4 is array (1 .. 16) of My_Boolean; pragma Pack (Arr4); end P; the compiler must issue the expected errors on Arr3 and Arr4: 1. package P is 2. 3. type Arr1 is array (1 .. 16) of Boolean; 4. pragma Atomic_Components (Arr1); 5. for Arr1'Component_Size use 1; | >>> incorrect component size for atomic components >>> only allowed value is 8 6. 7. type Arr2 is array (1 .. 16) of Boolean; 8. pragma Atomic_Components (Arr2); 9. pragma Pack (Arr2); | >>> cannot pack atomic components 10. 11. type My_Boolean is new Boolean; 12. pragma Atomic (My_Boolean); 13. 14. type Arr3 is array (1 .. 16) of My_Boolean; 15. for Arr3'Component_Size use 1; | >>> incorrect component size for atomic components >>> only allowed value is 8 16. 17. type Arr4 is array (1 .. 16) of My_Boolean; 18. pragma Pack (Arr4); | >>> cannot pack atomic components 19. 20. end P; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-01-07 Eric Botcazou <ebotca...@adacore.com> * freeze.adb (Freeze_Array_Type): Apply same handling to Is_Atomic component type as to Has_Atomic_Components type. Remove useless test on Is_Aliased component type.
Index: freeze.adb =================================================================== --- freeze.adb (revision 219280) +++ freeze.adb (working copy) @@ -2431,12 +2431,12 @@ end if; end; - -- Check for Atomic_Components or Aliased with unsuitable packing - -- or explicit component size clause given. + -- Check for Aliased or Atomic_Components/Atomic with unsuitable + -- packing or explicit component size clause given. - if (Has_Atomic_Components (Arr) + if (Has_Aliased_Components (Arr) or else - Has_Aliased_Components (Arr)) + Has_Atomic_Components (Arr) or else Is_Atomic (Ctyp)) and then (Has_Component_Size_Clause (Arr) or else Is_Packed (Arr)) then @@ -2503,13 +2503,10 @@ then null; - elsif Has_Aliased_Components (Arr) - or else Is_Aliased (Ctyp) - then + elsif Has_Aliased_Components (Arr) then Complain_CS ("aliased"); - elsif Has_Atomic_Components (Arr) - or else Is_Atomic (Ctyp) + elsif Has_Atomic_Components (Arr) or else Is_Atomic (Ctyp) then Complain_CS ("atomic"); end if;