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]

[objc] fix most alpha regressions


For a while now (don't know how long) we've been miscompiling many of
the data structures the objc front end emits.  The problem was that the
integers stored in the constructor slots were not of the right type --
they were 'int' instead of 'long'.  This resulted in e.g.

@@ -2891,7 +2869,6 @@
        .size   _OBJC_MODULES,32
 _OBJC_MODULES:
        .quad 8
-       .zero   4
        .quad 32
        .quad _OBJC_CLASS_NAME_1
        .quad _OBJC_SYMBOLS

which, naturally, results in quick crashes at startup.

I started to fix the types at the point that they are built, but there
are a _lot_ of them, and it isn't always obvious what the correct type
is.  Easier is to hook into the build_constructor function cleverly
provided and adjust the types there.

Tested on alphaev6-linux.  Ok?


r~


	* objc/objc-act.c (build_constructor): Cast initializer values
	to the proper field types.

Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.112
diff -c -p -d -r1.112 objc-act.c
*** objc-act.c	2001/12/04 00:25:20	1.112
--- objc-act.c	2001/12/09 02:56:59
*************** static tree
*** 1371,1378 ****
  build_constructor (type, elts)
       tree type, elts;
  {
!   tree constructor = build (CONSTRUCTOR, type, NULL_TREE, elts);
  
    TREE_CONSTANT (constructor) = 1;
    TREE_STATIC (constructor) = 1;
    TREE_READONLY (constructor) = 1;
--- 1371,1397 ----
  build_constructor (type, elts)
       tree type, elts;
  {
!   tree constructor, f, e;
  
+   /* ??? Most of the places that we build constructors, we don't fill in
+      the type of integers properly.  Convert them all en masse.  */
+   if (TREE_CODE (type) == ARRAY_TYPE)
+     {
+       f = TREE_TYPE (type);
+       if (TREE_CODE (f) == POINTER_TYPE || TREE_CODE (f) == INTEGER_TYPE)
+ 	for (e = elts; e ; e = TREE_CHAIN (e))
+ 	  TREE_VALUE (e) = convert (f, TREE_VALUE (e));
+     }
+   else
+     {
+       f = TYPE_FIELDS (type);
+       for (e = elts; e ; e = TREE_CHAIN (e), f = TREE_CHAIN (f))
+ 	if (TREE_CODE (TREE_TYPE (f)) == POINTER_TYPE
+ 	    || TREE_CODE (TREE_TYPE (f)) == INTEGER_TYPE)
+ 	  TREE_VALUE (e) = convert (TREE_TYPE (f), TREE_VALUE (e));
+     }
+ 
+   constructor = build (CONSTRUCTOR, type, NULL_TREE, elts);
    TREE_CONSTANT (constructor) = 1;
    TREE_STATIC (constructor) = 1;
    TREE_READONLY (constructor) = 1;


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