OSDN Git Service

In gcc/c-family/:
[pf3gnuchains/gcc-fork.git] / gcc / objc / objc-act.c
index a0651f6..f75fa75 100644 (file)
@@ -2953,7 +2953,7 @@ synth_module_prologue (void)
 
   /* Forward-declare '@interface Protocol'.  */
   type = get_identifier (PROTOCOL_OBJECT_CLASS_NAME);
-  objc_declare_class (tree_cons (NULL_TREE, type, NULL_TREE));
+  objc_declare_class (type);
   objc_protocol_type = build_pointer_type (xref_tag (RECORD_TYPE, type));
 
   /* Declare receiver type used for dispatching messages to 'super'.  */
@@ -2985,7 +2985,7 @@ synth_module_prologue (void)
   if (!constant_string_class_name)
     constant_string_class_name = runtime.default_constant_string_class_name;
   constant_string_id = get_identifier (constant_string_class_name);
-  objc_declare_class (tree_cons (NULL_TREE, constant_string_id, NULL_TREE));
+  objc_declare_class (constant_string_id);
 
   /* Pre-build the following entities - for speed/convenience.  */
   self_id = get_identifier ("self");
@@ -3360,48 +3360,42 @@ objc_declare_alias (tree alias_ident, tree class_ident)
 }
 
 void
-objc_declare_class (tree ident_list)
+objc_declare_class (tree identifier)
 {
-  tree list;
 #ifdef OBJCPLUS
   if (current_namespace != global_namespace) {
     error ("Objective-C declarations may only appear in global scope");
   }
 #endif /* OBJCPLUS */
 
-  for (list = ident_list; list; list = TREE_CHAIN (list))
+  if (! objc_is_class_name (identifier))
     {
-      tree ident = TREE_VALUE (list);
-
-      if (! objc_is_class_name (ident))
+      tree record = lookup_name (identifier), type = record;
+      
+      if (record)
        {
-         tree record = lookup_name (ident), type = record;
-
-         if (record)
+         if (TREE_CODE (record) == TYPE_DECL)
+           type = DECL_ORIGINAL_TYPE (record)
+             ? DECL_ORIGINAL_TYPE (record)
+             : TREE_TYPE (record);
+         
+         if (!TYPE_HAS_OBJC_INFO (type)
+             || !TYPE_OBJC_INTERFACE (type))
            {
-             if (TREE_CODE (record) == TYPE_DECL)
-               type = DECL_ORIGINAL_TYPE (record)
-                                       ? DECL_ORIGINAL_TYPE (record)
-                                       : TREE_TYPE (record);
-
-             if (!TYPE_HAS_OBJC_INFO (type)
-                 || !TYPE_OBJC_INTERFACE (type))
-               {
-                 error ("%qE redeclared as different kind of symbol",
-                        ident);
-                 error ("previous declaration of %q+D",
-                        record);
-               }
+             error ("%qE redeclared as different kind of symbol",
+                    identifier);
+             error ("previous declaration of %q+D",
+                    record);
            }
-
-         record = xref_tag (RECORD_TYPE, ident);
-         INIT_TYPE_OBJC_INFO (record);
-         /* In the case of a @class declaration, we store the ident
-            in the TYPE_OBJC_INTERFACE.  If later an @interface is
-            found, we'll replace the ident with the interface.  */
-         TYPE_OBJC_INTERFACE (record) = ident;
-         hash_class_name_enter (cls_name_hash_list, ident, NULL_TREE);
        }
+      
+      record = xref_tag (RECORD_TYPE, identifier);
+      INIT_TYPE_OBJC_INFO (record);
+      /* In the case of a @class declaration, we store the ident in
+        the TYPE_OBJC_INTERFACE.  If later an @interface is found,
+        we'll replace the ident with the interface.  */
+      TYPE_OBJC_INTERFACE (record) = identifier;
+      hash_class_name_enter (cls_name_hash_list, identifier, NULL_TREE);
     }
 }
 
@@ -4668,7 +4662,7 @@ build_keyword_selector (tree selector)
       strcat (buf, ":");
     }
 
-  return get_identifier (buf);
+  return get_identifier_with_length (buf, len);
 }
 
 /* Used for declarations and definitions.  */
@@ -5026,14 +5020,13 @@ objc_message_selector (void)
    (*(<abstract_decl>(*)())_msgSuper)(receiver, selTransTbl[n], ...);  */
 
 tree
-objc_build_message_expr (tree mess)
+objc_build_message_expr (tree receiver, tree message_args)
 {
-  tree receiver = TREE_PURPOSE (mess);
   tree sel_name;
 #ifdef OBJCPLUS
-  tree args = TREE_PURPOSE (TREE_VALUE (mess));
+  tree args = TREE_PURPOSE (message_args);
 #else
-  tree args = TREE_VALUE (mess);
+  tree args = message_args;
 #endif
   tree method_params = NULL_TREE;
 
@@ -5057,7 +5050,7 @@ objc_build_message_expr (tree mess)
   /* Build the parameter list to give to the method.  */
   if (TREE_CODE (args) == TREE_LIST)
 #ifdef OBJCPLUS
-    method_params = chainon (args, TREE_VALUE (TREE_VALUE (mess)));
+    method_params = chainon (args, TREE_VALUE (message_args));
 #else
     {
       tree chain = args, prev = NULL_TREE;
@@ -7870,9 +7863,8 @@ lookup_protocol (tree ident, bool warn_if_deprecated, bool definition_required)
    they are already declared or defined, the function has no effect.  */
 
 void
-objc_declare_protocols (tree names, tree attributes)
+objc_declare_protocol (tree name, tree attributes)
 {
-  tree list;
   bool deprecated = false;
 
 #ifdef OBJCPLUS
@@ -7897,29 +7889,25 @@ objc_declare_protocols (tree names, tree attributes)
        }
     }
 
-  for (list = names; list; list = TREE_CHAIN (list))
+  if (lookup_protocol (name, /* warn if deprecated */ false,
+                      /* definition_required */ false) == NULL_TREE)
     {
-      tree name = TREE_VALUE (list);
-
-      if (lookup_protocol (name, /* warn if deprecated */ false,
-                          /* definition_required */ false) == NULL_TREE)
+      tree protocol = make_node (PROTOCOL_INTERFACE_TYPE);
+      
+      TYPE_LANG_SLOT_1 (protocol)
+       = make_tree_vec (PROTOCOL_LANG_SLOT_ELTS);
+      PROTOCOL_NAME (protocol) = name;
+      PROTOCOL_LIST (protocol) = NULL_TREE;
+      add_protocol (protocol);
+      PROTOCOL_DEFINED (protocol) = 0;
+      PROTOCOL_FORWARD_DECL (protocol) = NULL_TREE;
+      
+      if (attributes)
        {
-         tree protocol = make_node (PROTOCOL_INTERFACE_TYPE);
-
-         TYPE_LANG_SLOT_1 (protocol)
-           = make_tree_vec (PROTOCOL_LANG_SLOT_ELTS);
-         PROTOCOL_NAME (protocol) = name;
-         PROTOCOL_LIST (protocol) = NULL_TREE;
-         add_protocol (protocol);
-         PROTOCOL_DEFINED (protocol) = 0;
-         PROTOCOL_FORWARD_DECL (protocol) = NULL_TREE;
-         
-         if (attributes)
-           {
-             TYPE_ATTRIBUTES (protocol) = attributes;
-             if (deprecated)
-               TREE_DEPRECATED (protocol) = 1;
-           }
+         /* TODO: Do we need to store the attributes here ? */
+         TYPE_ATTRIBUTES (protocol) = attributes;
+         if (deprecated)
+           TREE_DEPRECATED (protocol) = 1;
        }
     }
 }
@@ -10641,4 +10629,22 @@ objc_v2_encode_prop_attr (tree property)
   return get_identifier (string);
 }
 
+void
+objc_common_init_ts (void)
+{
+  c_common_init_ts ();
+
+  MARK_TS_DECL_NON_COMMON (CLASS_METHOD_DECL);
+  MARK_TS_DECL_NON_COMMON (INSTANCE_METHOD_DECL);
+  MARK_TS_DECL_NON_COMMON (KEYWORD_DECL);
+  MARK_TS_DECL_NON_COMMON (PROPERTY_DECL);
+
+  MARK_TS_COMMON (CLASS_INTERFACE_TYPE);
+  MARK_TS_COMMON (PROTOCOL_INTERFACE_TYPE);
+  MARK_TS_COMMON (CLASS_IMPLEMENTATION_TYPE);
+
+  MARK_TS_TYPED (MESSAGE_SEND_EXPR);
+  MARK_TS_TYPED (PROPERTY_REF);
+}
+
 #include "gt-objc-objc-act.h"