diff options
| author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-02-29 02:34:48 +0000 |
|---|---|---|
| committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-02-29 02:34:48 +0000 |
| commit | ab7943b9fd874a88ec7067561e0f6a2d69c5d396 (patch) | |
| tree | 9d32681a03d3ca309091c1dee14f1053a1621f84 /gcc/ch/typeck.c | |
| parent | 78fe751b3a78922e64f0d58744b18d675a5a7141 (diff) | |
| download | ppe42-gcc-ab7943b9fd874a88ec7067561e0f6a2d69c5d396.tar.gz ppe42-gcc-ab7943b9fd874a88ec7067561e0f6a2d69c5d396.zip | |
* Eliminate DECL_FIELD_SIZE.
* builtins.c (built_in_class_names, built_in_names): New variables.
* c-decl.c (finish_struct): Set specified size in DECL_SIZE.
* expr.c (expand_expr, case COMPONENT_REF): Get field size from
DECL_SIZE, not DECL_FIELD_SIZE.
* print-tree.c (print_node): Remove code that prints extra blank
lines in some cases.
Properly handle inline and builtin function cases.
* stor-layout.c (layout_decl): Get specified size from DEC_SIZE.
* tree.h (built_in_class_named, built_in_names): New declarations.
(union tree_decl): Rename internal unions to u1 and u2 and change
some of their components.
Add new field built_in_class.
(DECL_ALIGN, DECL_INCOMING_RTL, DECL_SAVED_INSNS, DECL_FRAME_SIZE):
Reflect above changes.
(DECL_FUNCTION_CODE, DECL_BUILT_IN_CLASS): Likewise.
(DECL_SET_FUNCTION_CODE, DECL_FIELD_SIZE): Deleted.
* objc/objc-act.c (objc_copy_list): Use DECL_SIZE, not DECL_FIELD_SIZE.
(encode_field_decl): Likewise; also remove obsolete test for bitfield.
* ch/ch-tree.h (DECL_ACTION_NESTING_LEVEL): Use new tree union name.
* ch/decl.c (finish_struct): Don't clear DECL_FIELD_SIZE.
* ch/typeck.c (make_chill_struct_type): Likewise.
(apply_decl_field_layout): General cleanup.
Set DECL_SIZE instead of DECL_FIELD_SIZE.
* cp/class.c (build_vtbl_or_vbase_field, check_methods): Don't clear
DECL_FIELD_SIZE.
(check_bitfield_decl, check_field_decls): Set DECL_SIZE, not
DECL_FIELD_SIZE.
* cp/rtti.c (expand_class_desc): Likewise.
* cp/cp-tree.h (DECL_INIT_PRIORITY): Use underlying union name.
(THUNK_VCALL_OFFSET): Likewise.
(THUNK_DELTA): Reflect changes in ../tree.h.
* java/java-tree.h (LABEL_PC): Relect name changes in ../tree.h.
(DECL_BIT_INDEX): Use underlying representation.
* java/parse.h (DECL_INHERITED_SOURCE_LINE): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32249 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ch/typeck.c')
| -rw-r--r-- | gcc/ch/typeck.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/gcc/ch/typeck.c b/gcc/ch/typeck.c index 8c74896b52a..2fe1af418f4 100644 --- a/gcc/ch/typeck.c +++ b/gcc/ch/typeck.c @@ -2992,16 +2992,12 @@ make_chill_struct_type (fieldlist) tree fieldlist; { tree t, x; - if (TREE_UNION_ELEM (fieldlist)) - t = make_node (UNION_TYPE); - else - t = make_node (RECORD_TYPE); + + t = make_node (TREE_UNION_ELEM (fieldlist) ? UNION_TYPE : RECORD_TYPE); + /* Install struct as DECL_CONTEXT of each field decl. */ for (x = fieldlist; x; x = TREE_CHAIN (x)) - { - DECL_CONTEXT (x) = t; - DECL_FIELD_SIZE (x) = 0; - } + DECL_CONTEXT (x) = t; /* Delete all duplicate fields from the fieldlist */ for (x = fieldlist; x && TREE_CHAIN (x);) @@ -3033,31 +3029,35 @@ make_chill_struct_type (fieldlist) return t; } -/* decl is a FIELD_DECL. - DECL_INIT (decl) is (NULL_TREE, integer_one_node, integer_zero_node, tree_list), - meaning (default, pack, nopack, POS (...) ). +/* DECL is a FIELD_DECL. + DECL_INIT (decl) is + (NULL_TREE, integer_one_node, integer_zero_node, tree_list) + meaning + (default, pack, nopack, POS (...) ). + The return value is a boolean: 1 if POS specified, 0 if not */ + static int apply_chill_field_layout (decl, next_struct_offset) tree decl; - int* next_struct_offset; + int *next_struct_offset; { - tree layout, type, temp, what; - int word = 0, wordsize, start_bit, offset, length, natural_length; + tree layout = DECL_INITIAL (decl); + tree type = TREE_TYPE (decl); + tree temp, what; + HOST_WIDE_INT word = 0; + HOST_WIDE_INT wordsize, start_bit, offset, length, natural_length; int pos_error = 0; - int is_discrete; + int is_discrete = discrete_type_p (type); - type = TREE_TYPE (decl); - is_discrete = discrete_type_p (type); if (is_discrete) - natural_length = get_type_precision (TYPE_MIN_VALUE (type), TYPE_MAX_VALUE (type)); + natural_length + = get_type_precision (TYPE_MIN_VALUE (type), TYPE_MAX_VALUE (type)); else natural_length = TREE_INT_CST_LOW (TYPE_SIZE (type)); - layout = DECL_INITIAL (decl); if (layout == integer_zero_node) /* NOPACK */ { - DECL_PACKED (decl) = 0; *next_struct_offset += natural_length; return 0; /* not POS */ } @@ -3065,14 +3065,14 @@ apply_chill_field_layout (decl, next_struct_offset) if (layout == integer_one_node) /* PACK */ { if (is_discrete) - DECL_BIT_FIELD (decl) = 1; - else { - DECL_BIT_FIELD (decl) = 0; - DECL_ALIGN (decl) = BITS_PER_UNIT; + DECL_BIT_FIELD (decl) = 1; + DECL_SIZE (decl) = bitsize_int (natural_length); } + else + DECL_ALIGN (decl) = BITS_PER_UNIT; + DECL_PACKED (decl) = 1; - DECL_FIELD_SIZE (decl) = natural_length; *next_struct_offset += natural_length; return 0; /* not POS */ } @@ -3090,7 +3090,7 @@ apply_chill_field_layout (decl, next_struct_offset) else { word = TREE_INT_CST_LOW (TREE_PURPOSE (temp)); - if (word < 0) + if (tree_int_cst_sgn (TREE_PURPOSE (temp)) < 0) { error ("Starting word in POS must be >= 0"); word = 0; @@ -3114,7 +3114,7 @@ apply_chill_field_layout (decl, next_struct_offset) else { start_bit = TREE_INT_CST_LOW (TREE_PURPOSE (temp)); - if (start_bit < 0) + if (tree_int_cst_sgn (TREE_PURPOSE (temp)) < 0) { error ("Starting bit in POS must be >= 0"); start_bit = *next_struct_offset - offset; @@ -3142,7 +3142,7 @@ apply_chill_field_layout (decl, next_struct_offset) else { length = TREE_INT_CST_LOW (TREE_VALUE (temp)); - if (length <= 0) + if (tree_int_cst_sgn (TREE_VALUE (temp)) < 0) { error ("Length in POS must be > 0"); length = natural_length; @@ -3159,7 +3159,8 @@ apply_chill_field_layout (decl, next_struct_offset) } else { - int end_bit = TREE_INT_CST_LOW (TREE_VALUE (temp)); + HOST_WIDE_INT end_bit = TREE_INT_CST_LOW (TREE_VALUE (temp)); + if (end_bit < start_bit) { error ("End bit in POS must be >= the start bit"); @@ -3174,6 +3175,7 @@ apply_chill_field_layout (decl, next_struct_offset) length = end_bit - start_bit + 1; } } + if (length != natural_length && ! pos_error) { sorry ("The length specified on POS must be the natural length of the field type"); @@ -3189,7 +3191,10 @@ apply_chill_field_layout (decl, next_struct_offset) DECL_PACKED (decl) = 1; DECL_BIT_FIELD (decl) = is_discrete; - DECL_FIELD_SIZE (decl) = length; + + if (is_discrete) + DECL_SIZE (decl) = bitsize_int (length); + *next_struct_offset += natural_length; return 1; /* was POS */ @@ -3209,12 +3214,7 @@ layout_chill_struct_type (t) old_momentary = suspend_momentary (); - /* Process specified field sizes. - Set DECL_FIELD_SIZE to the specified size, or 0 if none specified. - The specified size is found in the DECL_INITIAL. - Store 0 there, except for ": 0" fields (so we can find them - and delete them, below). */ - + /* Process specified field sizes. */ next_struct_offset = 0; for (x = fieldlist; x; x = TREE_CHAIN (x)) { |

