re PR rtl-optimization/42522 ((zero_extract:SI (mem:QI) ...) misoptimized)
[gcc.git] / libobjc / gc.c
index a67ba1c985531e03f779c8a146ddae002caabff8..32fadc3afcdf390fad117ebe40a9329bacec1ca3 100644 (file)
@@ -1,5 +1,5 @@
 /* Basic data types for Objective C.
-   Copyright (C) 1998, 2002, 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1998-2015 Free Software Foundation, Inc.
    Contributed by Ovidiu Predescu.
 
 This file is part of GCC.
@@ -24,15 +24,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
 #include "objc-private/common.h"
-#include "tconfig.h"
 #include "objc/objc.h"
-#include "objc/encoding.h"
 
+#if OBJC_WITH_GC
+
+#include "tconfig.h"
 #include <assert.h>
+#include <ctype.h> /* For isdigit.  */
 #include <string.h>
 #include <stdlib.h>
-
-#if OBJC_WITH_GC
+#include "objc/runtime.h"
+#include "objc-private/module-abi-8.h"
 
 #include <gc.h>
 #include <limits.h>
@@ -301,7 +303,7 @@ __objc_generate_gc_type_description (Class class)
 
   /* The number of bits in the mask is the size of an instance in bytes divided
      by the size of a pointer. */
-  bits_no = (ROUND (class_get_instance_size (class), sizeof (void *))
+  bits_no = (ROUND (class_getInstanceSize (class), sizeof (void *))
              / sizeof (void *));
   size = ROUND (bits_no, BITS_PER_WORD) / BITS_PER_WORD;
   mask = objc_atomic_malloc (size * sizeof (int));
@@ -421,11 +423,15 @@ class_ivar_set_gcinvisible (Class class, const char *ivarname,
 
          /* The variable is gc visible so we make it gc_invisible.  */
          new_type = objc_malloc (strlen(ivar->ivar_type) + 2);
+
+         /* Copy the variable name.  */
          len = (type - ivar->ivar_type);
          memcpy (new_type, ivar->ivar_type, len);
-         new_type[len] = 0;
-         strcat (new_type, "!");
-         strcat (new_type, type);
+         /* Add '!'.  */
+         new_type[len++] = _C_GCINVISIBLE;
+         /* Copy the original types.  */
+         strcpy (new_type + len, type);
+
          ivar->ivar_type = new_type;
        }