OSDN Git Service

[gcc/ChangeLog]
[pf3gnuchains/gcc-fork.git] / gcc / objc / objc-act.c
index 308f2ac..aefb4fb 100644 (file)
@@ -132,7 +132,7 @@ static tree build_objc_method_call (int, tree, tree, tree, tree);
 static void generate_strings (void);
 static tree get_proto_encoding (tree);
 static void build_selector_translation_table (void);
-
+static tree lookup_interface (tree);
 static tree objc_add_static_instance (tree, tree);
 
 static void build_objc_exception_stuff (void);
@@ -516,10 +516,9 @@ objc_init (void)
 }
 
 void
-finish_file (void)
+objc_finish_file (void)
 {
   mark_referenced_methods ();
-  c_objc_common_finish_file ();
 
   /* Finalize Objective-C runtime data.  No need to generate tables
      and code if only checking syntax.  */
@@ -609,6 +608,23 @@ lookup_protocol_in_reflist (tree rproto_list, tree lproto)
   return 0;
 }
 
+/* Return 1 if IDENT is an ObjC/ObjC++ reserved keyword in the context of
+   an '@'.  */
+
+int
+objc_is_reserved_word (tree ident)
+{
+  unsigned char code = C_RID_CODE (ident);
+
+  return (OBJC_IS_AT_KEYWORD (code)
+#ifdef OBJCPLUS
+         || code == RID_CLASS || code == RID_PUBLIC
+         || code == RID_PROTECTED || code == RID_PRIVATE
+         || code == RID_TRY || code == RID_THROW || code == RID_CATCH
+#endif
+           );
+}
+
 /* Return true if TYPE is 'id'.  */
 
 static bool
@@ -945,7 +961,7 @@ objc_check_decl (tree decl)
 
   if (TREE_CODE (type) != RECORD_TYPE)
     return;
-  if (TYPE_NAME (type) && (type = is_class_name (TYPE_NAME (type))))
+  if (OBJC_TYPE_NAME (type) && (type = objc_is_class_name (OBJC_TYPE_NAME (type))))
     error ("statically allocated instance of Objective-C class `%s'",
           IDENTIFIER_POINTER (type));
 }
@@ -959,25 +975,11 @@ get_static_reference (tree interface, tree protocols)
 
   if (protocols)
     {
-      tree t, m = TYPE_MAIN_VARIANT (type);
-
-      t = copy_node (type);
-
-      /* Add this type to the chain of variants of TYPE.  */
-      TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
-      TYPE_NEXT_VARIANT (m) = t;
-
+      type = build_variant_type_copy (type);
+      
       /* Look up protocols and install in lang specific list.  Note
         that the protocol list can have a different lifetime than T!  */
-      SET_TYPE_PROTOCOL_LIST (t, lookup_and_install_protocols (protocols));
-
-      /* This forces a new pointer type to be created later
-        (in build_pointer_type)...so that the new template
-        we just created will actually be used...what a hack!  */
-      if (TYPE_POINTER_TO (t))
-       TYPE_POINTER_TO (t) = NULL_TREE;
-
-      type = t;
+      SET_TYPE_PROTOCOL_LIST (type, lookup_and_install_protocols (protocols));
     }
 
   return type;
@@ -1009,24 +1011,10 @@ get_protocol_reference (tree protocols)
 
   if (protocols)
     {
-      tree t, m = TYPE_MAIN_VARIANT (type);
-
-      t = copy_node (type);
-
-      /* Add this type to the chain of variants of TYPE.  */
-      TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
-      TYPE_NEXT_VARIANT (m) = t;
+      type = build_variant_type_copy (type);
 
       /* Look up protocols...and install in lang specific list */
-      SET_TYPE_PROTOCOL_LIST (t, lookup_and_install_protocols (protocols));
-
-      /* This forces a new pointer type to be created later
-        (in build_pointer_type)...so that the new template
-        we just created will actually be used...what a hack!  */
-      if (TYPE_POINTER_TO (t))
-       TYPE_POINTER_TO (t) = NULL_TREE;
-
-      type = t;
+      SET_TYPE_PROTOCOL_LIST (type, lookup_and_install_protocols (protocols));
     }
   return type;
 }
@@ -1092,7 +1080,7 @@ create_builtin_decl (enum tree_code code, tree type, const char *name)
   if (code == VAR_DECL)
     {
       TREE_STATIC (decl) = 1;
-      make_decl_rtl (decl, 0);
+      make_decl_rtl (decl);
       pushdecl (decl);
       DECL_ARTIFICIAL (decl) = 1;
     }
@@ -1378,7 +1366,7 @@ my_build_string (int len, const char *str)
    NXConstantString class object.  */
 
 tree
-build_objc_string_object (tree string)
+objc_build_string_object (tree string)
 {
   tree initlist, constructor, constant_string_class;
   int length;
@@ -1433,7 +1421,7 @@ build_objc_string_object (tree string)
     }
   else
     {
-      initlist = build_tree_list (fields, build_int_2 (0, 0));
+      initlist = build_tree_list (fields, build_int_cst (NULL_TREE, 0));
     }
 
   fields = TREE_CHAIN (fields);
@@ -1444,7 +1432,7 @@ build_objc_string_object (tree string)
                  
   fields = TREE_CHAIN (fields);
   
-  initlist = tree_cons (fields, build_int_2 (length, 0), initlist);
+  initlist = tree_cons (fields, build_int_cst (NULL_TREE, length), initlist);
   constructor = objc_build_constructor (constant_string_type,
                                        nreverse (initlist));
 
@@ -1454,7 +1442,9 @@ build_objc_string_object (tree string)
        = objc_add_static_instance (constructor, constant_string_type);
     }
 
-  return (build_unary_op (ADDR_EXPR, constructor, 1));
+  constructor = build_unary_op (ADDR_EXPR, constructor, 1);
+  TREE_CONSTANT (constructor) = true;
+  return constructor;
 }
 
 /* Declare a static instance of CLASS_DECL initialized by CONSTRUCTOR.  */
@@ -1489,7 +1479,7 @@ objc_add_static_instance (tree constructor, tree class_decl)
      Postpone till end of input.  */
   DECL_DEFER_OUTPUT (decl) = 1;
   pushdecl_top_level (decl);
-  rest_of_decl_compilation (decl, 0, 1, 0);
+  rest_of_decl_compilation (decl, 1, 0);
 
   /* Add the DECL to the head of this CLASS' list.  */
   TREE_PURPOSE (*chain) = tree_cons (NULL_TREE, decl, TREE_PURPOSE (*chain));
@@ -1595,7 +1585,7 @@ build_objc_symtab_template (void)
                   (FIELD_DECL,
                    build_array_type
                    (ptr_type_node,
-                    build_index_type (build_int_2 (index, 0))),
+                    build_index_type (build_int_cst (NULL_TREE, index))),
                    "defs");
       chainon (field_decl_chain, field_decl);
     }
@@ -1640,7 +1630,7 @@ init_def_list (tree type)
       if (static_instances_decl)
        expr = build_unary_op (ADDR_EXPR, static_instances_decl, 0);
       else
-       expr = build_int_2 (0, 0);
+       expr = build_int_cst (NULL_TREE, 0);
 
       initlist = tree_cons (NULL_TREE, expr, initlist);
     }
@@ -1657,12 +1647,12 @@ init_objc_symtab (tree type)
 
   /* sel_ref_cnt = { ..., 5, ... } */
 
-  initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
+  initlist = build_tree_list (NULL_TREE, build_int_cst (NULL_TREE, 0));
 
   /* refs = { ..., _OBJC_SELECTOR_TABLE, ... } */
 
   if (flag_next_runtime || ! sel_ref_chain)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     initlist = tree_cons (NULL_TREE,
                          build_unary_op (ADDR_EXPR,
@@ -1671,11 +1661,11 @@ init_objc_symtab (tree type)
 
   /* cls_def_cnt = { ..., 5, ... } */
 
-  initlist = tree_cons (NULL_TREE, build_int_2 (imp_count, 0), initlist);
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, imp_count), initlist);
 
   /* cat_def_cnt = { ..., 5, ... } */
 
-  initlist = tree_cons (NULL_TREE, build_int_2 (cat_count, 0), initlist);
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, cat_count), initlist);
 
   /* cls_def = { ..., { &Foo, &Bar, ...}, ... } */
 
@@ -1776,7 +1766,7 @@ init_module_descriptor (tree type)
 
   /* version = { 1, ... } */
 
-  expr = build_int_2 (OBJC_VERSION, 0);
+  expr = build_int_cst (NULL_TREE, OBJC_VERSION);
   initlist = build_tree_list (NULL_TREE, expr);
 
   /* size = { ..., sizeof (struct objc_module), ... } */
@@ -1794,7 +1784,7 @@ init_module_descriptor (tree type)
   if (UOBJC_SYMBOLS_decl)
     expr = build_unary_op (ADDR_EXPR, UOBJC_SYMBOLS_decl, 0);
   else
-    expr = build_int_2 (0, 0);
+    expr = build_int_cst (NULL_TREE, 0);
   initlist = tree_cons (NULL_TREE, expr, initlist);
 
   return objc_build_constructor (type, nreverse (initlist));
@@ -1865,6 +1855,8 @@ build_module_descriptor (void)
 
   /* Mark the decl to avoid "defined but not used" warning.  */
   DECL_IN_SYSTEM_HEADER (UOBJC_MODULES_decl) = 1;
+  
+  mark_decl_referenced (UOBJC_MODULES_decl);
 
   /* Generate a constructor call for the module descriptor.
      This code was generated by reading the grammar rules
@@ -1891,7 +1883,7 @@ build_module_descriptor (void)
     DECL_ARTIFICIAL (execclass_decl) = 1;
     TREE_PUBLIC (execclass_decl) = 1;
     pushdecl (execclass_decl);
-    rest_of_decl_compilation (execclass_decl, 0, 0, 0);
+    rest_of_decl_compilation (execclass_decl, 0, 0);
     assemble_external (execclass_decl);
 
     /* void _GLOBAL_$I$<gnyf> () {objc_execClass (&L_OBJC_MODULES);}  */
@@ -1959,7 +1951,7 @@ generate_static_references (void)
 {
   tree decls = NULL_TREE, ident, decl_spec, expr_decl, expr = NULL_TREE;
   tree class_name, class, decl, initlist;
-  tree cl_chain, in_chain, type;
+  tree cl_chain, in_chain;
   int num_inst, num_class;
   char buf[256];
 
@@ -1982,6 +1974,7 @@ generate_static_references (void)
       decl = start_decl (expr_decl, decl_spec, 1, NULL_TREE);
       DECL_CONTEXT (decl) = 0;
       DECL_ARTIFICIAL (decl) = 1;
+      TREE_USED (decl) = 1;
 
       /* Output {class_name, ...}.  */
       class = TREE_VALUE (cl_chain);
@@ -1998,21 +1991,15 @@ generate_static_references (void)
        }
 
       /* Output {..., NULL}.  */
-      initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+      initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
 
       expr = objc_build_constructor (TREE_TYPE (decl), nreverse (initlist));
       finish_decl (decl, expr, NULL_TREE);
-      TREE_USED (decl) = 1;
-
-      type = build_array_type (build_pointer_type (void_type_node), 0);
-      decl = build_decl (VAR_DECL, ident, type);
-      TREE_USED (decl) = 1;
-      TREE_STATIC (decl) = 1;
       decls
        = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, decl, 1), decls);
     }
 
-  decls = tree_cons (NULL_TREE, build_int_2 (0, 0), decls);
+  decls = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), decls);
   ident = get_identifier ("_OBJC_STATIC_INSTANCES");
   expr_decl = build_nt (ARRAY_REF, ident, NULL_TREE, NULL_TREE, NULL_TREE);
   decl_spec = tree_cons (NULL_TREE, build_pointer_type (void_type_node),
@@ -2026,6 +2013,7 @@ generate_static_references (void)
   expr = objc_build_constructor (TREE_TYPE (static_instances_decl),
                            nreverse (decls));
   finish_decl (static_instances_decl, expr, NULL_TREE);
+  rest_of_decl_compilation (static_instances_decl, 0, 0);
 }
 
 /* Output all strings.  */
@@ -2105,7 +2093,7 @@ build_selector_reference_decl (void)
   DECL_ARTIFICIAL (decl) = 1;
   DECL_CONTEXT (decl) = 0;
 
-  make_decl_rtl (decl, 0);
+  make_decl_rtl (decl);
   pushdecl_top_level (decl);
 
   return decl;
@@ -2206,7 +2194,7 @@ build_selector_translation_table (void)
       DECL_EXTERNAL (UOBJC_SELECTOR_TABLE_decl) = 0;
       TREE_STATIC (UOBJC_SELECTOR_TABLE_decl) = 1;
       /* NULL terminate the list and fix the decl for output.  */
-      initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+      initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
       DECL_INITIAL (UOBJC_SELECTOR_TABLE_decl) = objc_ellipsis_node;
       initlist = objc_build_constructor (TREE_TYPE (UOBJC_SELECTOR_TABLE_decl),
                                         nreverse (initlist));
@@ -2232,7 +2220,7 @@ get_proto_encoding (tree proto)
       return add_objc_string (encoding, meth_var_types);
     }
   else
-    return build_int_2 (0, 0);
+    return build_int_cst (NULL_TREE, 0);
 }
 
 /* sel_ref_chain is a list whose "value" fields will be instances of
@@ -2259,7 +2247,7 @@ build_typed_selector_reference (tree ident, tree prototype)
  return_at_index:
   expr = build_unary_op (ADDR_EXPR,
                         build_array_ref (UOBJC_SELECTOR_TABLE_decl,
-                                         build_int_2 (index, 0)),
+                                         build_int_cst (NULL_TREE, index)),
                         1);
   return build_c_cast (objc_selector_type, expr);
 }
@@ -2277,7 +2265,7 @@ build_selector_reference (tree ident)
        return (flag_next_runtime
                ? TREE_PURPOSE (*chain)
                : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
-                                  build_int_2 (index, 0)));
+                                  build_int_cst (NULL_TREE, index)));
 
       index++;
       chain = &TREE_CHAIN (*chain);
@@ -2290,7 +2278,7 @@ build_selector_reference (tree ident)
   return (flag_next_runtime
          ? expr
          : build_array_ref (UOBJC_SELECTOR_TABLE_decl,
-                            build_int_2 (index, 0)));
+                            build_int_cst (NULL_TREE, index)));
 }
 
 static GTY(()) int class_reference_idx;
@@ -2312,7 +2300,7 @@ build_class_reference_decl (void)
   DECL_CONTEXT (decl) = 0;
   DECL_ARTIFICIAL (decl) = 1;
 
-  make_decl_rtl (decl, 0);
+  make_decl_rtl (decl);
   pushdecl_top_level (decl);
 
   return decl;
@@ -2350,7 +2338,7 @@ add_class_reference (tree ident)
    reference variable.  */
 
 tree
-get_class_reference (tree ident)
+objc_get_class_reference (tree ident)
 {
   tree orig_ident;
 
@@ -2363,7 +2351,7 @@ get_class_reference (tree ident)
 #endif
   orig_ident = ident;
 
-  if (!(ident = is_class_name (ident)))
+  if (!(ident = objc_is_class_name (ident)))
     {
       error ("`%s' is not an Objective-C class name or alias",
             IDENTIFIER_POINTER (orig_ident));
@@ -2462,7 +2450,7 @@ build_objc_string_decl (enum string_section section)
   DECL_CONTEXT (decl) = 0;
   DECL_ARTIFICIAL (decl) = 1;
 
-  make_decl_rtl (decl, 0);
+  make_decl_rtl (decl);
   pushdecl_top_level (decl);
 
   return decl;
@@ -2480,9 +2468,9 @@ objc_declare_alias (tree alias_ident, tree class_ident)
   }
 #endif /* OBJCPLUS */
 
-  if (!(underlying_class = is_class_name (class_ident)))
+  if (!(underlying_class = objc_is_class_name (class_ident)))
     warning ("cannot find class `%s'", IDENTIFIER_POINTER (class_ident));
-  else if (is_class_name (alias_ident))
+  else if (objc_is_class_name (alias_ident))
     warning ("class `%s' already exists", IDENTIFIER_POINTER (alias_ident));
   else
     alias_chain = tree_cons (underlying_class, alias_ident, alias_chain);
@@ -2502,7 +2490,7 @@ objc_declare_class (tree ident_list)
     {
       tree ident = TREE_VALUE (list);
 
-      if (! is_class_name (ident))
+      if (! objc_is_class_name (ident))
        {
          tree record = lookup_name (ident);
        
@@ -2522,7 +2510,7 @@ objc_declare_class (tree ident_list)
 }
 
 tree
-is_class_name (tree ident)
+objc_is_class_name (tree ident)
 {
   tree chain;
 
@@ -2575,10 +2563,10 @@ objc_is_object_ptr (tree type)
       && (IS_ID (type)
          || TREE_TYPE (type) == TREE_TYPE (objc_class_type)))
     return type;
-  return is_class_name (OBJC_TYPE_NAME (TREE_TYPE (type)));
+  return objc_is_class_name (OBJC_TYPE_NAME (TREE_TYPE (type)));
 }
 
-tree
+static tree
 lookup_interface (tree ident)
 {
   tree chain;
@@ -2598,7 +2586,7 @@ lookup_interface (tree ident)
 /* Implement @defs (<classname>) within struct bodies.  */
 
 tree
-get_class_ivars_from_name (tree class_name)
+objc_get_class_ivars (tree class_name)
 {
   tree interface = lookup_interface (class_name);
   tree field, fields = NULL_TREE;
@@ -2896,7 +2884,7 @@ next_sjlj_build_catch_list (void)
          else
            {
              args = tree_cons (NULL, cur_try_context->caught_decl, NULL);
-             t = get_class_reference (OBJC_TYPE_NAME (TREE_TYPE (type)));
+             t = objc_get_class_reference (OBJC_TYPE_NAME (TREE_TYPE (type)));
              args = tree_cons (NULL, t, args);
              t = build_function_call (objc_exception_match_decl, args);
              cond = lang_hooks.truthvalue_conversion (t);
@@ -3278,7 +3266,7 @@ build_next_objc_exception_stuff (void)
 
   /* int buf[_JBLEN]; */
 
-  index = build_index_type (build_int_2 (_JBLEN - 1, 0));
+  index = build_index_type (build_int_cst (NULL_TREE, _JBLEN - 1));
   field_decl = create_builtin_decl (FIELD_DECL,
                                    build_array_type (integer_type_node, index),
                                    "buf");
@@ -3286,7 +3274,7 @@ build_next_objc_exception_stuff (void)
 
   /* void *pointers[4]; */
 
-  index = build_index_type (build_int_2 (4 - 1, 0));
+  index = build_index_type (build_int_cst (NULL_TREE, 4 - 1));
   field_decl = create_builtin_decl (FIELD_DECL,
                                    build_array_type (ptr_type_node, index),
                                    "pointers");
@@ -3524,7 +3512,7 @@ build_method_prototype_list_template (tree list_type, int size)
 
   decl_specs = build_tree_list (NULL_TREE, list_type);
   field_decl = build_nt (ARRAY_REF, get_identifier ("method_list"),
-                        build_int_2 (size, 0), NULL_TREE, NULL_TREE);
+                        build_int_cst (NULL_TREE, size), NULL_TREE, NULL_TREE);
   field_decl = grokfield (field_decl, decl_specs, NULL_TREE);
   chainon (field_decl_chain, field_decl);
 
@@ -3670,7 +3658,7 @@ generate_descriptor_table (tree type, const char *name, int size, tree list,
                     decl_specs, 1, NULL_TREE);
   DECL_CONTEXT (decl) = NULL_TREE;
 
-  initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0));
+  initlist = build_tree_list (NULL_TREE, build_int_cst (NULL_TREE, size));
   initlist = tree_cons (NULL_TREE, list, initlist);
 
   finish_decl (decl, objc_build_constructor (type, nreverse (initlist)),
@@ -3880,7 +3868,7 @@ generate_protocols (void)
          TREE_TYPE (refs_expr) = cast_type2;
        }
       else
-       refs_expr = build_int_2 (0, 0);
+       refs_expr = build_int_cst (NULL_TREE, 0);
 
       /* UOBJC_INSTANCE_METHODS_decl/UOBJC_CLASS_METHODS_decl are set
         by generate_method_descriptors, which is called above.  */
@@ -3913,14 +3901,13 @@ build_protocol_initializer (tree type, tree protocol_name,
   /* Filling the "isa" in with one allows the runtime system to
      detect that the version change...should remove before final release.  */
 
-  expr = build_int_2 (PROTOCOL_VERSION, 0);
-  TREE_TYPE (expr) = cast_type;
+  expr = build_int_cst (cast_type, PROTOCOL_VERSION);
   initlist = tree_cons (NULL_TREE, expr, initlist);
   initlist = tree_cons (NULL_TREE, protocol_name, initlist);
   initlist = tree_cons (NULL_TREE, protocol_list, initlist);
 
   if (!instance_methods)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       expr = build_unary_op (ADDR_EXPR, instance_methods, 0);
@@ -3928,7 +3915,7 @@ build_protocol_initializer (tree type, tree protocol_name,
     }
 
   if (!class_methods)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       expr = build_unary_op (ADDR_EXPR, class_methods, 0);
@@ -4215,6 +4202,9 @@ synth_forward_declarations (void)
   /* static struct objc_class _OBJC_METACLASS_<my_name>; */
   UOBJC_METACLASS_decl = build_metadata_decl ("_OBJC_METACLASS",
                                                  objc_class_template);
+                                                 
+  mark_decl_referenced (UOBJC_CLASS_decl);
+  mark_decl_referenced (UOBJC_METACLASS_decl);
 
   /* Pre-build the following entities - for speed/convenience.  */
 
@@ -4418,7 +4408,7 @@ build_ivar_list_template (tree list_type, int size)
 
   decl_specs = build_tree_list (NULL_TREE, list_type);
   field_decl = build_nt (ARRAY_REF, get_identifier ("ivar_list"),
-                        build_int_2 (size, 0), NULL_TREE, NULL_TREE);
+                        build_int_cst (NULL_TREE, size), NULL_TREE, NULL_TREE);
 
   field_decl = grokfield (field_decl, decl_specs, NULL_TREE);
   chainon (field_decl_chain, field_decl);
@@ -4466,7 +4456,7 @@ build_method_list_template (tree list_type, int size)
 
   decl_specs = build_tree_list (NULL_TREE, list_type);
   field_decl = build_nt (ARRAY_REF, get_identifier ("method_list"),
-                        build_int_2 (size, 0), NULL_TREE, NULL_TREE);
+                        build_int_cst (NULL_TREE, size), NULL_TREE, NULL_TREE);
 
   field_decl = grokfield (field_decl, decl_specs, NULL_TREE);
   chainon (field_decl_chain, field_decl);
@@ -4493,7 +4483,7 @@ build_ivar_list_initializer (tree type, tree field_decl)
                          ivar);
       else
        /* Unnamed bit-field ivar (yuck).  */
-       ivar = tree_cons (NULL_TREE, build_int_2 (0, 0), ivar);
+       ivar = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), ivar);
 
       /* Set type.  */
       encode_field_decl (field_decl,
@@ -4536,7 +4526,7 @@ generate_ivars_list (tree type, const char *name, int size, tree list)
   decl = start_decl (synth_id_with_class_suffix (name, objc_implementation_context),
                     decl_specs, 1, NULL_TREE);
 
-  initlist = build_tree_list (NULL_TREE, build_int_2 (size, 0));
+  initlist = build_tree_list (NULL_TREE, build_int_cst (NULL_TREE, size));
   initlist = tree_cons (NULL_TREE, list, initlist);
 
   finish_decl (decl,
@@ -4711,8 +4701,8 @@ generate_dispatch_table (tree type, const char *name, int size, tree list)
   decl = start_decl (synth_id_with_class_suffix (name, objc_implementation_context),
                     decl_specs, 1, NULL_TREE);
 
-  initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
-  initlist = tree_cons (NULL_TREE, build_int_2 (size, 0), initlist);
+  initlist = build_tree_list (NULL_TREE, build_int_cst (NULL_TREE, 0));
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, size), initlist);
   initlist = tree_cons (NULL_TREE, list, initlist);
 
   finish_decl (decl,
@@ -4844,10 +4834,9 @@ generate_protocol_list (tree i_or_p)
       size++;
 
   /* Build initializer.  */
-  initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), NULL_TREE);
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), NULL_TREE);
 
-  e = build_int_2 (size, 0);
-  TREE_TYPE (e) = cast_type;
+  e = build_int_cst (cast_type, size);
   initlist = tree_cons (NULL_TREE, e, initlist);
 
   for (lproto = plist; lproto; lproto = TREE_CHAIN (lproto))
@@ -4873,18 +4862,18 @@ generate_protocol_list (tree i_or_p)
     expr_decl = build_nt (ARRAY_REF,
                          synth_id_with_class_suffix ("_OBJC_PROTOCOL_REFS",
                                                      i_or_p),
-                         build_int_2 (size + 2, 0), NULL_TREE, NULL_TREE);
+                         build_int_cst (NULL_TREE, size + 2), NULL_TREE, NULL_TREE);
   else if (TREE_CODE (i_or_p) == CLASS_INTERFACE_TYPE)
     expr_decl = build_nt (ARRAY_REF,
                          synth_id_with_class_suffix ("_OBJC_CLASS_PROTOCOLS",
                                                      i_or_p),
-                         build_int_2 (size + 2, 0), NULL_TREE, NULL_TREE);
+                         build_int_cst (NULL_TREE, size + 2), NULL_TREE, NULL_TREE);
   else if (TREE_CODE (i_or_p) == CATEGORY_INTERFACE_TYPE)
     expr_decl
       = build_nt (ARRAY_REF,
                  synth_id_with_class_suffix ("_OBJC_CATEGORY_PROTOCOLS",
                                              i_or_p),
-                 build_int_2 (size + 2, 0), NULL_TREE, NULL_TREE);
+                 build_int_cst (NULL_TREE, size + 2), NULL_TREE, NULL_TREE);
   else
     abort ();
 
@@ -4911,14 +4900,14 @@ build_category_initializer (tree type, tree cat_name, tree class_name,
   initlist = tree_cons (NULL_TREE, class_name, initlist);
 
   if (!instance_methods)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       expr = build_unary_op (ADDR_EXPR, instance_methods, 0);
       initlist = tree_cons (NULL_TREE, expr, initlist);
     }
   if (!class_methods)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       expr = build_unary_op (ADDR_EXPR, class_methods, 0);
@@ -4927,7 +4916,7 @@ build_category_initializer (tree type, tree cat_name, tree class_name,
 
   /* protocol_list = */
   if (!protocol_list)
-     initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+     initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
      {
        tree cast_type2 = groktypename
@@ -4986,17 +4975,17 @@ build_shared_structure_initializer (tree type, tree isa, tree super,
   initlist = tree_cons (NULL_TREE, default_conversion (name), initlist);
 
   /* version = */
-  initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
 
   /* info = */
-  initlist = tree_cons (NULL_TREE, build_int_2 (status, 0), initlist);
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, status), initlist);
 
   /* instance_size = */
   initlist = tree_cons (NULL_TREE, size, initlist);
 
   /* objc_ivar_list = */
   if (!ivar_list)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       expr = build_unary_op (ADDR_EXPR, ivar_list, 0);
@@ -5005,7 +4994,7 @@ build_shared_structure_initializer (tree type, tree isa, tree super,
 
   /* objc_method_list = */
   if (!dispatch_table)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       expr = build_unary_op (ADDR_EXPR, dispatch_table, 0);
@@ -5014,22 +5003,22 @@ build_shared_structure_initializer (tree type, tree isa, tree super,
 
   if (flag_next_runtime)
     /* method_cache = */
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
     {
       /* dtable = */
-      initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+      initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
 
       /* subclass_list = */
-      initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+      initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
 
       /* sibling_class = */
-      initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+      initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
     }
 
   /* protocol_list = */
   if (! protocol_list)
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
   else
      {
        tree cast_type2
@@ -5048,10 +5037,10 @@ build_shared_structure_initializer (tree type, tree isa, tree super,
 
   if (flag_next_runtime)
     /* sel_id = NULL */
-    initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+    initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
 
   /* gc_object_type = NULL */
-  initlist = tree_cons (NULL_TREE, build_int_2 (0, 0), initlist);
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 0), initlist);
 
   return objc_build_constructor (type, nreverse (initlist));
 }
@@ -5160,7 +5149,7 @@ generate_shared_structures (void)
       super_expr = build_c_cast (cast_type, super_expr); /* cast! */
     }
   else
-    super_expr = build_int_2 (0, 0);
+    super_expr = build_int_cst (NULL_TREE, 0);
 
   root_expr = add_objc_string (my_root_id, class_names);
   root_expr = build_c_cast (cast_type, root_expr); /* cast! */
@@ -5320,7 +5309,7 @@ adjust_type_for_id_default (tree type)
      Out:      an instance of "keyword_decl".  */
 
 tree
-build_keyword_decl (tree key_name, tree arg_type, tree arg_name)
+objc_build_keyword_decl (tree key_name, tree arg_type, tree arg_name)
 {
   tree keyword_decl;
 
@@ -5514,7 +5503,7 @@ check_duplicates (hash hsh, int methods, int is_class)
 }
 
 /* If RECEIVER is a class reference, return the identifier node for
-   the referenced class.  RECEIVER is created by get_class_reference,
+   the referenced class.  RECEIVER is created by objc_get_class_reference,
    so we check the exact form created depending on which runtimes are
    used.  */
 
@@ -5590,7 +5579,7 @@ objc_message_selector (void)
    (*(<abstract_decl>(*)())_msgSuper)(receiver, selTransTbl[n], ...);  */
 
 tree
-build_message_expr (tree mess)
+objc_build_message_expr (tree mess)
 {
   tree receiver = TREE_PURPOSE (mess);
   tree sel_name;
@@ -5667,7 +5656,7 @@ lookup_method_in_hash_lists (tree sel_name, int is_class)
 }
 
 /* The 'finish_message_expr' routine is called from within
-   'build_message_expr' for non-template functions.  In the case of
+   'objc_build_message_expr' for non-template functions.  In the case of
    C++ template functions, it is called from 'build_expr_from_tree'
    (in decl2.c) after RECEIVER and METHOD_PARAMS have been expanded.  */
 
@@ -5951,7 +5940,7 @@ build_protocol_reference (tree p)
       TREE_USED (decl) = 1;
       DECL_ARTIFICIAL (decl) = 1;
 
-      make_decl_rtl (decl, 0);
+      make_decl_rtl (decl);
       pushdecl_top_level (decl);
    }
 
@@ -5961,7 +5950,7 @@ build_protocol_reference (tree p)
 /* This function is called by the parser when (and only when) a
    @protocol() expression is found, in order to compile it.  */
 tree
-build_protocol_expr (tree protoname)
+objc_build_protocol_expr (tree protoname)
 {
   tree expr;
   tree p = lookup_protocol (protoname);
@@ -6033,7 +6022,7 @@ build_protocol_expr (tree protoname)
    is found, in order to compile it.  It is only called by the parser
    and only to compile a @selector().  */
 tree
-build_selector_expr (tree selnamelist)
+objc_build_selector_expr (tree selnamelist)
 {
   tree selname;
 
@@ -6079,7 +6068,7 @@ build_selector_expr (tree selnamelist)
 }
 
 tree
-build_encode_expr (tree type)
+objc_build_encode_expr (tree type)
 {
   tree result;
   const char *string;
@@ -6777,7 +6766,7 @@ start_class (enum tree_code code, tree class_name, tree super_name,
   CLASS_SUPER_NAME (class) = super_name;
   CLASS_CLS_METHODS (class) = NULL_TREE;
 
-  if (! is_class_name (class_name)
+  if (! objc_is_class_name (class_name)
       && (decl = lookup_name (class_name)))
     {
       error ("`%s' redeclared as different kind of symbol",
@@ -7864,13 +7853,13 @@ get_super_receiver (void)
        TREE_USED (UOBJC_SUPER_decl) = 1;
        DECL_ARTIFICIAL (UOBJC_SUPER_decl) = 1;
 
-       UOBJC_SUPER_scope = get_current_scope ();
+       UOBJC_SUPER_scope = objc_get_current_scope ();
       }
 
       /* Set receiver to self.  */
       super_expr = build_component_ref (UOBJC_SUPER_decl, self_id);
       super_expr = build_modify_expr (super_expr, NOP_EXPR, self_decl);
-      super_expr_list = build_tree_list (NULL_TREE, super_expr);
+      super_expr_list = super_expr;
 
       /* Set class to begin searching.  */
 #ifdef OBJCPLUS
@@ -7909,7 +7898,7 @@ get_super_receiver (void)
 
          if (flag_next_runtime && !flag_zero_link)
            {
-             super_class = get_class_reference (super_name);
+             super_class = objc_get_class_reference (super_name);
              if (TREE_CODE (objc_method_context) == CLASS_METHOD_DECL)
                /* If we are in a class method, we must retrieve the
                   _metaclass_ for the current class, pointed at by
@@ -7941,12 +7930,12 @@ get_super_receiver (void)
                                               super_class));
        }
 
-      chainon (super_expr_list, build_tree_list (NULL_TREE, super_expr));
+      super_expr_list = build_compound_expr (super_expr_list, super_expr);
 
       super_expr = build_unary_op (ADDR_EXPR, UOBJC_SUPER_decl, 0);
-      chainon (super_expr_list, build_tree_list (NULL_TREE, super_expr));
+      super_expr_list = build_compound_expr (super_expr_list, super_expr);
 
-      return build_compound_expr (super_expr_list);
+      return super_expr_list;
     }
   else
     {
@@ -7962,7 +7951,7 @@ void
 objc_clear_super_receiver (void)
 {
   if (objc_method_context
-      && UOBJC_SUPER_scope == get_current_scope ()) {
+      && UOBJC_SUPER_scope == objc_get_current_scope ()) {
     UOBJC_SUPER_decl = 0;
     UOBJC_SUPER_scope = 0;
   }
@@ -8954,7 +8943,7 @@ handle_class_ref (tree chain)
   TREE_PUBLIC (decl) = 1;
 
   pushdecl (decl);
-  rest_of_decl_compilation (decl, 0, 0, 0);
+  rest_of_decl_compilation (decl, 0, 0);
 
   /* Make a decl for the address.  */
   sprintf (string, "%sobjc_class_ref_%s",
@@ -8966,7 +8955,7 @@ handle_class_ref (tree chain)
   TREE_USED (decl) = 1;
 
   pushdecl (decl);
-  rest_of_decl_compilation (decl, 0, 0, 0);
+  rest_of_decl_compilation (decl, 0, 0);
 }
 
 static void
@@ -9017,8 +9006,7 @@ handle_impent (struct imp_entry *impent)
     {
       tree decl, init;
 
-      init = build_int_2 (0, 0);
-      TREE_TYPE (init) = c_common_type_for_size (BITS_PER_WORD, 1);
+      init = build_int_cst (c_common_type_for_size (BITS_PER_WORD, 1), 0);
       decl = build_decl (VAR_DECL, get_identifier (string), TREE_TYPE (init));
       TREE_PUBLIC (decl) = 1;
       TREE_READONLY (decl) = 1;
@@ -9048,13 +9036,13 @@ generate_objc_image_info (void)
                 tree_cons (NULL_TREE,
                            build_array_type
                            (integer_type_node,
-                            build_index_type (build_int_2 (1, 0))),
+                            build_index_type (build_int_cst (NULL_TREE, 1))),
                            sc_spec),
                 1,
                 NULL_TREE);
 
-  initlist = build_tree_list (NULL_TREE, build_int_2 (0, 0));
-  initlist = tree_cons (NULL_TREE, build_int_2 (1, 0), initlist);
+  initlist = build_tree_list (NULL_TREE, build_int_cst (NULL_TREE, 0));
+  initlist = tree_cons (NULL_TREE, build_int_cst (NULL_TREE, 1), initlist);
   initlist = build_constructor (TREE_TYPE (decl), nreverse (initlist));
 
   TREE_USED (decl) = DECL_IGNORED_P (decl) = DECL_ARTIFICIAL (decl) = 1;
@@ -9065,7 +9053,7 @@ generate_objc_image_info (void)
 /* Look up ID as an instance variable.  */
 
 tree
-lookup_objc_ivar (tree id)
+objc_lookup_ivar (tree id)
 {
   tree decl;
 
@@ -9084,4 +9072,3 @@ lookup_objc_ivar (tree id)
 }
 
 #include "gt-objc-objc-act.h"
-#include "gtype-objc.h"