+2019-07-03 Eric Botcazou <ebotcazou@adacore.com>
+
+ * doc/gnat_ugn/building_executable_programs_with_gnat.rst
+ (Warning message control): Document that -gnatw.z/Z apply to
+ array types.
+ * freeze.adb (Freeze_Entity): Give -gnatw.z warning for array
+ types as well, but not if the specified alignment is the minimum
+ one.
+ * gnat_ugn.texi: Regenerate.
+
2019-07-03 Bob Duff <duff@adacore.com>
* einfo.ads, exp_util.adb, layout.ads, sinfo.ads: Spell "laid"
:switch:`-gnatw.z`
*Activate warnings for size not a multiple of alignment.*
- This switch activates warnings for cases of record types with
- specified ``Size`` and ``Alignment`` attributes where the
+ This switch activates warnings for cases of array and record types
+ with specified ``Size`` and ``Alignment`` attributes where the
size is not a multiple of the alignment, resulting in an object
size that is greater than the specified size. The default
is that such warnings are generated.
:switch:`-gnatw.Z`
*Suppress warnings for size not a multiple of alignment.*
- This switch suppresses warnings for cases of record types with
- specified ``Size`` and ``Alignment`` attributes where the
+ This switch suppresses warnings for cases of array and record types
+ with specified ``Size`` and ``Alignment`` attributes where the
size is not a multiple of the alignment, resulting in an object
- size that is greater than the specified size.
- The warning can also be
- suppressed by giving an explicit ``Object_Size`` value.
+ size that is greater than the specified size. The warning can also
+ be suppressed by giving an explicit ``Object_Size`` value.
.. index:: -Wunused (gcc)
Inherit_Aspects_At_Freeze_Point (E);
end if;
- -- Check for incompatible size and alignment for record type
+ -- Case of array type
+
+ if Is_Array_Type (E) then
+ Freeze_Array_Type (E);
+ end if;
+
+ -- Check for incompatible size and alignment for array/record type
if Warn_On_Size_Alignment
- and then Is_Record_Type (E)
- and then Has_Size_Clause (E) and then Has_Alignment_Clause (E)
+ and then (Is_Array_Type (E) or else Is_Record_Type (E))
+ and then Has_Size_Clause (E)
+ and then Has_Alignment_Clause (E)
-- If explicit Object_Size clause given assume that the programmer
-- knows what he is doing, and expects the compiler behavior.
and then not Has_Object_Size_Clause (E)
+ -- It does not really make sense to warn for the minimum alignment
+ -- since the programmer could not get rid of the warning.
+
+ and then Alignment (E) > 1
+
-- Check for size not a multiple of alignment
and then RM_Size (E) mod (Alignment (E) * System_Storage_Unit) /= 0
end;
end if;
- -- Array type
-
- if Is_Array_Type (E) then
- Freeze_Array_Type (E);
-
-- For a class-wide type, the corresponding specific type is
-- frozen as well (RM 13.14(15))
- elsif Is_Class_Wide_Type (E) then
+ if Is_Class_Wide_Type (E) then
Freeze_And_Append (Root_Type (E), N, Result);
-- If the base type of the class-wide type is still incomplete,
@emph{Activate warnings for size not a multiple of alignment.}
-This switch activates warnings for cases of record types with
-specified @code{Size} and @code{Alignment} attributes where the
+This switch activates warnings for cases of array and record types
+with specified @code{Size} and @code{Alignment} attributes where the
size is not a multiple of the alignment, resulting in an object
size that is greater than the specified size. The default
is that such warnings are generated.
@emph{Suppress warnings for size not a multiple of alignment.}
-This switch suppresses warnings for cases of record types with
-specified @code{Size} and @code{Alignment} attributes where the
+This switch suppresses warnings for cases of array and record types
+with specified @code{Size} and @code{Alignment} attributes where the
size is not a multiple of the alignment, resulting in an object
-size that is greater than the specified size.
-The warning can also be
-suppressed by giving an explicit @code{Object_Size} value.
+size that is greater than the specified size. The warning can also
+be suppressed by giving an explicit @code{Object_Size} value.
@end table
@geindex -Wunused (gcc)