This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Ada] Issue missing warning for 'Size attribute
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 May 2015 23:29:51 +0200
- Subject: [Ada] Issue missing warning for 'Size attribute
- Authentication-results: sourceware.org; auth=none
The documentation says that the compiler issues a warning for the 'Size
attribute on discrete types if the specified value is larger than 64, but we
failed to so for values between 65 and 128.
Tested on x86_64-suse-linux, applied on the mainline.
2015-05-25 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (maybe_pad_type): Do not apply adjustment to
original size for elementary types before issuing the size warning.
2015-05-25 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/warn11.adb: New test.
* gnat.dg/specs/alignment2.ads: Add dg-warning directive.
--
Eric Botcazou
Index: ada/gcc-interface/utils.c
===================================================================
--- ada/gcc-interface/utils.c (revision 223656)
+++ ada/gcc-interface/utils.c (working copy)
@@ -1426,7 +1426,7 @@ built:
if (CONTAINS_PLACEHOLDER_P (orig_size))
orig_size = max_size (orig_size, true);
- if (align)
+ if (align && AGGREGATE_TYPE_P (type))
orig_size = round_up (orig_size, align);
if (!operand_equal_p (size, orig_size, 0)
with Ada.Text_IO; use Ada.Text_IO;
procedure Warn11 is
type My_Integer is new Integer range 1 .. 10;
for My_Integer'Size use 65; -- { dg-warning "unused" }
type My_Integer2 is new Integer range 1 .. 10;
for My_Integer2'Size use 129; -- { dg-warning "unused" }
begin
Put_Line ("MB'Size is " & Natural'Image (My_Integer'Size));
Put_Line ("MB'Size is " & Natural'Image (My_Integer2'Size));
end;