diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2010-11-09 11:59:55 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2010-11-09 11:59:55 +0000 |
commit | 98cd3025d4d3204a18f327627a61b6773fd377a5 (patch) | |
tree | f3683767b5743cd5036a7a65c1816ad7f965366b /gcc | |
parent | b9cb66d281d279a13ed9628a9046e4523cb677d5 (diff) | |
download | gcc-98cd3025d4d3204a18f327627a61b6773fd377a5.zip gcc-98cd3025d4d3204a18f327627a61b6773fd377a5.tar.gz gcc-98cd3025d4d3204a18f327627a61b6773fd377a5.tar.bz2 |
tree.h (contains_placeholder_p): Fix comment.
* tree.h (contains_placeholder_p): Fix comment.
(type_contains_placeholder_p): Adjust comment.
* tree.c (contains_placeholder_p): Fix comment.
(type_contains_placeholder_1): Do not recurse on pointed-to types and
adjust comment.
(type_contains_placeholder_p): Add comment.
ada/
* gcc-interface/decl.c (finish_fat_pointer_type): New function.
(gnat_to_gnu_entity) <E_Array_Type>: Use it to build the fat pointer
type.
<E_Access_Type>: Likewise.
From-SVN: r166484
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 58 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/static_initializer5.ads | 13 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/specs/static_initializer5_pkg.ads | 17 | ||||
-rw-r--r-- | gcc/tree.c | 19 | ||||
-rw-r--r-- | gcc/tree.h | 13 |
8 files changed, 98 insertions, 43 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95a436f..3db4991 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-11-09 Eric Botcazou <ebotcazou@adacore.com> + + * tree.h (contains_placeholder_p): Fix comment. + (type_contains_placeholder_p): Adjust comment. + * tree.c (contains_placeholder_p): Fix comment. + (type_contains_placeholder_1): Do not recurse on pointed-to types and + adjust comment. + (type_contains_placeholder_p): Add comment. + 2010-11-09 Paul Koning <ni1d@arrl.net> * config/pdp11/pdp11.c (pdp11_assemble_integer): Clean up fix for diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index ff25a9f..f4cc6a2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2010-11-09 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/decl.c (finish_fat_pointer_type): New function. + (gnat_to_gnu_entity) <E_Array_Type>: Use it to build the fat pointer + type. + <E_Access_Type>: Likewise. + 2010-11-02 Eric Botcazou <ebotcazou@adacore.com> * gcc-interface/gigi.h (add_stmt_force): Declare. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index b7fe778..c2b8278 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -177,6 +177,7 @@ static tree create_variant_part_from (tree, VEC(variant_desc,heap) *, tree, tree, VEC(subst_pair,heap) *); static void copy_and_substitute_in_size (tree, tree, VEC(subst_pair,heap) *); static void rest_of_type_decl_compilation_no_defer (tree); +static void finish_fat_pointer_type (tree, tree); /* The relevant constituents of a subprogram binding to a GCC builtin. Used to pass around calls performing profile compatibilty checks. */ @@ -188,7 +189,6 @@ typedef struct { } intrin_binding_t; static bool intrin_profiles_compatible_p (intrin_binding_t *); - /* Given GNAT_ENTITY, a GNAT defining identifier node, which denotes some Ada entity, return the equivalent GCC tree for that entity (a ..._DECL node) @@ -1915,23 +1915,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Build the fat pointer type. Use a "void *" object instead of a pointer to the array type since we don't have the array type yet (it will reference the fat pointer via the bounds). */ - tem = chainon (chainon (NULL_TREE, - create_field_decl (get_identifier ("P_ARRAY"), - ptr_void_type_node, - gnu_fat_type, NULL_TREE, - NULL_TREE, 0, 0)), - create_field_decl (get_identifier ("P_BOUNDS"), - gnu_ptr_template, - gnu_fat_type, NULL_TREE, - NULL_TREE, 0, 0)); - - /* Make sure we can put this into a register. */ - TYPE_ALIGN (gnu_fat_type) = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE); - - /* Do not emit debug info for this record type since the types of its - fields are still incomplete at this point. */ - finish_record_type (gnu_fat_type, tem, 0, false); - TYPE_FAT_POINTER_P (gnu_fat_type) = 1; + tem + = create_field_decl (get_identifier ("P_ARRAY"), ptr_void_type_node, + gnu_fat_type, NULL_TREE, NULL_TREE, 0, 0); + TREE_CHAIN (tem) + = create_field_decl (get_identifier ("P_BOUNDS"), gnu_ptr_template, + gnu_fat_type, NULL_TREE, NULL_TREE, 0, 0); + finish_fat_pointer_type (gnu_fat_type, tem); /* Build a reference to the template from a PLACEHOLDER_EXPR that is the fat pointer. This will be used to access the individual @@ -3587,15 +3577,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) = create_field_decl (get_identifier ("P_BOUNDS"), gnu_ptr_template, gnu_type, NULL_TREE, NULL_TREE, 0, 0); - - /* Make sure we can place this into a register. */ - TYPE_ALIGN (gnu_type) - = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE); - TYPE_FAT_POINTER_P (gnu_type) = 1; - - /* Do not emit debug info for this record type since the types - of its fields are incomplete. */ - finish_record_type (gnu_type, fields, 0, false); + finish_fat_pointer_type (gnu_type, fields); TYPE_OBJECT_RECORD_TYPE (gnu_desig_type) = make_node (RECORD_TYPE); @@ -5125,6 +5107,28 @@ rest_of_type_decl_compilation_no_defer (tree decl) } } +/* Given a record type RECORD_TYPE and a list of FIELD_DECL nodes FIELD_LIST, + finish constructing the record type as a fat pointer type. */ + +static void +finish_fat_pointer_type (tree record_type, tree field_list) +{ + /* Make sure we can put it into a register. */ + TYPE_ALIGN (record_type) = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE); + + /* Show what it really is. */ + TYPE_FAT_POINTER_P (record_type) = 1; + + /* Do not emit debug info for it since the types of its fields may still be + incomplete at this point. */ + finish_record_type (record_type, field_list, 0, false); + + /* Force type_contains_placeholder_p to return true on it. Although the + PLACEHOLDER_EXPRs are referenced only indirectly, this isn't a pointer + type but the representation of the unconstrained array. */ + TYPE_CONTAINS_PLACEHOLDER_INTERNAL (record_type) = 2; +} + /* Finalize any From_With_Type incomplete types. We do this after processing our compilation unit and after processing its spec, if this is a body. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 07b1a58..6e1dde8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-11-09 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/specs/static_initializer5.ads: New test. + * gnat.dg/specs/static_initializer5_pkg.ads: New helper. + 2010-11-09 Jakub Jelinek <jakub@redhat.com> PR middle-end/46360 diff --git a/gcc/testsuite/gnat.dg/specs/static_initializer5.ads b/gcc/testsuite/gnat.dg/specs/static_initializer5.ads new file mode 100644 index 0000000..29845ce --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/static_initializer5.ads @@ -0,0 +1,13 @@ +-- { dg-do compile } + +with Static_Initializer5_Pkg; use Static_Initializer5_Pkg; + +package Static_Initializer5 is + + type Derived is new Rec with record + Target : Boolean; + end record; + + Null_Derived : constant Derived := (Null_Rec with Target => False); + +end Static_Initializer5; diff --git a/gcc/testsuite/gnat.dg/specs/static_initializer5_pkg.ads b/gcc/testsuite/gnat.dg/specs/static_initializer5_pkg.ads new file mode 100644 index 0000000..16a8f72 --- /dev/null +++ b/gcc/testsuite/gnat.dg/specs/static_initializer5_pkg.ads @@ -0,0 +1,17 @@ +package Static_Initializer5_Pkg is + + type Arr is array (Positive range <>) of Character; + + type Buffer_Type (Length : Positive) is record + Content : Arr (1 .. Length); + end record; + + type Buffer_Access is access Buffer_Type; + + type Rec is tagged record + Buffer : Buffer_Access; + end record; + + Null_Rec : constant Rec := (Buffer => null); + +end Static_Initializer5_Pkg; @@ -2795,8 +2795,8 @@ process_call_operands (tree t) TREE_READONLY (t) = read_only; } -/* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size - or offset that depends on a field within a record. */ +/* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a + size or offset that depends on a field within a record. */ bool contains_placeholder_p (const_tree exp) @@ -2882,9 +2882,9 @@ contains_placeholder_p (const_tree exp) return 0; } -/* Return true if any part of the computation of TYPE involves a - PLACEHOLDER_EXPR. This includes size, bounds, qualifiers - (for QUAL_UNION_TYPE) and field positions. */ +/* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR + directly. This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and + field positions. */ static bool type_contains_placeholder_1 (const_tree type) @@ -2893,7 +2893,8 @@ type_contains_placeholder_1 (const_tree type) the case of arrays) type involves a placeholder, this type does. */ if (CONTAINS_PLACEHOLDER_P (TYPE_SIZE (type)) || CONTAINS_PLACEHOLDER_P (TYPE_SIZE_UNIT (type)) - || (TREE_TYPE (type) != 0 + || (!POINTER_TYPE_P (type) + && TREE_TYPE (type) && type_contains_placeholder_p (TREE_TYPE (type)))) return true; @@ -2921,8 +2922,8 @@ type_contains_placeholder_1 (const_tree type) || CONTAINS_PLACEHOLDER_P (TYPE_MAX_VALUE (type))); case ARRAY_TYPE: - /* We're already checked the component type (TREE_TYPE), so just check - the index type. */ + /* We have already checked the component type above, so just check the + domain type. */ return type_contains_placeholder_p (TYPE_DOMAIN (type)); case RECORD_TYPE: @@ -2947,6 +2948,8 @@ type_contains_placeholder_1 (const_tree type) } } +/* Wrapper around above function used to cache its result. */ + bool type_contains_placeholder_p (tree type) { @@ -4588,11 +4588,8 @@ extern tree skip_simple_arithmetic (tree); enum tree_node_structure_enum tree_node_structure (const_tree); -/* Return 1 if EXP contains a PLACEHOLDER_EXPR; i.e., if it represents a size - or offset that depends on a field within a record. - - Note that we only allow such expressions within simple arithmetic - or a COND_EXPR. */ +/* Return true if EXP contains a PLACEHOLDER_EXPR, i.e. if it represents a + size or offset that depends on a field within a record. */ extern bool contains_placeholder_p (const_tree); @@ -4602,9 +4599,9 @@ extern bool contains_placeholder_p (const_tree); #define CONTAINS_PLACEHOLDER_P(EXP) \ ((EXP) != 0 && ! TREE_CONSTANT (EXP) && contains_placeholder_p (EXP)) -/* Return 1 if any part of the computation of TYPE involves a PLACEHOLDER_EXPR. - This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and field - positions. */ +/* Return true if any part of the structure of TYPE involves a PLACEHOLDER_EXPR + directly. This includes size, bounds, qualifiers (for QUAL_UNION_TYPE) and + field positions. */ extern bool type_contains_placeholder_p (tree); |