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]

PATCH: Fix big-endian LP64 ObjC woes


ObjC was initializing 'long' fields with 'int' values, and was getting away with it on
most platforms, too. Thanks to Eric Botcazou and Ulrich Weigand for identifying the
problem and verifying the fix.


[gcc/objc/ChangeLog]
2004-09-24  Ziemowit Laski  <zlaski@apple.com>

	* objc-act.c (init_objc_symtab, init_module_descriptor,
	build_shared_structure_initializer): When initializing 'long'
	fields, ensure that the initializer value is also 'long'.

Index: gcc/objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.247
diff -u -3 -p -r1.247 objc-act.c
--- gcc/objc/objc-act.c 24 Sep 2004 21:38:04 -0000      1.247
+++ gcc/objc/objc-act.c 24 Sep 2004 23:03:34 -0000
@@ -1870,7 +1870,8 @@ init_objc_symtab (tree type)

/* sel_ref_cnt = { ..., 5, ... } */

- initlist = build_tree_list (NULL_TREE, build_int_cst (NULL_TREE, 0));
+ initlist = build_tree_list (NULL_TREE,
+ build_int_cst (long_integer_type_node, 0));


/* refs = { ..., _OBJC_SELECTOR_TABLE, ... } */

@@ -1969,12 +1970,13 @@ init_module_descriptor (tree type)

/* version = { 1, ... } */

-  expr = build_int_cst (NULL_TREE, OBJC_VERSION);
+  expr = build_int_cst (long_integer_type_node, OBJC_VERSION);
   initlist = build_tree_list (NULL_TREE, expr);

/* size = { ..., sizeof (struct _objc_module), ... } */

-  expr = size_in_bytes (objc_module_template);
+  expr = convert (long_integer_type_node,
+                 size_in_bytes (objc_module_template));
   initlist = tree_cons (NULL_TREE, expr, initlist);

/* name = { ..., "foo.m", ... } */
@@ -4850,13 +4852,17 @@ build_shared_structure_initializer (tree
initlist = tree_cons (NULL_TREE, default_conversion (name), initlist);


/* version = */
- initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
+ initlist = tree_cons (NULL_TREE, build_int_cst (long_integer_type_node, 0),
+ initlist);


/* info = */
- initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, status), initlist);
+ initlist = tree_cons (NULL_TREE,
+ build_int_cst (long_integer_type_node, status),
+ initlist);


/* instance_size = */
- initlist = tree_cons (NULL_TREE, size, initlist);
+ initlist = tree_cons (NULL_TREE, convert (long_integer_type_node, size),
+ initlist);


   /* objc_ivar_list = */
   if (!ivar_list)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]