* [Ada] Bug box on object of derived array type with repped enumeration index
@ 2010-06-17 9:45 Arnaud Charlet
0 siblings, 0 replies; only message in thread
From: Arnaud Charlet @ 2010-06-17 9:45 UTC (permalink / raw)
To: gcc-patches; +Cc: Gary Dismukes
[-- Attachment #1: Type: text/plain, Size: 2295 bytes --]
The compiler blows up on an object of a derived array type where the index
is of an enumeration type with specified representation and the component
is of a floating-point type. In this case, the derived type and its parent
type were not considered to have the same representation, because the component
size of the parent was not getting set by the front end's layout phase (only
array types with discrete components were set), whereas the derived type
had its component size set properly in Freeze_Type (because its parent type
was treated as packed due to the nonstandard representation of its index).
The layout for array types now sets the component size in the case of arrays
with components of any scalar type. This change also helps avoid expensive
(and unnecessary) representation conversions between derived array types
of this kind.
The package init_scalar_bug.adb, given below, must compile with only the
following warning output (or quietly with -gnatws):
init_scalar_bug.adb:13:11: warning: default initialization of "Result" may modify overlaid storage
init_scalar_bug.adb:13:11: warning: use pragma Import for "Result" to suppress initialization (RM B.1(24))
pragma Initialize_Scalars;
package Float_Arr_Pkg is
type Repped_Enum is (Enum_1, Enum_2, Enum_3);
for Repped_Enum use (Enum_1 => 1, Enum_2 => 2, Enum_3 => 3);
type Float_Array is array (Repped_Enum) of Float;
end Float_Arr_Pkg;
with System;
package Init_Scalar_Bug is
procedure Proc (Addr : System.Address);
end Init_Scalar_Bug;
pragma Initialize_Scalars;
with Float_Arr_Pkg;
package body Init_Scalar_Bug is
type New_Float_Array is new Float_Arr_Pkg.Float_Array;
procedure Proc (Addr : System.Address) is
Result : New_Float_Array;
for Result use at Addr;
begin
null;
end Proc;
end Init_Scalar_Bug;
Tested on x86_64-pc-linux-gnu, committed on trunk
2010-06-17 Gary Dismukes <dismukes@adacore.com>
* layout.adb (Layout_Type): Broaden test for setting an array type's
Component_Size to include all scalar types, not just discrete types
(components of real types were missed).
* sem_ch3.adb (Constrain_Index): Add missing setting of First_Literal
on the itype created for an index (consistent with Make_Index and
avoids possible Assert_Failures).
[-- Attachment #2: difs --]
[-- Type: text/plain, Size: 1099 bytes --]
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb (revision 160843)
+++ sem_ch3.adb (working copy)
@@ -11071,6 +11071,7 @@ package body Sem_Ch3 is
else
Set_Ekind (Def_Id, E_Enumeration_Subtype);
Set_Is_Character_Type (Def_Id, Is_Character_Type (T));
+ Set_First_Literal (Def_Id, First_Literal (T));
end if;
Set_Size_Info (Def_Id, (T));
Index: layout.adb
===================================================================
--- layout.adb (revision 160834)
+++ layout.adb (working copy)
@@ -2560,10 +2560,10 @@ package body Layout is
begin
-- For some reasons, access types can cause trouble, So let's
- -- just do this for discrete types ???
+ -- just do this for scalar types ???
if Present (CT)
- and then Is_Discrete_Type (CT)
+ and then Is_Scalar_Type (CT)
and then Known_Static_Esize (CT)
then
declare
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-06-17 8:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-17 9:45 [Ada] Bug box on object of derived array type with repped enumeration index Arnaud Charlet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).