This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Issue missing warning for 'Size attribute

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  <>

	* 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  <>

	* gnat.dg/warn11.adb: New test.
	* gnat.dg/specs/ 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" }

   Put_Line ("MB'Size is " & Natural'Image (My_Integer'Size));
   Put_Line ("MB'Size is " & Natural'Image (My_Integer2'Size));

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]