+2009-10-02 Eric Botcazou <ebotcazou@adacore.com>
+
+ * stor-layout.c (layout_type) <ARRAY_TYPE>: Make sure that an array
+ of zero-sized element is zero-sized regardless of its extent.
+
2009-10-02 Jakub Jelinek <jakub@redhat.com>
PR debug/40521
tree element_size = TYPE_SIZE (element);
tree length;
+ /* Make sure that an array of zero-sized element is zero-sized
+ regardless of its extent. */
+ if (integer_zerop (element_size))
+ length = size_zero_node;
+
/* The initial subtraction should happen in the original type so
that (possible) negative values are handled appropriately. */
- length = size_binop (PLUS_EXPR, size_one_node,
- fold_convert (sizetype,
- fold_build2_loc (input_location,
- MINUS_EXPR,
- TREE_TYPE (lb),
- ub, lb)));
+ else
+ length
+ = size_binop (PLUS_EXPR, size_one_node,
+ fold_convert (sizetype,
+ fold_build2_loc (input_location,
+ MINUS_EXPR,
+ TREE_TYPE (lb),
+ ub, lb)));
TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
fold_convert (bitsizetype,
+2009-10-02 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/array10.adb: New test.
+ * gnat.dg/object_overflow.adb: Tweak.
+
2009-10-02 Jack Howarth <howarth@bromo.med.uc.edu>
* gcc.dg/guality/guality.exp: Disable on darwin.
--- /dev/null
+-- { dg-do run }
+-- Verify that an array of non-aliased zero-sized element is zero-sized
+
+procedure Array10 is
+
+ type Rec is null record;
+
+ type Arr1 is array (1..8) of Rec;
+ type Arr2 is array (Long_Integer) of Rec;
+
+ R : Rec;
+ A1 : Arr1;
+ A2 : Arr2;
+
+begin
+ if Rec'Size /= 0 then
+ raise Program_Error;
+ end if;
+ if Arr1'Size /= 0 then
+ raise Program_Error;
+ end if;
+ if Arr2'Size /= 0 then
+ raise Program_Error;
+ end if;
+end;
procedure Object_Overflow is
- type Rec is null record;
+ procedure Proc (x : Boolean) is begin null; end;
- procedure Proc (x : Rec) is begin null; end;
-
- type Arr is array(Long_Integer) of Rec;
+ type Arr is array(Long_Integer) of Boolean;
Obj : Arr; -- { dg-warning "Storage_Error will be raised" }
begin
+ Obj(1) := True;
Proc (Obj(1));
end;