]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/objc/objc-next-runtime-abi-01.c
Update copyright years.
[thirdparty/gcc.git] / gcc / objc / objc-next-runtime-abi-01.c
index b60bd468000ca2c0734157d4097c6f350601050e..5c34fcb05cb2536fce0135f9130eeaa07da3d85d 100644 (file)
@@ -1,5 +1,5 @@
 /* Next Runtime (ABI-0/1) private.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011-2020 Free Software Foundation, Inc.
    Contributed by Iain Sandoe (split from objc-act.c)
 
 This file is part of GCC.
@@ -27,12 +27,14 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "tree.h"
+#include "stringpool.h"
+#include "attribs.h"
 
 #ifdef OBJCPLUS
-#include "cp-tree.h"
+#include "cp/cp-tree.h"
 #else
-#include "c-tree.h"
-#include "c-lang.h"
+#include "c/c-tree.h"
+#include "c/c-lang.h"
 #endif
 #include "langhooks.h"
 #include "c-family/c-objc.h"
@@ -46,7 +48,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "objcp-decl.h"
 #endif  /* OBJCPLUS */
 
-#include "ggc.h"
 #include "target.h"
 #include "c-family/c-target.h"
 #include "tree-iterator.h"
@@ -123,8 +124,8 @@ static tree next_runtime_abi_01_get_class_super_ref (location_t, struct imp_entr
 static tree next_runtime_abi_01_get_category_super_ref (location_t, struct imp_entry *, bool);
 
 static tree next_runtime_abi_01_receiver_is_class_object (tree);
-static void next_runtime_abi_01_get_arg_type_list_base (VEC(tree,gc) **, tree,
-                                                       int, int);
+static void next_runtime_abi_01_get_arg_type_list_base (vec<tree, va_gc> **,
+                                                       tree, int, int);
 static tree next_runtime_abi_01_build_objc_method_call (location_t, tree, tree,
                                                        tree, tree, tree, int);
 static bool next_runtime_abi_01_setup_const_string_class_decl (void);
@@ -149,7 +150,8 @@ objc_next_runtime_abi_01_init (objc_runtime_hooks *rthooks)
     {
       warning_at (UNKNOWN_LOCATION, OPT_Wall,
                "%<-fobjc-sjlj-exceptions%> is the only supported exceptions "
-               "system for %<-fnext-runtime%> with %<-fobjc-abi-version%> < 2");
+               "system for %<-fnext-runtime%> with %<-fobjc-abi-version%> "
+               "argument less than 2");
     }
 
   rthooks->initialize = next_runtime_01_initialize;
@@ -583,7 +585,7 @@ build_v1_protocol_template (void)
   objc_finish_struct (objc_protocol_template, decls);
 }
 
-/* --- names, decls identifers --- */
+/* --- names, decls identifiers --- */
 
 static tree
 next_runtime_abi_01_super_superclassfield_id (void)
@@ -730,8 +732,9 @@ next_runtime_abi_01_get_class_reference (tree ident)
    prototype.  */
 
 static void
-next_runtime_abi_01_get_arg_type_list_base (VEC(tree,gc) **argtypes, tree meth,
-                                           int context, int superflag)
+next_runtime_abi_01_get_arg_type_list_base (vec<tree, va_gc> **argtypes,
+                                           tree meth, int context,
+                                           int superflag)
 {
   tree receiver_type;
 
@@ -742,9 +745,9 @@ next_runtime_abi_01_get_arg_type_list_base (VEC(tree,gc) **argtypes, tree meth,
   else
     receiver_type = objc_object_type;
 
-  VEC_safe_push (tree, gc, *argtypes, receiver_type);
+  vec_safe_push (*argtypes, receiver_type);
   /* Selector type - will eventually change to `int'.  */
-  VEC_safe_push (tree, gc, *argtypes, objc_selector_type);
+  vec_safe_push (*argtypes, objc_selector_type);
 }
 
 static tree
@@ -820,7 +823,7 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
 {
   tree sender, sender_cast, method, t;
   tree rcv_p = (super_flag ? objc_super_type : objc_object_type);
-  VEC(tree, gc) *parms;
+  vec<tree, va_gc> *parms;
   unsigned nparm = (method_params ? list_length (method_params) : 0);
 
   /* If a prototype for the method to be called exists, then cast
@@ -846,7 +849,7 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
   lookup_object = save_expr (lookup_object);
 
   /* Param list + 2 slots for object and selector.  */
-  parms = VEC_alloc (tree, gc, nparm + 2);
+  vec_alloc (parms, nparm + 2);
 
   /* If we are returning a struct in memory, and the address
      of that memory location is passed as a hidden first
@@ -869,19 +872,19 @@ build_objc_method_call (location_t loc, int super_flag, tree method_prototype,
   method = build_fold_addr_expr_loc (loc, sender);
 
   /* Pass the object to the method.  */
-  VEC_quick_push (tree, parms, lookup_object);
+  parms->quick_push (lookup_object);
   /* Pass the selector to the method.  */
-  VEC_quick_push (tree, parms, selector);
+  parms->quick_push (selector);
   /* Now append the remainder of the parms.  */
   if (nparm)
     for (; method_params; method_params = TREE_CHAIN (method_params))
-      VEC_quick_push (tree, parms, TREE_VALUE (method_params));
+      parms->quick_push (TREE_VALUE (method_params));
 
   /* Build an obj_type_ref, with the correct cast for the method call.  */
   t = build3 (OBJ_TYPE_REF, sender_cast, method,
                            lookup_object, size_zero_node);
-  t = build_function_call_vec (loc, t, parms, NULL);
-  VEC_free (tree, gc, parms);
+  t = build_function_call_vec (loc, vNULL, t, parms, NULL);
+  vec_free (parms);
   return t;
 }
 
@@ -1005,7 +1008,7 @@ next_runtime_abi_01_build_const_string_constructor (location_t loc, tree string,
                                                   int length)
 {
   tree constructor, fields, var;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   /* NeXT:   (NSConstantString *) & ((__builtin_ObjCString) { isa, string, length })   */
   fields = TYPE_FIELDS (internal_const_str_type);
@@ -1145,7 +1148,7 @@ generate_v1_meth_descriptor_table (tree chain, tree protocol,
 {
   tree method_list_template, initlist, decl;
   int size;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
   char buf[BUFSIZE];
 
   if (!chain || !prefix)
@@ -1186,7 +1189,7 @@ generate_v1_objc_protocol_extension (tree proto_interface,
 {
   int size;
   location_t loc;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
   tree decl, expr;
   char buf[BUFSIZE];
 
@@ -1277,7 +1280,7 @@ static tree
 build_v1_property_table_initializer (tree type, tree context)
 {
   tree x;
-  VEC(constructor_elt,gc) *inits = NULL;
+  vec<constructor_elt, va_gc> *inits = NULL;
 
   if (TREE_CODE (context) == PROTOCOL_INTERFACE_TYPE)
     x = CLASS_PROPERTY_DECL (context);
@@ -1286,7 +1289,7 @@ build_v1_property_table_initializer (tree type, tree context)
 
   for (; x; x = TREE_CHAIN (x))
     {
-      VEC(constructor_elt,gc) *elemlist = NULL;
+      vec<constructor_elt, va_gc> *elemlist = NULL;
       tree attribute, name_ident = PROPERTY_NAME (x);
 
       CONSTRUCTOR_APPEND_ELT (elemlist, NULL_TREE,
@@ -1313,7 +1316,7 @@ generate_v1_property_table (tree context, tree klass_ctxt)
 {
   tree x, decl, initlist, property_list_template;
   bool is_proto = false;
-  VEC(constructor_elt,gc) *inits = NULL;
+  vec<constructor_elt, va_gc> *inits = NULL;
   int init_val, size = 0;
   char buf[BUFSIZE];
 
@@ -1365,7 +1368,7 @@ generate_v1_protocol_list (tree i_or_p, tree klass_ctxt)
 {
   tree array_type, ptype, refs_decl, lproto, e, plist, attr;
   int size = 0;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
   char buf[BUFSIZE];
 
   switch (TREE_CODE (i_or_p))
@@ -1447,7 +1450,7 @@ build_v1_protocol_initializer (tree type, tree protocol_name, tree protocol_list
 {
   tree expr, ttyp;
   location_t loc;
-  VEC(constructor_elt,gc) *inits = NULL;
+  vec<constructor_elt, va_gc> *inits = NULL;
 
   if (!objc_protocol_extension_template)
     build_v1_objc_protocol_extension_template ();
@@ -1659,8 +1662,8 @@ static tree
 generate_dispatch_table (tree chain, const char *name, tree attr)
 {
   tree decl, method_list_template, initlist;
-  VEC(constructor_elt,gc) *v = NULL;
-  int size;;
+  vec<constructor_elt, va_gc> *v = NULL;
+  int size;
 
   if (!chain || !name || !(size = list_length (chain)))
     return NULL_TREE;
@@ -1694,7 +1697,7 @@ build_v1_category_initializer (tree type, tree cat_name, tree class_name,
                                location_t loc)
 {
   tree expr, ltyp;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, cat_name);
   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, class_name);
@@ -1807,7 +1810,7 @@ generate_objc_class_ext (tree property_list, tree context)
   tree weak_ivar_layout_tree;
   int size;
   location_t loc;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
   char buf[BUFSIZE];
 
   /* TODO: pass the loc in or find it from args.  */
@@ -1879,7 +1882,7 @@ build_v1_shared_structure_initializer (tree type, tree isa, tree super,
 {
   tree expr, ltyp;
   location_t loc;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   /* TODO: fish the location out of the input data.  */
   loc = UNKNOWN_LOCATION;
@@ -1964,7 +1967,7 @@ generate_ivars_list (tree chain, const char *name, tree attr)
 {
   tree initlist, ivar_list_template, decl;
   int size;
-  VEC(constructor_elt,gc) *inits = NULL;
+  vec<constructor_elt, va_gc> *inits = NULL;
 
   if (!chain)
     return NULL_TREE;
@@ -2138,7 +2141,7 @@ init_def_list (tree type)
   tree expr;
   location_t loc;
   struct imp_entry *impent;
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   if (imp_count)
     for (impent = imp_list; impent; impent = impent->next)
@@ -2215,7 +2218,7 @@ build_objc_symtab_template (void)
 static tree
 init_objc_symtab (tree type)
 {
-  VEC(constructor_elt,gc) *v = NULL;
+  vec<constructor_elt, va_gc> *v = NULL;
 
   /* sel_ref_cnt = { ..., 5, ... } */
 
@@ -2331,36 +2334,6 @@ generate_classref_translation_entry (tree chain)
   return;
 }
 
-
-/* The Fix-and-Continue functionality available in Mac OS X 10.3 and
-   later requires that ObjC translation units participating in F&C be
-   specially marked.  The following routine accomplishes this.  */
-
-/* static int _OBJC_IMAGE_INFO[2] = { 0, 1 }; */
-
-static void
-generate_objc_image_info (void)
-{
-  tree decl;
-  int flags
-    = ((flag_replace_objc_classes && imp_count ? 1 : 0)
-       | (flag_objc_gc ? 2 : 0));
-  VEC(constructor_elt,gc) *v = NULL;
-  tree array_type;
-
-  array_type  = build_sized_array_type (integer_type_node, 2);
-
-  decl = start_var_decl (array_type, "_OBJC_ImageInfo");
-
-  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, integer_zero_node);
-  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, build_int_cst (integer_type_node, flags));
-  /* The runtime wants this and refers to it in a manner hidden from the compiler.
-     So we must force the output.  */
-  DECL_PRESERVE_P (decl) = 1;
-  OBJCMETA (decl, objc_meta, meta_info);
-  finish_var_decl (decl, objc_build_constructor (TREE_TYPE (decl), v));
-}
-
 static void
 objc_generate_v1_next_metadata (void)
 {
@@ -2411,9 +2384,6 @@ objc_generate_v1_next_metadata (void)
   attr = build_tree_list (objc_meta, meta_modules);
   build_module_descriptor (vers, attr);
 
-  /* This conveys information on GC usage and zero-link.  */
-  generate_objc_image_info ();
-
   /* Dump the class references.  This forces the appropriate classes
      to be linked into the executable image, preserving unix archive
      semantics.  */
@@ -2845,7 +2815,7 @@ objc_eh_runtime_type (tree type)
         we use c++'s typeinfo decl. */
       return build_eh_type_type (type);
 #else
-      error ("non-objective-c type '%T' cannot be caught", type);
+      error ("non-objective-c type %qT cannot be caught", type);
       ident = get_identifier ("ErrorMarkNode");
       goto make_err_class;
 #endif
@@ -2892,12 +2862,14 @@ static tree
 build_throw_stmt (location_t loc, tree throw_expr, bool rethrown ATTRIBUTE_UNUSED)
 {
   tree t;
-  VEC(tree, gc) *parms = VEC_alloc (tree, gc, 1);
+  vec<tree, va_gc> *parms;
+  vec_alloc (parms, 1);
   /* A throw is just a call to the runtime throw function with the
      object as a parameter.  */
-  VEC_quick_push (tree, parms, throw_expr);
-  t = build_function_call_vec (loc, objc_exception_throw_decl, parms, NULL);
-  VEC_free (tree, gc, parms);
+  parms->quick_push (throw_expr);
+  t = build_function_call_vec (loc, vNULL, objc_exception_throw_decl, parms,
+                              NULL);
+  vec_free (parms);
   return add_stmt (t);
 }