OSDN Git Service

PR c++/60046
[pf3gnuchains/gcc-fork.git] / gcc / objc / objc-runtime-shared-support.c
index dff1d46..7d478d9 100644 (file)
@@ -41,16 +41,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "objcp-decl.h"
 #endif  /* OBJCPLUS */
 
-#include "obstack.h"
-
-/* These are only used for encoding ivars.  */
-extern struct obstack util_obstack;
-extern char *util_firstobj;
-
 /* Hooks for string decls etc.  */
 #include "objc-runtime-hooks.h"
 
 #include "objc-runtime-shared-support.h"
+#include "objc-encoding.h"
 
 /* rt_trees identifiers - shared between NeXT implementations.  These allow
    the FE to tag meta-data in a manner that survives LTO and can be used when
@@ -159,8 +154,8 @@ build_selector (tree ident)
 
 /* struct _objc_super {
      struct _objc_object *self;
-     struct _objc_class *super_class; 
-               [or Class cls; for the abi v2]
+     struct _objc_class *super_class;
+               [or Class cls; for the abi v2]
    };  */
 
 void
@@ -302,7 +297,7 @@ add_objc_string (tree ident, string_section section)
 {
   tree *chain, decl, type;
   char buf[BUFSIZE];
-  
+
   switch (section)
     {
     case class_names:
@@ -336,13 +331,13 @@ add_objc_string (tree ident, string_section section)
     }
 
   type = build_sized_array_type (char_type_node, IDENTIFIER_LENGTH (ident) + 1);
-  /* Get a runtime-specific string decl which will be finish_var()'ed in 
+  /* Get a runtime-specific string decl which will be finish_var()'ed in
      generate_strings ().  */
   decl = (*runtime.string_decl) (type, buf, section);
   TREE_CONSTANT (decl) = 1;
   *chain = tree_cons (decl, ident, NULL_TREE);
 
-  return convert (string_type_node, 
+  return convert (string_type_node,
                  build_unary_op (input_location, ADDR_EXPR, decl, 1));
 }
 
@@ -442,7 +437,7 @@ init_module_descriptor (tree type, long vers)
 
   /* No really useful place to point to.  */
   loc = UNKNOWN_LOCATION;
-  
+
   /* version = { 1, ... } */
 
   expr = build_int_cst (long_integer_type_node, vers);
@@ -463,7 +458,7 @@ init_module_descriptor (tree type, long vers)
   /* symtab = { ..., _OBJC_SYMBOLS, ... } */
 
   ltyp = build_pointer_type (xref_tag (RECORD_TYPE,
-                                      get_identifier (UTAG_SYMTAB)));  
+                                      get_identifier (UTAG_SYMTAB)));
   if (UOBJC_SYMBOLS_decl)
     expr = convert (ltyp, build_unary_op (loc,
                           ADDR_EXPR, UOBJC_SYMBOLS_decl, 0));
@@ -507,7 +502,10 @@ build_module_descriptor (long vers, tree attr)
 
   /* Create an instance of "_objc_module".  */
   UOBJC_MODULES_decl = start_var_decl (objc_module_template,
-                       flag_next_runtime ? "_OBJC_Module" :  "_OBJC_Module");
+                                      /* FIXME - why the conditional
+                                         if the symbol is the
+                                         same.  */
+                                      flag_next_runtime ? "_OBJC_Module" :  "_OBJC_Module");
 
   /* This is the root of the metadata for defined classes and categories, it
      is referenced by the runtime and, therefore, needed.  */
@@ -516,7 +514,7 @@ build_module_descriptor (long vers, tree attr)
   /* Allow the runtime to mark meta-data such that it can be assigned to target
      specific sections by the back-end.  */
   if (attr)
-    DECL_ATTRIBUTES (UOBJC_MODULES_decl) = attr; 
+    DECL_ATTRIBUTES (UOBJC_MODULES_decl) = attr;
 
   finish_var_decl (UOBJC_MODULES_decl,
                   init_module_descriptor (TREE_TYPE (UOBJC_MODULES_decl),
@@ -547,16 +545,9 @@ build_ivar_list_initializer (tree type, tree field_decl)
        CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, build_int_cst (NULL_TREE, 0));
 
       /* Set type.  */
-      encode_field_decl (field_decl,
-                        obstack_object_size (&util_obstack),
-                        OBJC_ENCODE_DONT_INLINE_DEFS);
-
-      /* Null terminate string.  */
-      obstack_1grow (&util_obstack, 0);
-      id = add_objc_string (get_identifier (XOBFINISH (&util_obstack, char *)),
+      id = add_objc_string (encode_field_decl (field_decl),
                             meth_var_types);
       CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, id);
-      obstack_free (&util_obstack, util_firstobj);
 
       /* Set offset.  */
       CONSTRUCTOR_APPEND_ELT (ivar, NULL_TREE, byte_position (field_decl));
@@ -637,7 +628,7 @@ build_next_selector_translation_table (void)
       if (warn_selector)
        {
          location_t loc;
-         if (decl) 
+         if (decl)
            loc = DECL_SOURCE_LOCATION (decl);
          else
            loc = UNKNOWN_LOCATION;
@@ -649,7 +640,7 @@ build_next_selector_translation_table (void)
       if (decl)
        {
          /* Entries of this form are used for references to methods.
-         The runtime re-writes these on start-up, but the compiler can't see 
+         The runtime re-writes these on start-up, but the compiler can't see
          that and optimizes it away unless we force it.  */
          DECL_PRESERVE_P (decl) = 1;
          finish_var_decl (decl, expr);