This is the mail archive of the gcc-patches@gcc.gnu.org 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] | |
Tested on i686-linux, committed on trunk
This patch corrects a problem of incorrect Object_Size values being
passed to the back end. This is unlikely to cause any real problem
in practice, but can affect the behavior of the Object_Size attribute.
gnat.dg/assert1.adb should not raise any exception.
Anonymous access to subprograms generate an anonymous subprogram_type entity,
which carries the given profile and is used in analysis of calls. Itypes are
frozen on demand at the first point of use, or else by means of explicit
itype_references for gigi. For internal subprogram_types that correspond to
access parameters, it is necessary to freeze them (and their profiles) when the
enclosing subprogram profile is frozen. This should not be done when the formal
has a named access to subprogram parameter, because the named access will be
frozen through some other rule. This allows the profile of the access_to_subprogram
to mention types that are not yet frozen.
The following must compile quietly:
with Ada.Finalization;
generic
type T is private;
package Gen is
type wrapper is record
Ptr : T;
end record;
procedure Add (To : Wrapper; It : T);
end Gen;
package body Gen is
procedure Add (To : Wrapper; It : T) is begin null; end;
end Gen;
with Gen;
with Ada.Finalization;
package Pack is
type T is new Ada.Finalization.Controlled with private;
type Ptr is access procedure (Param : T'class);
private
package Inst is new Gen (Ptr);
type T is new Ada.Finalization.Controlled with null record;
end;
The use of pragma Convention to set a non-Ada convention for a
discriminated record is dubious, since there is no corresponding
type in any other language. With this patch, a warning is now
given for this usage (the warning is suppressed for an unchecked
union, since the whole point of unchecked union is interfacing).
1. with Interfaces; use Interfaces;
2. package k is
3. type Extra_Type is
4. array (Positive range <>) of Unsigned_8;
5.
6. pragma Pack (Extra_Type);
7.
8. subtype Extra_Length_Subtype is
9. Natural range 0 .. 2**16 - 1;
10.
11. type Wave_Format_Type (Extra_Length : Extra_Length_Subtype) is
12. record
13. Format_Tag : Unsigned_16;
14. Channel_Count : Unsigned_16;
15. Sample_Rate : Unsigned_32;
16. Byte_Rate : Unsigned_32;
17. Block_Align : Unsigned_16;
18. Bits_Per_Sample : Unsigned_16;
19. Extra : Extra_Type (1 .. Extra_Length);
20. end record;
21.
22. for Wave_Format_Type use
23. record
24. Format_Tag at 0 range 0 .. 15;
25. Channel_Count at 2 range 0 .. 15;
26. Sample_Rate at 4 range 0 .. 31;
27. Byte_Rate at 8 range 0 .. 31;
28. Block_Align at 12 range 0 .. 15;
29. Bits_Per_Sample at 14 range 0 .. 15;
30. Extra_Length at 16 range 0 .. 15;
31. end record;
32.
33. pragma Pack (Wave_Format_Type);
34. pragma Convention (C, Wave_Format_Type);
|
>>> warning: variant record has no equivalent in
non-Ada languages, use of convention for type
"Wave_Format_Type" is dubious
35. end k;
This patch causes the size of an enumeration object to be increased to
C int size if it is given convention C, and there is no explicit size
clause. This seems more compatible with expectations on the C side.
If the following test program is compiled with -gnatR2
package Pkg is
type Stack_Type is (
gdc_stack_depth,
gdc_stack_sum,
gdc_stack_beside,
gdc_stack_layer);
GDC_Stack_Type : Stack_Type;
pragma Import(C, GDC_Stack_Type, "GDC_stack_type");
end Pkg;
then the output is now
Representation information for unit Pkg (spec)
----------------------------------------------
for Stack_Type'Object_Size use 8;
for Stack_Type'Value_Size use 2;
for Stack_Type'Alignment use 1;
for Gdc_Stack_Type'Size use 32;
for Gdc_Stack_Type'Alignment use 4;
2007-06-06 Robert Dewar <dewar@adacore.com>
Ed Schonberg <schonberg@adacore.com>
* exp_pakd.adb (Expand_Packed_Not): Use RM_Size rather than ESize to
compute masking constant, since we now set Esize properly to the
underlying size.
(Create_Packed_Array_Type): Set proper Esize value adjusted as required
to match the alignment.
(Create_Packed_Array_Type): Use Short_Short_Unsigned as base type for
packed arrays of 8 bits or less.
* freeze.adb (Freeze_Entity): When freezing the formals of a
subprogram, freeze the designated type of a parameter of an access type
only if it is an access parameter.
Increase size of C convention enumeration object
(Freeze_Entity, array type case): Make sure Esize value is properly
adjusted for the alignment if it is known.
(Freeze_Entity, array type case): When checking bit packed arrays for
the size being incorrect, check RM_Size, not Esize.
(Freeze_Record_Type): Check for bad discriminated record convention
(In_Exp_Body): Return true if the body is generated for a subprogram
renaming, either an attribute renaming or a renaming as body.
(Check_Itype): If the designated type of an anonymous access component
is a non-protected subprogram type, indicate that it is frozen, to
prevent out-of-scope freeze node at some subsequent call.
(Freeze_Subprogram): On OpenVMS, reject descriptor passing mechanism
only if the subprogram is neither imported nor exported, as well as the
NCA descriptor class if the subprogram is exported.
Attachment:
difs
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |