diff options
author | Ziemowit Laski <zlaski@apple.com> | 2002-08-20 01:27:39 +0000 |
---|---|---|
committer | Ziemowit Laski <zlaski@gcc.gnu.org> | 2002-08-20 01:27:39 +0000 |
commit | 1bd5981b33ab83a5f1745bda7bd7d97d23e84f4b (patch) | |
tree | 5bfe74464a81284da9557cd95333dffa30318d52 /gcc/objc | |
parent | 2bf087c09eb697b798574e77845466d248381bc6 (diff) | |
download | gcc-1bd5981b33ab83a5f1745bda7bd7d97d23e84f4b.zip gcc-1bd5981b33ab83a5f1745bda7bd7d97d23e84f4b.tar.gz gcc-1bd5981b33ab83a5f1745bda7bd7d97d23e84f4b.tar.bz2 |
objc-act.c (build_ivar_chain): Remove.
[gcc]
2002-08-19 Ziemowit Laski <zlaski@apple.com>
* objc/objc-act.c (build_ivar_chain): Remove.
(objc_copy_list): Likewise.
(get_class_ivars): Inline call to removed build_ivar_chain
function. Save off a clean copy of ivars in the CLASS_OWN_IVARS
slot; use that slot (rather than CLASS_IVARS) when accessing
ivars for base classes. Call copy_list and chainon instead of
objc_copy_list.
(build_private_template): Call get_class_ivars instead of
build_ivar_chain.
(start_class): Allocate room for the CLASS_OWN_IVARS slot.
(continue_class): Call get_class_ivars instead of
build_ivar_chain.
(encode_field_decl): Check for DECL_BIT_FIELD_TYPE instead
of DECL_BIT_FIELD (which may have been cleared).
* objc/objc-act.h (CLASS_OWN_IVARS): New accessor macro.
[gcc/testsuite]
2002-08-19 Ziemowit Laski <zlaski@apple.com>
* objc.dg/bitfield-1.m: New test.
* objc.dg/bitfield-2.m: New test.
From-SVN: r56451
Diffstat (limited to 'gcc/objc')
-rw-r--r-- | gcc/objc/objc-act.c | 76 | ||||
-rw-r--r-- | gcc/objc/objc-act.h | 1 |
2 files changed, 18 insertions, 59 deletions
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 44edf72..7841307 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -128,7 +128,6 @@ static tree build_objc_method_call PARAMS ((int, tree, tree, static void generate_strings PARAMS ((void)); static tree get_proto_encoding PARAMS ((tree)); static void build_selector_translation_table PARAMS ((void)); -static tree build_ivar_chain PARAMS ((tree, int)); static tree objc_add_static_instance PARAMS ((tree, tree)); @@ -249,7 +248,6 @@ static tree build_typed_selector_reference PARAMS ((tree, tree)); static tree build_selector_reference PARAMS ((tree)); static tree build_class_reference_decl PARAMS ((void)); static void add_class_reference PARAMS ((tree)); -static tree objc_copy_list PARAMS ((tree, tree *)); static tree build_protocol_template PARAMS ((void)); static tree build_descriptor_table_initializer PARAMS ((tree, tree)); static tree build_method_prototype_list_template PARAMS ((tree, int)); @@ -2277,51 +2275,23 @@ lookup_interface (ident) return NULL_TREE; } -static tree -objc_copy_list (list, head) - tree list; - tree *head; -{ - tree newlist = NULL_TREE, tail = NULL_TREE; - - while (list) - { - tail = copy_node (list); - - /* The following statement fixes a bug when inheriting instance - variables that are declared to be bitfields. finish_struct - expects to find the width of the bitfield in DECL_INITIAL. */ - if (DECL_BIT_FIELD (tail) && DECL_INITIAL (tail) == 0) - DECL_INITIAL (tail) = DECL_SIZE (tail); - - newlist = chainon (newlist, tail); - list = TREE_CHAIN (list); - } - - *head = newlist; - return tail; -} - -/* Used by: build_private_template, get_class_ivars, and - continue_class. COPY is 1 when called from @defs. In this case - copy all fields. Otherwise don't copy leaf ivars since we rely on - them being side-effected exactly once by finish_struct. */ +/* Used by: build_private_template, continue_class, + and for @defs constructs. */ -static tree -build_ivar_chain (interface, copy) +tree +get_class_ivars (interface) tree interface; - int copy; { tree my_name, super_name, ivar_chain; my_name = CLASS_NAME (interface); super_name = CLASS_SUPER_NAME (interface); + ivar_chain = CLASS_IVARS (interface); - /* Possibly copy leaf ivars. */ - if (copy) - objc_copy_list (CLASS_IVARS (interface), &ivar_chain); - else - ivar_chain = CLASS_IVARS (interface); + /* Save off a pristine copy of the leaf ivars (i.e, those not + inherited from a super class). */ + if (!CLASS_OWN_IVARS (interface)) + CLASS_OWN_IVARS (interface) = copy_list (ivar_chain); while (super_name) { @@ -2345,14 +2315,14 @@ build_ivar_chain (interface, copy) my_name = CLASS_NAME (interface); super_name = CLASS_SUPER_NAME (interface); - op1 = CLASS_IVARS (interface); + op1 = CLASS_OWN_IVARS (interface); if (op1) { - tree head, tail = objc_copy_list (op1, &head); + tree head = copy_list (op1); /* Prepend super class ivars...make a copy of the list, we do not want to alter the original. */ - TREE_CHAIN (tail) = ivar_chain; + chainon (head, ivar_chain); ivar_chain = head; } } @@ -2379,7 +2349,7 @@ build_private_template (class) { uprivate_record = start_struct (RECORD_TYPE, CLASS_NAME (class)); - ivar_context = build_ivar_chain (class, 0); + ivar_context = get_class_ivars (class); finish_struct (uprivate_record, ivar_context, NULL_TREE); @@ -5660,18 +5630,6 @@ is_public (expr, identifier) return 1; } - -/* Implement @defs (<classname>) within struct bodies. */ - -tree -get_class_ivars (interface) - tree interface; -{ - /* Make sure we copy the leaf ivars in case @defs is used in a local - context. Otherwise finish_struct will overwrite the layout info - using temporary storage. */ - return build_ivar_chain (interface, 1); -} /* Make sure all entries in CHAIN are also in LIST. */ @@ -5903,7 +5861,7 @@ start_class (code, class_name, super_name, protocol_list) } class = make_node (code); - TYPE_BINFO (class) = make_tree_vec (5); + TYPE_BINFO (class) = make_tree_vec (6); CLASS_NAME (class) = class_name; CLASS_SUPER_NAME (class) = super_name; @@ -6093,7 +6051,7 @@ continue_class (class) if (!TYPE_FIELDS (record)) { - finish_struct (record, build_ivar_chain (class, 0), NULL_TREE); + finish_struct (record, get_class_ivars (class), NULL_TREE); CLASS_STATIC_TEMPLATE (class) = record; /* Mark this record as a class template for static typing. */ @@ -6717,14 +6675,14 @@ encode_field_decl (field_decl, curtype, format) the bitfield typing information. */ if (flag_next_runtime) { - if (DECL_BIT_FIELD (field_decl)) + if (DECL_BIT_FIELD_TYPE (field_decl)) encode_bitfield (tree_low_cst (DECL_SIZE (field_decl), 1)); else encode_type (TREE_TYPE (field_decl), curtype, format); } else { - if (DECL_BIT_FIELD (field_decl)) + if (DECL_BIT_FIELD_TYPE (field_decl)) encode_complete_bitfield (int_bit_position (field_decl), DECL_BIT_FIELD_TYPE (field_decl), tree_low_cst (DECL_SIZE (field_decl), 1)); diff --git a/gcc/objc/objc-act.h b/gcc/objc/objc-act.h index aebccf8..af10387 100644 --- a/gcc/objc/objc-act.h +++ b/gcc/objc/objc-act.h @@ -97,6 +97,7 @@ tree build_encode_expr PARAMS ((tree)); #define CLASS_STATIC_TEMPLATE(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 2) #define CLASS_CATEGORY_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 3) #define CLASS_PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 4) +#define CLASS_OWN_IVARS(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 5) #define PROTOCOL_NAME(CLASS) ((CLASS)->type.name) #define PROTOCOL_LIST(CLASS) TREE_VEC_ELT (TYPE_BINFO (CLASS), 0) #define PROTOCOL_NST_METHODS(CLASS) ((CLASS)->type.minval) |