This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SAMPLE ONLY: Objective-C++ diffs


As promised, here is a set of diffs which should give a "feel"
for the extent of modifications needed to implement Objective-C++
in gcc 3.x.

The diffs for most of the files were obtained by taking the
Apple 2.95.2 ObjC++ front-end (which lives in its own obcp/
directory), subtracting from it the FSF 2.95.2 C++ front-end,
and then manually excising all Apple local code not related
to ObjC++. Diffs for objc-act.[ch] and objc-tree.def were
obtained by subtracting the FSF 3.1 ObjC front-end from our
internal version (the latter containing additional ObjC++
stuff).  The 2.95.2 diffs for objc-act.[ch] were much too
confusing to be useful.

I'd like to re-emphasize that these diffs merely indicate
the amount of work to be done, and are not meant to suggest
an implementation strategy.  The 2.95.2 ObjC++ implementation
is pretty ugly (expecially lex.c!), and I'd like to move
as far away from it as possible.  :) :)

My personal preference is to implement the 3.x ObjC++ "on
top of" C++, just like ObjC sits on top of C.  Hence,
cp/parse.y would become something like cp/cp-parse.in,
and would contain much of the same lexical analysis logic
(yylexname(), etc.) as c-parse.in does.  As much of the
ObjC++-specific code would then be contained in either:
  -- the ifobjcxx...end ifobjcxx sections of cp/cp-parse.in;
  -- objc/objc-act.[ch]

Again, this will keep things analogous to how ObjC is set up
and will make it much easier to merge ObjC and ObjC++ as
part of any future front-end unification.  Hopefully, the
makefile bits for ObjC++ can live in objc/ from the getgo.

Ok, enough babbling.  Here come the diffs...

--Zem
==============================================================
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/class.c 
/apple/MacOSX/compiler/gcc/obcp/class.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/class.c  Fri Aug  6 18:31:51 1999
--- /apple/MacOSX/compiler/gcc/obcp/class.c     Fri Jun  1 19:42:50 2001
*************** int current_lang_stacksize;
*** 144,149 ****
--- 144,152 ----

   /* Names of languages we recognize.  */
   tree lang_name_c, lang_name_cplusplus, lang_name_java;
+ #ifdef OBJCPLUS
+ tree lang_name_objc;
+ #endif
   tree current_lang_name;

   /* When layout out an aggregate type, the size of the
*************** build_vbase_path (code, type, expr, path
*** 256,263 ****
     tree null_expr = 0, nonnull_expr;
     tree basetype;
     tree offset = integer_zero_node;
!
!   if (BINFO_INHERITANCE_CHAIN (path) == NULL_TREE)
       return build1 (NOP_EXPR, type, expr);

     /* If -fthis-is-variable, we might have set nonnull incorrectly.  We
--- 259,267 ----
     tree null_expr = 0, nonnull_expr;
     tree basetype;
     tree offset = integer_zero_node;
!   /* do NOT remove the 'path == NULL_TREE' disjunct below!  I wasted
!      3 days on this... */
!   if (path == NULL_TREE || BINFO_INHERITANCE_CHAIN (path) == NULL_TREE)
       return build1 (NOP_EXPR, type, expr);

     /* If -fthis-is-variable, we might have set nonnull incorrectly.  We
*************** add_implicitly_declared_members (t, cant
*** 3031,3036 ****
--- 3076,3084 ----

     /* Default constructor.  */
     if (! TYPE_HAS_CONSTRUCTOR (t) && ! cant_have_default_ctor
+ #ifdef OBJCPLUS
+       && !is_class_name (name)
+ #endif
         && ! IS_SIGNATURE (t))
       {
         default_fn = cons_up_default_function (t, name, 2);
*************** add_implicitly_declared_members (t, cant
*** 3039,3045 ****
       }

     /* Copy constructor.  */
!   if (! TYPE_HAS_INIT_REF (t) && ! IS_SIGNATURE (t) && ! TYPE_FOR_JAVA 
(t))
       {
         /* ARM 12.18: You get either X(X&) or X(const X&), but
          not both.  --Chip  */
--- 3087,3097 ----
       }

     /* Copy constructor.  */
!   if (! TYPE_HAS_INIT_REF (t)
! #ifdef OBJCPLUS
!       && ! is_class_name (name)
! #endif
!       && ! IS_SIGNATURE (t) && ! TYPE_FOR_JAVA (t))
       {
         /* ARM 12.18: You get either X(X&) or X(const X&), but
          not both.  --Chip  */
*************** void
*** 4618,4623 ****
--- 4736,4750 ----
   push_lang_context (name)
        tree name;
   {
+ #ifdef OBJCPLUS
+   /* zlaski 2001-Apr-04: Select one of the built-in language
+      identifiers if one exists; we may simply compare pointers
+      since the 'get_identifier' function keeps strings unique */
+   if(IDENTIFIER_POINTER (name) == IDENTIFIER_POINTER (lang_name_objc))
+       name = lang_name_objc;
+   if(IDENTIFIER_POINTER (name) == IDENTIFIER_POINTER (lang_name_c))
+       name = lang_name_c;
+ #endif
     *current_lang_stack++ = current_lang_name;
     if (current_lang_stack >= current_lang_base + current_lang_stacksize)
       {
*************** push_lang_context (name)
*** 4655,4660 ****
--- 4782,4794 ----
         strict_prototype = strict_prototypes_lang_c;
         current_lang_name = name;
       }
+ #ifdef OBJCPLUS
+   else if (name == lang_name_objc)
+     {
+       strict_prototype = strict_prototypes_lang_c;
+       current_lang_name = name;
+     }
+ #endif
     else
       error ("language string `\"%s\"' not recognized", 
IDENTIFIER_POINTER (name));
   }
*************** pop_lang_context ()
*** 4668,4675 ****
--- 4802,4815 ----
     if (current_lang_name == lang_name_cplusplus
         || current_lang_name == lang_name_java)
       strict_prototype = strict_prototypes_lang_cplusplus;
     else if (current_lang_name == lang_name_c)
       strict_prototype = strict_prototypes_lang_c;
+ #ifdef OBJCPLUS
+   else if (current_lang_name == lang_name_objc)
+       strict_prototype = strict_prototypes_lang_c;
+ #endif
   }


   /* Type instantiation routines.  */
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/config-lang.in 
/apple/MacOSX/compiler/gcc/obcp/config-lang.in
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/config-lang.in   Wed Jan  6 
12:57:30 1999
--- /apple/MacOSX/compiler/gcc/obcp/config-lang.in      Fri Jun  1 
19:42:50 2001
***************
*** 26,36 ****
   # stagestuff  - files to add to $(STAGESTUFF)
   # diff_excludes       - files to ignore when building diffs between 
two versions.

! language="c++"

! compilers="cc1plus\$(exeext)"

! stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)"

   diff_excludes="-x parse.c -x parse.h"

--- 26,36 ----
   # stagestuff  - files to add to $(STAGESTUFF)
   # diff_excludes       - files to ignore when building diffs between 
two versions.

! language="objc++"

! compilers="cc1objplus\$(exeext)"

! stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1objplus\$(exeext)"

   diff_excludes="-x parse.c -x parse.h"

*************** headers='$(CXX_EXTRA_HEADERS)'
*** 38,41 ****

   lib2funcs=cplib2.txt

! outputs=cp/Makefile
--- 38,41 ----

   lib2funcs=cplib2.txt

! outputs=obcp/Makefile
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/cp-tree.h 
/apple/MacOSX/compiler/gcc/obcp/cp-tree.h
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/cp-tree.h        Thu Aug 19 
16:29:44 1999
--- /apple/MacOSX/compiler/gcc/obcp/cp-tree.h   Fri Jun  1 19:42:50 2001
*************** enum cplus_tree_code {
*** 576,582 ****
--- 625,636 ----
   };
   #undef DEFTREECODE

+ #ifdef OBJCPLUS
+ enum languages { lang_c, lang_cplusplus, lang_java, lang_objc };
+ #else
   enum languages { lang_c, lang_cplusplus, lang_java };
+ #endif
+

   /* Macros to make error reporting functions' lives easier.  */
   #define TYPE_IDENTIFIER(NODE) (DECL_NAME (TYPE_NAME (NODE)))
*************** extern int current_class_depth;
*** 2249,2254 ****
--- 2317,2325 ----

   extern tree current_lang_name;
   extern tree lang_name_cplusplus, lang_name_c, lang_name_java;
+ #ifdef OBJCPLUS
+ extern tree lang_name_objc;
+ #endif

   /* The low-water mark on the class-cache obstack.  */
   extern char *class_cache_firstobj;
*************** extern tree define_function
*** 2854,2859 ****
--- 2933,2939 ----
   extern tree check_tag_decl                    PROTO((tree));
   extern void shadow_tag                                PROTO((tree));
   extern tree groktypename                      PROTO((tree));
+ extern tree grokparms                         PROTO((tree, int));
   extern tree start_decl                                PROTO((tree, 
tree, int, tree, tree));
   extern void start_decl_1                      PROTO((tree));
   extern void cp_finish_decl                    PROTO((tree, tree, tree, 
int, int));
*************** extern int wrapup_globals_for_namespace
*** 2913,2919 ****
--- 2993,3003 ----

   /* in decl2.c */
   extern int check_java_method                  PROTO((tree));
+ #ifdef OBJCPLUS
+ extern int cplus_decode_option                        PROTO((int, 
char **));
+ #else
   extern int lang_decode_option                 PROTO((int, char **));
+ #endif
   extern tree grok_method_quals                 PROTO((tree, tree, 
tree));
   extern void warn_if_unknown_interface         PROTO((tree));
   extern void grok_x_components                 PROTO((tree));
*************** extern void GNU_xref_hier                       
PROTO((tree,
*** 3520,3524 ****
--- 3609,3634 ----
   extern void GNU_xref_member                   PROTO((tree, tree));

   /* -- end of C++ */
+
+ #ifdef OBJCPLUS
+ /* Obj-C++ specific stuff  -- all *.c files... */
+
+ extern tree objc_method_context;
+ extern tree objc_ivar_chain;
+ extern int objc_receiver_context;
+ extern int objc_declarator_context;
+ extern tree objc_interface_context;
+ extern tree objc_implementation_context;
+ extern tree objc_ivar_context;
+ extern int objc_msg_context;
+ extern void forget_saved_protocol_qualifiers PROTO((void));
+ extern int doing_objc_thang;
+ extern int objc_public_flag;
+ extern int objc_old_semantics_expected;  /* see objc-act.c for 
explanation */
+ extern tree super_type, selector_type, id_type, objc_class_type;
+ extern tree objc_object_id, objc_class_id, objc_id_id;
+ extern int objc_need_raw_identifier; /* if next token should not be a 
type or keyword */
+ extern int objc_in_method_signature; /* if we're in the midst of an 
ObjC method signature */
+ #endif

   #endif /* not _CP_TREE_H */
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/decl.c 
/apple/MacOSX/compiler/gcc/obcp/decl.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/decl.c   Sun Aug  8 17:28:33 1999
--- /apple/MacOSX/compiler/gcc/obcp/decl.c      Tue Jul 17 13:29:32 2001
*************** static struct stack_level *decl_stack;
*** 131,137 ****
   #define WCHAR_TYPE "int"
   #endif

! static tree grokparms                         PROTO((tree, int));
   static tree lookup_nested_type                        PROTO((tree, 
tree));
   static const char *redeclaration_error_message        PROTO((tree, 
tree));

--- 135,144 ----
   #define WCHAR_TYPE "int"
   #endif

! #ifndef OBJCPLUS
! static
! #endif
! tree grokparms                                        PROTO((tree, 
int));
   static tree lookup_nested_type                        PROTO((tree, 
tree));
   static const char *redeclaration_error_message        PROTO((tree, 
tree));

*************** pop_from_top_level ()
*** 2614,2620 ****
     current_lang_stacksize = s->lang_stacksize;
     if (current_lang_name == lang_name_cplusplus)
       strict_prototype = strict_prototypes_lang_cplusplus;
!   else if (current_lang_name == lang_name_c)
       strict_prototype = strict_prototypes_lang_c;
     minimal_parse_mode = s->minimal_parse_mode;
     last_function_parms = s->last_function_parms;
--- 2656,2662 ----
     current_lang_stacksize = s->lang_stacksize;
     if (current_lang_name == lang_name_cplusplus)
       strict_prototype = strict_prototypes_lang_cplusplus;
!   else if (current_lang_name == lang_name_c || current_lang_name == 
lang_name_objc)
       strict_prototype = strict_prototypes_lang_c;
     minimal_parse_mode = s->minimal_parse_mode;
     last_function_parms = s->last_function_parms;
*************** warn_extern_redeclared_static (newdecl,
*** 3107,3113 ****
     static const char *implicit_extern_static_warning
       = "`%D' was declared implicitly `extern' and later `static'";

!   if (TREE_CODE (newdecl) == TYPE_DECL)
       return;

     name = DECL_ASSEMBLER_NAME (newdecl);
--- 3149,3159 ----
     static const char *implicit_extern_static_warning
       = "`%D' was declared implicitly `extern' and later `static'";

!   if (TREE_CODE (newdecl) == TYPE_DECL
! #ifdef OBJCPLUS
!       || DECL_ARTIFICIAL (olddecl)
! #endif
!       )
       return;

     name = DECL_ASSEMBLER_NAME (newdecl);
*************** init_decl_processing ()
*** 6217,6222 ****
--- 6276,6284 ----
     /* Have to make these distinct before we try using them.  */
     lang_name_cplusplus = get_identifier ("C++");
     lang_name_c = get_identifier ("C");
+ #ifdef OBJCPLUS
+   lang_name_objc = get_identifier ("Objective-C");
+ #endif
     lang_name_java = get_identifier ("Java");

     /* Enter the global namespace. */
*************** groktypename (typename)
*** 7181,7186 ****
--- 7346,7588 ----
                          TYPENAME, 0, NULL_TREE);
   }

+ #ifdef OBJCPLUS
+ /* Return a PARM_DECL node for a given pair of specs and 
declarator.  */
+
+ tree
+ groktypename_in_parm_context (typename)
+      tree typename;
+ {
+   if (TREE_CODE (typename) != TREE_LIST)
+     return typename;
+   return grokdeclarator (TREE_VALUE (typename),
+                          TREE_PURPOSE (typename),
+                          PARM, 0, NULL_TREE);
+ }
+ #endif /* OBJCPLUS */
+
   /* Decode a declarator in an ordinary declaration or data definition.
      This is called as soon as the type information and variable name
      have been parsed, before parsing the initializer if any.
*************** cp_finish_decl (decl, init, asmspec_tree
*** 7901,7907 ****
--- 8308,8321 ----
       core_type = TREE_TYPE (core_type);

     if (TREE_CODE (decl) == FIELD_DECL)
+ #ifdef OBJCPLUS
+       /* zlaski 2001-Apr-23: Obj-C++ classes may not be statically 
allocated
+          since C++ would not know how to initialize them properly 
(esp. the
+          all-important 'isa' pointer). */
+       maybe_objc_check_decl (decl);
+ #else
       ;
+ #endif
     else if (TREE_CODE (decl) == CONST_DECL)
       {
         my_friendly_assert (TREE_CODE (decl) != REFERENCE_TYPE, 148);
*************** cp_finish_decl (decl, init, asmspec_tree
*** 7914,7919 ****
--- 8328,8338 ----
       }
     else if (init)
       {
+ #ifdef OBJCPLUS
+       /* If obj-c, make sure the variable is not declared static. */
+       maybe_objc_check_decl (decl);
+ #endif
+
         if (TYPE_HAS_CONSTRUCTOR (type) || TYPE_NEEDS_CONSTRUCTING 
(type))
         {
           if (TREE_CODE (type) == ARRAY_TYPE)
*************** cp_finish_decl (decl, init, asmspec_tree
*** 8062,8067 ****
--- 8481,8492 ----
           cleanup = maybe_build_cleanup (decl);
           resume_momentary (yes);
         }
+ #ifdef OBJCPLUS
+       /* zlaski 2001-Apr-23: Obj-C++ classes may not be statically 
allocated
+          since C++ would not know how to initialize them properly 
(esp. the
+          all-important 'isa' pointer). */
+       maybe_objc_check_decl (decl);
+ #endif
       }
     /* PARM_DECLs get cleanups, too.  */
     else if (TREE_CODE (decl) == PARM_DECL && TYPE_NEEDS_DESTRUCTOR 
(type))
*************** grokdeclarator (declarator, declspecs, d
*** 9347,9352 ****
--- 9820,9832 ----
         switch (TREE_CODE (decl))
           {
           case TREE_LIST:
+ #ifdef OBJCPLUS
+             /* zlaski 2001-Apr-03: In the 2.7.2.1 version of this 
routine, 0
+                was returned, which we still sometimes need. */
+             if(objc_old_semantics_expected) {
+               return 0;
+             }
+ #endif
             /* For attributes.  */
             next = &TREE_VALUE (decl);
             break;
*************** grokdeclarator (declarator, declspecs, d
*** 11511,11523 ****
               }

             /* 9.2p13 [class.mem] */
!           if (declarator == constructor_name (current_class_type)
!               /* Divergence from the standard:  In extern "C", we
!                  allow non-static data members here, because C does
!                  and /usr/include/netinet/in.h uses that.  */
!               && (staticp || ! in_system_header))
!             cp_pedwarn ("ANSI C++ forbids data member `%D' with same 
name as enclosing class",
!                         declarator);

             if (staticp)
               {
--- 12137,12153 ----
               }

             /* 9.2p13 [class.mem] */
! #ifdef OBJCPLUS
!             /* zlaski 2001-Mar-29: Obj-C++ classes have no 
constructors or destructors! */
!             if(objc_interface_context == NULL_TREE && 
objc_implementation_context == NULL_TREE)
! #endif
!               if (declarator == constructor_name (current_class_type)
!                 /* Divergence from the standard:  In extern "C", we
!                    allow non-static data members here, because C does
!                    and /usr/include/netinet/in.h uses that.  */
!                 && (staticp || ! in_system_header))
!               cp_warning ("ANSI C++ forbids data member `%D' with same 
name as enclosing class",
!                           declarator);

             if (staticp)
               {
*************** check_default_argument (decl, arg)
*** 11872,11878 ****
--- 12551,12561 ----
      only parameters which are specified with their types can take on
      default values.  */

+ #ifdef OBJCPLUS
+ tree
+ #else
   static tree
+ #endif
   grokparms (first_parm, funcdef_flag)
        tree first_parm;
        int funcdef_flag;
*************** grokparms (first_parm, funcdef_flag)
*** 11891,11897 ****
--- 12574,12590 ----
     else if (first_parm != NULL_TREE
            && TREE_CODE (TREE_VALUE (first_parm)) != TREE_LIST
            && TREE_CODE (TREE_VALUE (first_parm)) != VOID_TYPE)
+ #ifdef OBJCPLUS
+ /* snaroff (3/30/96): this is a total "COPOUT" fix for a problem 
briefly
+    described below. Nevertheless, it appears to work. Without it, we
+    would die anyway. A more elegant fix would require sifting through
+    subtle changes between grokparms for C++ and grokparms for ANSI-C.
+    I don't have the time right now
+  */
+     return first_parm;
+ #else
       my_friendly_abort (145);
+ #endif
     else
       {
         /* Types were specified.  This is a list of declarators
*************** grokparms (first_parm, funcdef_flag)
*** 12032,12037 ****
--- 12725,12735 ----
                   TREE_CHAIN (last_decl) = decl;
                   last_decl = decl;
                 }
+ /* snaroff (3/30/96): add_instance_method/comp_proto_with_proto and
+    really_start_method assume the parm list is immutable. This enables
+    obcp-act.c to call this routine multiple times. Without this,
+    we crash with "error(145)"...see beginning of this method.
+  */
               if (! current_function_decl && TREE_PERMANENT (list_node))
                 {
                   TREE_PURPOSE (list_node) = init;
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/decl2.c 
/apple/MacOSX/compiler/gcc/obcp/decl2.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/decl2.c  Thu Aug 19 16:29:45 1999
--- /apple/MacOSX/compiler/gcc/obcp/decl2.c     Wed Oct 24 17:53:21 2001
*************** Boston, MA 02111-1307, USA.  */
*** 50,55 ****
--- 50,59 ----
   extern cpp_reader  parse_in;
   #endif

+ #ifdef OBJCPLUS
+ #include "objc-act.h"
+ #endif
+
   /* This structure contains information about the initializations
      and/or destructions required for a particular priority level.  */
   typedef struct priority_info_s {
*************** lang_f_options[] =
*** 538,544 ****
--- 597,607 ----
      Otherwise return 0.  */

   int
+ #ifdef OBJCPLUS
+ cplus_decode_option (argc, argv)
+ #else
   lang_decode_option (argc, argv)
+ #endif
        int argc
   #if !USE_CPPLIB
     ATTRIBUTE_UNUSED
*************** delete_sanity (exp, size, doing_vec, use
*** 1238,1243 ****
--- 1332,1342 ----
     if (integer_zerop (t))
       return build1 (NOP_EXPR, void_type_node, t);

+ #ifdef OBJCPLUS
+   /* zlaski 2001-Apr-23: Do not call 'delete' on Obj-C++ objects! */
+   objc_check_type(TREE_TYPE(type));
+ #endif
+
     if (doing_vec)
       return build_vec_delete (t, maxindex, integer_one_node,
                              integer_zero_node, use_global_delete);
*************** grokbitfield (declarator, declspecs, wid
*** 1818,1824 ****
         return NULL_TREE;
       }

!   if (IS_SIGNATURE (current_class_type))
       {
         error ("field declaration not allowed in signature");
         return void_type_node;
--- 1924,1931 ----
         return NULL_TREE;
       }

!   /* do NOT remove the first conjunct! */
!   if (current_class_type != NULL_TREE && IS_SIGNATURE 
(current_class_type))
       {
         error ("field declaration not allowed in signature");
         return void_type_node;
*************** finish_file ()
*** 3737,3742 ****
--- 3934,3945 ----

     finish_repo ();

+ #ifdef OBJCPLUS
+   /* Wrap up ObjC++ processing only after templates
+      have been instantiated.  */
+   objc_finish ();
+ #endif
+
     this_time = get_run_time ();
     parse_time -= this_time - start_time;
     varconst_time += this_time - start_time;
*************** build_expr_from_tree (t)
*** 4046,4051 ****
--- 4351,4368 ----
           return build_x_function_call (name, args, current_class_ref);
         }

+ #ifdef OBJCPLUS
+     case MESSAGE_SEND_EXPR:
+       return finish_message_expr
+       (build_expr_from_tree (TREE_OPERAND (t, 0)),
+        TREE_OPERAND (t, 1),  /* No need to expand the selector.  */
+        build_expr_from_tree (TREE_OPERAND (t, 2)));
+
+     case CLASS_REFERENCE_EXPR:
+       return get_class_reference
+       (build_expr_from_tree (TREE_OPERAND (t, 0)));
+ #endif
+
       case COND_EXPR:
         return build_x_conditional_expr
         (build_expr_from_tree (TREE_OPERAND (t, 0)),
*************** mark_used (decl)
*** 5248,5253 ****
--- 5567,5579 ----
         && current_function_decl)
       synthesize_method (decl);

+ #ifdef OBJCPLUS
+   if(objc_implementation_context &&
+      (TREE_CODE(decl) == COMPOUND_EXPR || TREE_CODE(decl) == 
COMPONENT_REF)) {
+           return;
+   }
+ #endif
+
     /* If this is a function or variable that is an instance of some
        template, we now know that we will need to actually do the
        instantiation.  A TEMPLATE_DECL may also have DECL_TEMPLATE_INFO,
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/error.c 
/apple/MacOSX/compiler/gcc/obcp/error.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/error.c  Fri Aug  6 18:31:56 1999
--- /apple/MacOSX/compiler/gcc/obcp/error.c     Fri Jun  1 19:42:52 2001
*************** Boston, MA 02111-1307, USA.  */
*** 25,30 ****
--- 25,33 ----
   #include "cp-tree.h"
   #include "obstack.h"
   #include "toplev.h"
+ #ifdef OBJCPLUS
+ #include "objc-act.h"
+ #endif

   typedef char* cp_printer ();

*************** dump_type_real (t, v, canonical_name)
*** 314,319 ****
--- 346,358 ----
         OB_PUTS ("{anonymous template type parm}");
         break;

+ #ifdef OBJCPLUS
+     case INSTANCE_METHOD_DECL:
+     case CLASS_METHOD_DECL:
+       dump_decl (METHOD_DEFINITION (t), v);
+       break;
+ #endif
+
         /* This is not always necessary for pointers and such, but doing 
this
          reduces code size.  */
       case ARRAY_TYPE:
*************** dump_decl (t, v)
*** 948,953 ****
--- 989,1001 ----
         OB_PUTID (DECL_NAME (t));
         break;

+ #ifdef OBJCPLUS
+     case INSTANCE_METHOD_DECL:
+     case CLASS_METHOD_DECL:
+       dump_decl (METHOD_DEFINITION (t), v);
+       break;
+ #endif
+
       default:
         sorry ("`%s' not supported by dump_decl",
              tree_code_name[(int) TREE_CODE (t)]);
*************** dump_expr (t, nop)
*** 1784,1794 ****
         dump_decl (t, 0);
         break;

       case TREE_LIST:
!       if (TREE_VALUE (t) && TREE_CODE (TREE_VALUE (t)) == 
FUNCTION_DECL)
         {
!         OB_PUTID (DECL_NAME (TREE_VALUE (t)));
!         break;
         }
         /* else fall through */

--- 1838,1864 ----
         dump_decl (t, 0);
         break;

+ #ifdef OBJCPLUS
+     case INSTANCE_METHOD_DECL:
+     case CLASS_METHOD_DECL:
+       dump_decl (METHOD_DEFINITION (t), 1);
+       break;
+ #endif
+
       case TREE_LIST:
!       if (TREE_VALUE (t))
         {
!         if (TREE_CODE (TREE_VALUE (t)) == FUNCTION_DECL)
!           {
!             OB_PUTID (DECL_NAME (TREE_VALUE (t)));
!             break;
!           }
!         /* This can happen when we have a casted default parameter.  */
!         else if (TREE_CODE (TREE_VALUE (t)) == INTEGER_CST)
!           {
!             dump_expr (TREE_VALUE (t), nop);
!             break;
!           }
         }
         /* else fall through */

*************** language_as_string (c, v)
*** 1998,2003 ****
--- 2068,2078 ----
       {
       case lang_c:
         return "C";
+
+ #ifdef OBJCPLUS
+     case lang_objc:
+       return "Objective-C";
+ #endif

       case lang_cplusplus:
         return "C++";
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/gxx.gperf 
/apple/MacOSX/compiler/gcc/obcp/gxx.gperf
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/gxx.gperf        Thu Apr 22 
10:36:44 1999
--- /apple/MacOSX/compiler/gcc/obcp/gxx.gperf   Fri Jun  1 19:42:54 2001
***************
*** 1,8 ****
   %{
! /* Command-line: gperf -L KR-C -F ', 0, 0' -p -j1 -g -o -t -N 
is_reserved_word -k1,4,$,7 gplus.gperf  */
   %}
   struct resword { const char *name; short token; enum rid rid;};
   %%
   __alignof, ALIGNOF, NORID
   __alignof__, ALIGNOF, NORID
   __asm, ASM_KEYWORD, NORID
--- 1,21 ----
   %{
! /* Command-line: gperf -L C -p -j1 -g -G -o -t -N is_reserved_word 
-k'1,4,7,$' gxx.gperf  */
   %}
   struct resword { const char *name; short token; enum rid rid;};
+
   %%
+ @class, CLASS, NORID
+ @compatibility_alias, ALIAS, NORID
+ @defs, DEFS, NORID
+ @encode, ENCODE, NORID
+ @end, END, NORID
+ @implementation, IMPLEMENTATION, NORID
+ @interface, INTERFACE, NORID
+ @private, PRIVATE, NORID
+ @protected, PROTECTED, NORID
+ @protocol, PROTOCOL, NORID
+ @public, PUBLIC, NORID
+ @selector, SELECTOR, NORID
   __alignof, ALIGNOF, NORID
   __alignof__, ALIGNOF, NORID
   __asm, ASM_KEYWORD, NORID
*************** bitand, '&', NORID,
*** 41,46 ****
--- 56,63 ----
   bitor, '|', NORID,
   bool, TYPESPEC, RID_BOOL,
   break, BREAK, NORID,
+ bycopy, CV_QUALIFIER, RID_BYCOPY
+ byref, CV_QUALIFIER, RID_BYREF
   case, CASE, NORID,
   catch, CATCH, NORID,
   char, TYPESPEC, RID_CHAR,
*************** float, TYPESPEC, RID_FLOAT,
*** 64,71 ****
--- 81,91 ----
   for, FOR, NORID,
   friend, SCSPEC, RID_FRIEND,
   goto, GOTO, NORID,
+ id, OBJECTNAME, RID_ID
   if, IF, NORID,
+ in, CV_QUALIFIER, RID_IN
   inline, SCSPEC, RID_INLINE,
+ inout, CV_QUALIFIER, RID_INOUT
   int, TYPESPEC, RID_INT,
   long, TYPESPEC, RID_LONG,
   mutable, SCSPEC, RID_MUTABLE,
*************** not_eq, EQCOMPARE, NORID,
*** 76,81 ****
--- 96,104 ----
   operator, OPERATOR, NORID,
   or, OROR, NORID,
   or_eq, ASSIGN, NORID,
+ oneway, CV_QUALIFIER, RID_ONEWAY
+ out, CV_QUALIFIER, RID_OUT
   private, VISSPEC, RID_PRIVATE,
   protected, VISSPEC, RID_PROTECTED,
   public, VISSPEC, RID_PUBLIC,
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/lang-options.h 
/apple/MacOSX/compiler/gcc/obcp/lang-options.h
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/lang-options.h   Tue Apr 13 
22:34:55 1999
--- /apple/MacOSX/compiler/gcc/obcp/lang-options.h      Tue Jul 17 
13:29:32 2001
*************** along with GNU CC; see the file COPYING.
*** 18,24 ****
   the Free Software Foundation, 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

! DEFINE_LANG_NAME ("C++")

   /* This is the contribution to the `lang_options' array in gcc.c for
      g++.  */
--- 18,24 ----
   the Free Software Foundation, 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

! DEFINE_LANG_NAME ("ObjC++")

   /* This is the contribution to the `lang_options' array in gcc.c for
      g++.  */
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/lang-specs.h 
/apple/MacOSX/compiler/gcc/obcp/lang-specs.h
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/lang-specs.h     Mon May 17 
16:28:09 1999
--- /apple/MacOSX/compiler/gcc/obcp/lang-specs.h        Fri Jun  1 
19:42:55 2001
*************** Boston, MA 02111-1307, USA.  */
*** 21,33 ****
   /* This is the contribution to the `default_compilers' array in gcc.c 
for
      g++.  */

!   {".cc", {"@c++"}},
!   {".cp", {"@c++"}},
!   {".cxx", {"@c++"}},
!   {".cpp", {"@c++"}},
!   {".c++", {"@c++"}},
!   {".C", {"@c++"}},
!   {"@c++",
   #if USE_CPPLIB
      {
        "%{E|M|MM:cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} 
%{P} %{$} %I\
--- 21,29 ----
   /* This is the contribution to the `default_compilers' array in gcc.c 
for
      g++.  */

!   {".M", {"@objective-c++"}},
!   {".mm", {"@objective-c++"}},
!   {"@objective-c++",
   #if USE_CPPLIB
      {
        "%{E|M|MM:cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} 
%{P} %{$} %I\
*************** Boston, MA 02111-1307, USA.  */
*** 41,47 ****
         %{ffast-math:-D__FAST_MATH__}\
         %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
           %i %{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}}\n}\
!       %{!E:%{!M:%{!MM:cc1plus %i %1 %2\
                               -lang-c++ %{nostdinc*} %{C} %{A*} %{I*} 
%{P} %{$} %I\
                               %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
                               %{!no-gcc:-D__GNUC__=%v1 -D__GNUG__=%v1\
--- 37,43 ----
         %{ffast-math:-D__FAST_MATH__}\
         %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
           %i %{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}}\n}\
!       %{!E:%{!M:%{!MM:cc1objplus %i %1 %2\
                               -lang-c++ %{nostdinc*} %{C} %{A*} %{I*} 
%{P} %{$} %I\
                               %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
                               %{!no-gcc:-D__GNUC__=%v1 -D__GNUG__=%v1\
*************** Boston, MA 02111-1307, USA.  */
*** 73,79 ****
         %{ffast-math:-D__FAST_MATH__}\
         %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
           %i 
%{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
!     "%{!M:%{!MM:%{!E:cc1plus %{!pipe:%g.ii} %1 %2\
                             %{!Q:-quiet} -dumpbase %b.cc %{d*} %{m*} 
%{a}\
                             %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
                             %{v:-version} %{pg:-p} %{p}\
--- 69,75 ----
         %{ffast-math:-D__FAST_MATH__}\
         %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
           %i 
%{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
!     "%{!M:%{!MM:%{!E:cc1objplus %{!pipe:%g.ii} %1 %2\
                             %{!Q:-quiet} -dumpbase %b.cc %{d*} %{m*} 
%{a}\
                             %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
                             %{v:-version} %{pg:-p} %{p}\
*************** Boston, MA 02111-1307, USA.  */
*** 86,92 ****
   #endif /* ! USE_CPPLIB */
     {".ii", {"@c++-cpp-output"}},
     {"@c++-cpp-output",
!    {"%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
                             %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
                             %{v:-version} %{pg:-p} %{p}\
                             %{f*} %{+e*} %{aux-info*} %{Qn:-fno-ident}\
--- 82,88 ----
   #endif /* ! USE_CPPLIB */
     {".ii", {"@c++-cpp-output"}},
     {"@c++-cpp-output",
!    {"%{!M:%{!MM:%{!E:cc1objplus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
                             %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
                             %{v:-version} %{pg:-p} %{p}\
                             %{f*} %{+e*} %{aux-info*} %{Qn:-fno-ident}\
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/lex.c 
/apple/MacOSX/compiler/gcc/obcp/lex.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/lex.c    Wed Aug 11 11:36:44 1999
--- /apple/MacOSX/compiler/gcc/obcp/lex.c       Wed Oct 24 17:53:59 2001
*************** Boston, MA 02111-1307, USA.  */
*** 37,42 ****
--- 37,45 ----
   #include "c-pragma.h"
   #include "toplev.h"
   #include "output.h"
+ #ifdef OBJCPLUS
+ #include "objc-act.h"
+ #endif

   #ifdef MULTIBYTE_CHARS
   #include "mbchar.h"
*************** make_pointer_declarator (cv_qualifiers,
*** 184,190 ****
--- 194,204 ----
     if (target && TREE_CODE (target) == IDENTIFIER_NODE
         && ANON_AGGRNAME_P (target))
       error ("type name expected before `*'");
+ #ifdef OBJCPLUS
+   target = build_nt (INDIRECT_REF, target);
+ #else
     target = build_parse_node (INDIRECT_REF, target);
+ #endif
     TREE_TYPE (target) = cv_qualifiers;
     return target;
   }
*************** make_reference_declarator (cv_qualifiers
*** 216,222 ****
--- 230,241 ----
         if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P 
(target))
           error ("type name expected before `&'");
       }
+ #ifdef OBJCPLUS
+   /* Build node on permanent stack in Objective-C land.  */
+   target = build_nt (ADDR_EXPR, target);
+ #else
     target = build_parse_node (ADDR_EXPR, target);
+ #endif
     TREE_TYPE (target) = cv_qualifiers;
     return target;
   }
*************** char *token_buffer;             /* Pointer to token
*** 307,315 ****
                                    Actual allocated length is maxtoken + 
2.  */

   #include "hash.h"
!


! /* Nonzero tells yylex to ignore \ in string constants.  */
   static int ignore_escape_flag = 0;

   static tree
--- 326,373 ----
                                    Actual allocated length is maxtoken + 
2.  */

   #include "hash.h"
!
   #ifdef OBJCPLUS
! /* Objective-C++ protocol argument qualifier handling. */

! void
! forget_protocol_qualifiers ()
! {
!   int i, n = MAX_HASH_VALUE;
!
!   /* Check the lookahead tokens for protocol qualifiers.  */
!   forget_saved_protocol_qualifiers ();
!
!   for (i = 0; i < n; i++)
!     {
!       if (wordlist[i].rid >= RID_IN && wordlist[i].rid <= RID_ONEWAY)
!         wordlist[i].name = "";
!     }
! }
!
! void
! remember_protocol_qualifiers ()
! {
!   int i, n = MAX_HASH_VALUE;
!
!   for (i = 0; i < n; i++)
!     {
!       if (wordlist[i].rid == RID_IN)
!         wordlist[i].name = "in";
!       else if (wordlist[i].rid == RID_OUT)
!         wordlist[i].name = "out";
!       else if (wordlist[i].rid == RID_INOUT)
!         wordlist[i].name = "inout";
!       else if (wordlist[i].rid == RID_BYCOPY)
!         wordlist[i].name = "bycopy";
!       else if (wordlist[i].rid == RID_BYREF)
!         wordlist[i].name = "byref";
!       else if (wordlist[i].rid == RID_ONEWAY)
!         wordlist[i].name = "oneway";
!     }
! }
!
! #endif /* ifdef OBJCPLUS */
!
   /* Nonzero tells yylex to ignore \ in string constants.  */
   static int ignore_escape_flag = 0;

   static tree
*************** lang_init ()
*** 414,419 ****
--- 483,491 ----
   #endif
     if (flag_gnu_xref) GNU_xref_begin (input_filename);
     init_repo (input_filename);
+ #ifdef OBJCPLUS
+   objc_lang_init ();
+ #endif
   }

   void
*************** init_parse (filename)
*** 699,704 ****
--- 771,800 ----
     ridpointers[(int) RID_REGISTER] = get_identifier ("register");
     ridpointers[(int) RID_COMPLEX] = get_identifier ("__complex");

+ #ifdef OBJCPLUS
+   /* Objective-C protocol extensions */
+   ridpointers[(int) RID_ID] = get_identifier ("id");
+   ridpointers[(int) RID_IN] = get_identifier ("in");
+   ridpointers[(int) RID_OUT] = get_identifier ("out");
+   ridpointers[(int) RID_INOUT] = get_identifier ("inout");
+   ridpointers[(int) RID_BYCOPY] = get_identifier ("bycopy");
+   ridpointers[(int) RID_BYREF] = get_identifier ("byref");
+   ridpointers[(int) RID_ONEWAY] = get_identifier ("oneway");
+   /* The Objective-C++ protocol arg qualifiers are initially DISABLED, 
until
+      remember_protocol_qualifiers() is called. */
+   forget_protocol_qualifiers ();
+ #endif /* OBJCPLUS */
+
     /* C++ extensions. These are probably not correctly named.  */
     ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
     class_type_node = build_int_2 (class_type, 0);
*************** do_identifier (token, parsing, args)
*** 2845,2850 ****
--- 2986,2995 ----
     register tree id;
     int lexing = (parsing == 1);
     int in_call = (parsing == 2);
+ #ifdef OBJCPLUS
+   int is_objc_receiver_context = objc_receiver_context;
+   objc_receiver_context = 0;
+ #endif

     if (! lexing || IDENTIFIER_OPNAME_P (token))
       id = lookup_name (token, 0);
*************** do_identifier (token, parsing, args)
*** 2853,2858 ****
--- 2998,3021 ----

     /* Scope class declarations before global
        declarations.  */
+
+ #ifdef OBJCPLUS
+   /* lastiddecl gets reassigned to the following selector part if an i
+      dentifier is used as a keywordexpr or receiver.  E.g.  in
+      [.. x bar: ..] lastiddecl gets reassigned to the decl of bar
+      when handling x.  So we look it up once more */
+   if (objc_msg_context)
+     id = lookup_name (token, 0);
+ #endif
+
*************** do_identifier (token, parsing, args)
*** 2926,2931 ****
--- 3090,3103 ----
         }
         else if (in_call && ! flag_strict_prototype)
         {
+ #ifdef OBJCPLUS
+         /* This may be an application of a function pointer ivar */
+         if (objc_method_context && is_ivar (objc_ivar_chain, token))
+           {
+             id = build_ivar_reference (token);
+           }
+         else
+ #endif /* OBJCPLUS */
           id = implicitly_declare (token);
         }
         else if (current_function_decl == 0)
*************** do_identifier (token, parsing, args)
*** 2934,2939 ****
--- 3106,3124 ----
           id = error_mark_node;
         }
         else
+ #ifdef OBJCPLUS
+       if (is_objc_receiver_context
+          && !strcmp (IDENTIFIER_POINTER (token), "super"))
+       {
+         id = get_super_receiver ();
+       }
+       else if (objc_method_context
+              && is_ivar (objc_ivar_chain, token))
+       {
+         id = build_ivar_reference (token);
+       }
+       else
+ #endif
         {
           if (IDENTIFIER_NAMESPACE_VALUE (token) != error_mark_node
               || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
*************** do_identifier (token, parsing, args)
*** 2955,2960 ****
--- 3140,3169 ----
           SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
         }
       }
+ #ifdef OBJCPLUS
+   else  /* if (id && id != error_mark_node) */
+     {
+       /* we have a definition - still check if iVariable */
+
+       if (is_objc_receiver_context
+         && !strcmp (IDENTIFIER_POINTER (token), "super"))
+       {
+         id = get_super_receiver ();
+       }
+       else
+       {
+         if (objc_method_context && is_ivar (objc_ivar_chain, token))
+           {
+             if (IDENTIFIER_BINDING (token))
+               warning ("local declaration of `%s' "
+                        "hides instance variable",
+                        IDENTIFIER_POINTER (token));
+             else
+               id = build_ivar_reference (token);
+           }
+       }
+     }
+ #endif /* OBJCPLUS */

     if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
       {
*************** real_yylex ()
*** 3239,3247 ****
--- 3457,3472 ----
     register int c;
     register int value;
     int wide_flag = 0;
+ #ifdef OBJCPLUS
+   int objc_flag = 0;
+ #endif
     int dollar_seen = 0;
     int i;

     if (nextchar >= 0)
       c = nextchar, nextchar = -1;
     else
*************** real_yylex ()
*** 3315,3320 ****
--- 3540,3566 ----
         put_back (c);
         }

+ #ifdef OBJCPLUS
+     case '@':
+       /* '@' may start a constant string object as in @"String". */
+       if (doing_objc_thang)
+       {
+         register int c = getch ();
+         if (c == '"')
+           {
+             objc_flag = 1;
+             goto string_constant;
+           }
+         put_back (c);
+       }
+       else
+       {
+         warning ("possible Objective-C token in C++ input.  Use 
-ObjC");
+       }
+       /* If we FALL THROUGH to this point,
+        @ is the beginning of a keyword */
+ #endif /* OBJCPLUS */
+
       case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
       case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
       case 'K':           case 'M':  case 'N':  case 'O':
*************** real_yylex ()
*** 3409,3414 ****
--- 3665,3737 ----
               if (ptr->rid)
                 {
                   tree old_ttype = ridpointers[(int) ptr->rid];
+ #ifdef OBJCPLUS
+                   /* zlaski 2001-May-04: In the spirit of Turly's 
hackery, we
+                      bail out if we encounter any C++ keywords that 
really
+                      should be treated as identifiers */
+                   if (objc_need_raw_identifier && ptr->rid == 
RID_CLASS) {
+                     value = IDENTIFIER;
+                     goto check_identifier;
+                   }
+ #endif

                   /* If this provides a type for us, then revert lexical
                      state to standard state.  */
*************** real_yylex ()
*** 3504,3514 ****
--- 3827,3867 ----
                   token_buffer[0] = '^';
                   token_buffer[1] = 0;
                 }
+ #ifdef OBJCPLUS
+               /* zlaski 2001-May-17: I've tried to disable the 'and' 
and 'or'
+                  alternate C++ keywords altogether, but it turns out 
PowerPlant
+                  uses them!  Thing is, they also figure prominently in 
Cocoa
+                  as ObjC selectors. */
+               else if ((objc_msg_context || 
objc_in_method_signature) &&
+                   (ptr->token == ANDAND || ptr->token == OROR))
+                 {
+                   value = IDENTIFIER;
+                   goto check_identifier;
+                 }
+ #endif /* OBJCPLUS */

               value = (int) ptr->token;
+
+ #ifdef OBJCPLUS
+             /* Only return OBJECTNAME if it is a typedef.  */
+             if (value == OBJECTNAME)
+               {
+                 lastiddecl = lookup_name (yylval.ttype, 1);
+
+                 if (!objc_declarator_context
+                     && doing_objc_thang
+                     && lastiddecl
+                     && TREE_CODE (lastiddecl) == TYPE_DECL)
+                   value = OBJECTNAME;
+                 else
+                   value = IDENTIFIER;
+               }
+ #endif /* OBJCPLUS */
+
             }
         }

+ check_identifier:
         /* If we did not find a keyword, look for an identifier
            (or a typename).  */

*************** real_yylex ()
*** 3519,3524 ****
--- 3872,3883 ----
           {
             register tree tmp = get_identifier (token_buffer);

+ #ifdef OBJCPLUS
+         identifier:
+           if (token_buffer[0] == '@')
+             error ("illegal identifier `%s'", token_buffer);
+ #endif /* OBJCPLUS */
+
   #if !defined(VMS) && defined(JOINER)
             /* Make sure that user does not collide with our internal
                naming scheme.  */
*************** real_yylex ()
*** 3533,3542 ****
--- 3892,3918 ----
                     || ANON_PARMNAME_P (tmp)))
               warning ("identifier name `%s' conflicts with GNU C++ 
internal naming strategy",
                        token_buffer);
+ #ifdef OBJCPLUS
+           else                /* match syntax below */
   #endif
+ #endif
+ #ifdef OBJCPLUS
+             if (doing_objc_thang && !objc_need_raw_identifier
+                 && is_class_name (tmp)
+                 && !got_scope
+                 && (lookup_name(tmp, -2) == 
IDENTIFIER_GLOBAL_VALUE(tmp)))
+               /* This is not the right way to determine that we're 
looking
+                  in global scope and something is shadowing the class 
decl
+                  because it doesn't catch the case of name being 
defined
+                  inside class scope.  */
+               value = CLASSNAME;
+ #endif /* OBJCPLUS */

             yylval.ttype = tmp;
           }
+ #ifdef OBJCPLUS
+         objc_need_raw_identifier = 0;  /* reset flag */
+ #endif
         if (value == NEW && ! global_bindings_p ())
           {
             value = NEW;
*************** real_yylex ()
*** 4278,4297 ****
             *p++ = 0;
           }

         /* We have read the entire constant.
            Construct a STRING_CST for the result.  */

         if (processing_template_decl)
           push_obstacks (&permanent_obstack, &permanent_obstack);
-       yylval.ttype = build_string (p - (token_buffer + 1), 
token_buffer + 1);
-       if (processing_template_decl)
-         pop_obstacks ();

!       if (wide_flag)
!         TREE_TYPE (yylval.ttype) = wchar_array_type_node;
!       else
!         TREE_TYPE (yylval.ttype) = char_array_type_node;

         value = STRING; break;
         }

--- 4704,4757 ----
             *p++ = 0;
           }

+ #ifdef OBJCPLUS
+       if (objc_flag)
+         {
+           /* Return an Objective-C @"..." constant string object.  */
+           yylval.ttype = build_objc_string (p - (token_buffer + 1),
+                                             token_buffer + 1);
+           TREE_TYPE (yylval.ttype) = char_array_type_node;
+           value = OBJC_STRING;
+             break;
+         }
+ #endif
+
         /* We have read the entire constant.
            Construct a STRING_CST for the result.  */

         if (processing_template_decl)
           push_obstacks (&permanent_obstack, &permanent_obstack);

*************** real_yylex ()
*** 4480,4485 ****
--- 4940,4951 ----
         else value = c;
         break;

+ #ifdef OBJCPLUS
+     case ';': case ')':
+       objc_need_raw_identifier = 0;
+       /* fall through */
+ #endif
+
       default:
         value = c;
       }
*************** int
*** 4499,4505 ****
   is_rid (t)
        tree t;
   {
!   return !!is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH 
(t));
   }

   #ifdef GATHER_STATISTICS
--- 4965,4997 ----
   is_rid (t)
        tree t;
   {
!   struct resword *r;
!
!   r = is_reserved_word (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t));
!
! #ifdef OBJCPLUS
!   /* zlaski 2001-Mar-28: let the Obj-C++ keywords through, they're not 
really
!      "reserved" */
!   if(r && r->rid >= RID_IN && r->rid <= RID_ID) {
!       r = 0;
!   }
!   /* zlaski 2001-Apr-04: Allow the C++ 'class' keyword to also be used 
as
!      an identifier. For simplicity's sake, allow this for all languages
!      (an ivar named "class" is generated in objc-act.c) */
!   if(r && r->rid == RID_CLASS) {
!        r = 0;
!   }
! #endif
!   return !!r;
   }

   #ifdef GATHER_STATISTICS
*************** retrofit_lang_decl (t)
*** 4586,4591 ****
--- 5078,5087 ----
       DECL_LANGUAGE (t) = lang_c;
     else if (current_lang_name == lang_name_java)
       DECL_LANGUAGE (t) = lang_java;
+ #ifdef OBJCPLUS
+   else if (current_lang_name == lang_name_objc)
+     DECL_LANGUAGE (t) = lang_c; /* same mangling, etc., as for C */
+ #endif
     else my_friendly_abort (64);

   #if 0 /* not yet, should get fixed properly later */
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/lex.h 
/apple/MacOSX/compiler/gcc/obcp/lex.h
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/lex.h    Wed Dec 16 13:15:40 1998
--- /apple/MacOSX/compiler/gcc/obcp/lex.h       Fri Jun  1 19:42:55 2001
*************** enum rid
*** 64,71 ****
--- 64,102 ----
     RID_AUTO,
     RID_MUTABLE,
     RID_COMPLEX,
+
+ #ifdef OBJCPLUS
+   RID_IN,       /* begin Objective-C type modifiers */
+   RID_OUT,
+   RID_INOUT,
+   RID_BYCOPY,
+   RID_BYREF,
+   RID_ONEWAY,
+   RID_ID,       /* end Objective-C type modifiers */
+ #undef RID_LAST_MODIFIER
+ #define RID_LAST_MODIFIER RID_ID
+ #endif
+
     /* This is where grokdeclarator ends its search when setting the
        specbits.  */

*************** extern tree got_object;
*** 135,137 ****
--- 168,179 ----
   extern int pending_lang_change;

   extern int yylex PROTO((void));
+
+ #ifdef OBJCPLUS
+ extern void yyerror PROTO((const char *));
+
+ extern tree make_pointer_declarator PROTO((tree, tree));
+ extern void reinit_parse_for_function PROTO((void));
+ extern void forget_protocol_qualifiers PROTO((void));
+ extern void remember_protocol_qualifiers PROTO((void));
+ #endif
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/parse.y 
/apple/MacOSX/compiler/gcc/obcp/parse.y
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/parse.y  Mon Aug  9 03:51:17 1999
--- /apple/MacOSX/compiler/gcc/obcp/parse.y     Wed Oct 24 18:02:42 2001
***************
*** 1,4 ****
! /* YACC parser for C++ syntax.
      Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
      Hacked by Michael Tiemann (tiemann@cygnus.com)

--- 1,4 ----
! /* YACC parser for Objective-C++ syntax.
      Copyright (C) 1988, 89, 93-98, 1999 Free Software Foundation, Inc.
      Hacked by Michael Tiemann (tiemann@cygnus.com)

*************** Boston, MA 02111-1307, USA.  */
*** 43,56 ****
--- 43,69 ----
   #include "except.h"
   #include "toplev.h"

+ #ifdef OBJCPLUS
+ #include "objc-act.h"
+
+ /* the `decl' list operators optimization is not appropriate for 
Objective-C */
+ #define build_decl_list       build_tree_list
+ #define decl_tree_cons                tree_cons
+ #endif
+
   /* Since parsers are distinct for each language, put the language 
string
      definition here.  (fnf) */
+ #ifdef OBJCPLUS
+ char *language_string = "GNU Obj-C++";
+ #else
   char *language_string = "GNU C++";
+ #endif

   extern tree void_list_node;
   extern struct obstack permanent_obstack;

   extern int end_of_file;
+ extern int flag_new_for_scope;

   /* Like YYERROR but do call yyerror.  */
   #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
*************** empty_parms ()
*** 101,106 ****
--- 114,122 ----
      but they can also serve as typespecs in declarations.  */
   %token TYPENAME
   %token SELFNAME
+ /* Objective-C */
+ %token CLASSNAME
+ %token OBJECTNAME

   /* A template function.  */
   %token PFUNCNAME
*************** empty_parms ()
*** 145,150 ****
--- 163,176 ----
   %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
   %token <itype> SCOPE

+ /* The Objective-C keywords.   */
+ %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
+ %token PUBLIC PRIVATE PROTECTED PROTOCOL CLASS ALIAS
+
+ /* Objective-C string constants in raw form.
+    yylval is an OBJC_STRING_CST node.  */
+ %token OBJC_STRING
+
   /* Define the operator tokens and their precedences.
      The value is an integer because, if used, it is the tree code
      to use in the expression made from the operator.  */
*************** empty_parms ()
*** 157,163 ****
   %nonassoc IF
   %nonassoc ELSE

! %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC 
CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME 
TYPENAME_KEYWORD

   %left '{' ',' ';'

--- 183,189 ----
   %nonassoc IF
   %nonassoc ELSE

! %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC 
CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME 
TYPENAME_KEYWORD CLASSNAME OBJECTNAME

   %left '{' ',' ';'

*************** empty_parms ()
*** 280,285 ****
--- 306,323 ----
   /* Used in lex.c for parsing pragmas.  */
   %token END_OF_LINE

+ /* the Objective-C productions */
+ %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
+ %type <ttype> methoddecl unaryselector keywordselector selector 
methodtype
+ %type <ttype> keyworddecl receiver objcmessageexpr messageargs
+ %type <ttype> keywordexpr keywordarglist keywordarg reservedword
+ %type <ttype> myparms myparm optparmlist objcselectorexpr
+ %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
+ %type <ttype> objc_string protocolrefs identifier_list identifier_colon
+ %type <ttype> objcprotocolexpr CLASSNAME OBJC_STRING OBJECTNAME
+ %type <ttype> objc_openbracket.expr objc_closebracket
+ %type <ttype> objc_return_type_mods
+
   /* lex.c and pt.c depend on this being the last token.  Define
      any new tokens before this one!  */
   %token END_OF_SAVED_INPUT
*************** static tree prefix_attributes;
*** 297,307 ****
--- 335,364 ----
   /* When defining an enumeration, this is the type of the 
enumeration.  */
   static tree current_enum_type;

+ /* List of Objective-C specific information */
+
+ tree objc_interface_context;
+ tree objc_implementation_context;
+ tree objc_method_context;
+ tree objc_ivar_chain;
+ tree objc_ivar_context;
+ static enum tree_code objc_inherit_code;
+ int objc_receiver_context = 0;
+ int objc_declarator_context = 0;
+ int objc_msg_context = 0;
+ int objc_public_flag;
+ tree super_type, selector_type, id_type, objc_class_type;
+ tree objc_object_id, objc_class_id, objc_id_id;
+ int objc_need_raw_identifier = 0;
+ int objc_in_method_signature = 0;
+
+ extern char *token_buffer;
+
   /* Tell yyparse how to print a token's value, if yydebug is set.  */

   #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
*************** extdef:
*** 391,396 ****
--- 448,454 ----
                 { if (pending_inlines) do_pending_inlines (); }
         | datadef
                 { if (pending_inlines) do_pending_inlines (); }
+         | objcdef
         | template_def
                 { if (pending_inlines) do_pending_inlines (); }
         | asm_keyword '(' string ')' ';'
*************** identifier:
*** 850,855 ****
--- 908,915 ----
         | SELFNAME
         | PTYPENAME
         | NSNAME
+       | OBJECTNAME
+         | CLASSNAME
         ;

   notype_identifier:
*************** unary_expr:
*** 1159,1164 ****
--- 1223,1232 ----
                 { $$ = delete_sanity ($5, $3, 2, $1);
                   if (yychar == YYEMPTY)
                     yychar = YYLEX; }
+       | delete objc_openbracket.expr objc_closebracket cast_expr %prec 
UNARY
+               { $$ = delete_sanity ($4, $2, 2, $1);
+                 if (yychar == YYEMPTY)
+                   yychar = YYLEX; }
         | REALPART cast_expr %prec UNARY
                 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
         | IMAGPART cast_expr %prec UNARY
*************** expr_no_commas:
*** 1288,1294 ****
                       C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
         | expr_no_commas ASSIGN expr_no_commas
                 { $$ = build_x_modify_expr ($$, $2, $3); }
!       | THROW
                 { $$ = build_throw (NULL_TREE); }
         | THROW expr_no_commas
                 { $$ = build_throw ($2); }
--- 1358,1364 ----
                       C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
         | expr_no_commas ASSIGN expr_no_commas
                 { $$ = build_x_modify_expr ($$, $2, $3); }
!       | THROW  %prec EMPTY
                 { $$ = build_throw (NULL_TREE); }
         | THROW expr_no_commas
                 { $$ = build_throw ($2); }
*************** primary:
*** 1541,1546 ****
--- 1611,1625 ----
                 { $$ = finish_pseudo_destructor_call_expr ($1, 
NULL_TREE, $3); }
         | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
                 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
+       /* Objective-C expressions */
+       | objcmessageexpr
+               { $$ = build_message_expr ($1); }
+       | objcselectorexpr
+               { $$ = build_selector_expr ($1); }
+       | objcprotocolexpr
+               { $$ = build_protocol_expr ($1); }
+       | objc_string
+               { $$ = build_objc_string_object ($1); }
         | object error
                 {
                   $$ = error_mark_node;
*************** string:
*** 1611,1616 ****
--- 1690,1707 ----
           STRING
         | string STRING
                 { $$ = chainon ($$, $2); }
+       | objcencodeexpr
+               { $$ = build_encode_expr ($1); }
+       | string objcencodeexpr
+               { $$ = chainon ($$, build_encode_expr ($1)); }
+       ;
+
+ /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs 
chained
+    onto it.  */
+ objc_string:
+         OBJC_STRING
+       | objc_string OBJC_STRING
+               { $$ = chainon ($1, $2); }
         ;

   nodecls:
*************** reserved_typespecquals:
*** 1819,1825 ****
   typespec:
           structsp
         | TYPESPEC  %prec EMPTY
!               { $$.t = $1; $$.new_type_flag = 0; }
         | complete_type_name
                 { $$.t = $1; $$.new_type_flag = 0; }
         | TYPEOF '(' expr ')'
--- 1910,1923 ----
   typespec:
           structsp
         | TYPESPEC  %prec EMPTY
!               { $$.t = $1; $$.new_type_flag = 0;
!                   if(!processing_template_parmlist) 
objc_need_raw_identifier = 1; }
!         | CLASSNAME protocolrefs
!               { $$.t = get_static_reference ($1, $2);
!                 $$.new_type_flag = 0; }
!       | OBJECTNAME protocolrefs
!               { $$.t = get_object_reference ($2);
!                 $$.new_type_flag = 0; }
         | complete_type_name
                 { $$.t = $1; $$.new_type_flag = 0; }
         | TYPEOF '(' expr ')'
*************** opt.component_decl_list:
*** 2436,2441 ****
--- 2536,2547 ----
         | component_decl_list
         | opt.component_decl_list access_specifier component_decl_list
         | opt.component_decl_list access_specifier
+       /* ObjC @defs(class) construct.  Note that the trailing semicolon
+          is optional.  */
+         | DEFS '(' CLASSNAME ')'
+                 { emit_class_ivars($3); }
+         | DEFS '(' CLASSNAME ')' ';'
+                 { emit_class_ivars($3); }
         ;

   access_specifier:
*************** nonmomentary_expr:
*** 2745,2756 ****
--- 2852,2883 ----
                 { resume_momentary ((int) $<itype>1); $$ = $2; }
         ;

+ /* This rule needs to be before after_type_declarator so that we 
resolve
+    the reduce/reduce conflict in state 111 correctly.  We need to 
resolve it
+    the same way that vanilla C++ resolves the reduce/reduce conflict 
in state
+    105.  That is we must assume that we are processing a typespec 
rather than
+    an after_type_declarator when we see a TYPENAME and aren't sure.  
For the
+    OBJECTNAME case this means we must read any protocolrefs, and then 
resume
+    processing the typespec. */
+ protocolrefs:
+           /* empty */
+               {
+                   $$ = NULL_TREE;
+                 }
+       | '<' identifier_list '>'
+               {
+                     $$ = $2;
+               }
+         ;
+
   /* An expression which will not live on the momentary obstack.  */
   maybe_parmlist:
           suspend_mom '(' nonnull_exprlist ')'
                 { resume_momentary ((int) $<itype>1); $$ = $3; }
         | suspend_mom '(' parmlist ')'
                 { resume_momentary ((int) $<itype>1); $$ = $3; }
+       | suspend_mom OBJECTNAME LEFT_RIGHT
+               { resume_momentary ((int) $<itype>1); $$ = 
empty_parms (); }
         | suspend_mom LEFT_RIGHT
                 { resume_momentary ((int) $<itype>1); $$ = 
empty_parms (); }
         | suspend_mom '(' error ')'
*************** direct_after_type_declarator:
*** 2800,2805 ****
--- 2927,2933 ----
                   $$ = build_parse_node (SCOPE_REF, $$, $2);
                   TREE_COMPLEXITY ($$) = current_class_depth; }
         | type_name  %prec EMPTY
+       | OBJECTNAME %prec EMPTY
         ;

   nonnested_type:
*************** compstmt_or_error:
*** 3245,3251 ****

   compstmt:
           '{'
!                 { $<ttype>$ = begin_compound_stmt (0); }
           compstmtend
                   { $$ = finish_compound_stmt (0, $<ttype>2); }
         ;
--- 3373,3380 ----

   compstmt:
           '{'
!                 { $<ttype>$ = begin_compound_stmt (0);
!                   if(objc_method_context) add_objc_super_decl();  }
           compstmtend
                   { $$ = finish_compound_stmt (0, $<ttype>2); }
         ;
*************** operator_name:
*** 3792,3797 ****
--- 3921,4683 ----
                 { $$ = grokoptypename ($2.t, $3); }
         | operator error
                 { $$ = ansi_opname[ERROR_MARK]; }
+       ;
+
+ /*
+  *    Objective-C productions.
+  */
+
+ /* records the type and storage class specs to use for processing
+    the declarators that follow */
+
+ .setspecs: /* empty */
+               { current_declspecs = $<ttype>0;
+                 $<itype>$ = suspend_momentary (); }
+       ;
+
+ objcdef:
+         classdef
+       | classdecl
+       | protocoldecl
+       | aliasdecl
+       | protocoldef
+       | methoddef
+       | END
+               {
+                 if (objc_implementation_context)
+                     {
+                   finish_class(objc_implementation_context);
+                   objc_ivar_chain = NULL_TREE;
+                   objc_implementation_context = NULL_TREE;
+                   }
+                 else
+                   warning("`@end' must appear in an implementation 
context");
+               }
+       ;
+
+ /* A nonempty list of identifiers.  */
+ identifier_list:
+         identifier
+               { $$ = build_tree_list (NULL_TREE, $1); }
+       | identifier_list ',' identifier
+               { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
+       ;
+
+ classdecl:
+         CLASS identifier_list ';'
+               {
+                 objc_declare_class ($2);
+               }
+
+ protocoldecl:
+         PROTOCOL identifier_list ';'
+               {
+                 objc_declare_protocols ($2);
+               }
+
+ aliasdecl:
+         ALIAS identifier identifier ';'
+               {
+                 objc_declare_alias ($2, $3);
+               }
+
+ /* This is necessary for living in this c++ parser */
+ identifier_colon:
+         identifier ':'
+               { $$ = $1 }
+       | PTYPENAME
+       ;
+
+ classdef:
+         INTERFACE identifier protocolrefs '{'
+               {
+                 objc_interface_context = objc_ivar_context
+                   = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, 
$3);
+                   objc_public_flag = 0;
+               }
+         ivar_decl_list '}'
+               {
+                   continue_class (objc_interface_context);
+               }
+         methodprotolist
+         END
+               {
+                 finish_class (objc_interface_context);
+                 objc_interface_context = NULL_TREE;
+               }
+
+       | INTERFACE identifier protocolrefs
+               {
+                 objc_interface_context
+                   = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, 
$3);
+                   continue_class (objc_interface_context);
+               }
+         methodprotolist
+         END
+               {
+                 finish_class(objc_interface_context);
+                 objc_interface_context = NULL_TREE;
+               }
+
+       | INTERFACE identifier_colon identifier protocolrefs '{'
+               {
+                 objc_interface_context = objc_ivar_context
+                   = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4);
+                   objc_public_flag = 0;
+               }
+         ivar_decl_list '}'
+               {
+                   continue_class (objc_interface_context);
+               }
+         methodprotolist
+         END
+               {
+                 finish_class(objc_interface_context);
+                 objc_interface_context = NULL_TREE;
+               }
+
+       | INTERFACE identifier_colon identifier protocolrefs
+               {
+                 objc_interface_context
+                   = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4);
+                   continue_class (objc_interface_context);
+               }
+         methodprotolist
+         END
+               {
+                 finish_class (objc_interface_context);
+                 objc_interface_context = NULL_TREE;
+               }
+
+       | IMPLEMENTATION identifier '{'
+               {
+                 objc_implementation_context = objc_ivar_context
+                   = start_class (CLASS_IMPLEMENTATION_TYPE, $2, 
NULL_TREE, NULL_TREE);
+                   objc_public_flag = 0;
+               }
+         ivar_decl_list '}'
+               {
+                   objc_ivar_chain
+                   = continue_class (objc_implementation_context);
+               }
+
+       | IMPLEMENTATION identifier
+               {
+                 objc_implementation_context
+                   = start_class (CLASS_IMPLEMENTATION_TYPE, $2, 
NULL_TREE, NULL_TREE);
+                   objc_ivar_chain
+                   = continue_class (objc_implementation_context);
+               }
+
+       | IMPLEMENTATION identifier_colon identifier '{'
+               {
+                 objc_implementation_context = objc_ivar_context
+                   = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, 
NULL_TREE);
+                   objc_public_flag = 0;
+               }
+         ivar_decl_list '}'
+               {
+                   objc_ivar_chain
+                   = continue_class (objc_implementation_context);
+               }
+
+       | IMPLEMENTATION identifier_colon identifier
+               {
+                 objc_implementation_context
+                   = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, 
NULL_TREE);
+                   objc_ivar_chain
+                   = continue_class (objc_implementation_context);
+               }
+
+       | INTERFACE identifier '(' identifier ')' protocolrefs
+               {
+                 objc_interface_context
+                   = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
+                   continue_class (objc_interface_context);
+               }
+         methodprotolist
+         END
+               {
+                 finish_class (objc_interface_context);
+                 objc_interface_context = NULL_TREE;
+               }
+
+       | IMPLEMENTATION identifier '(' identifier ')'
+               {
+                 objc_implementation_context
+                   = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, 
NULL_TREE);
+                   objc_ivar_chain
+                   = continue_class (objc_implementation_context);
+               }
+       ;
+
+ protocoldef:
+         PROTOCOL identifier '<' identifier_list '>'
+               {
+               objc_interface_context =
+                       start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $4);
+               }
+         methodprotolist
+         END
+               {
+               finish_protocol(objc_interface_context);
+               objc_interface_context = NULL_TREE;
+               }
+       | PROTOCOL identifier
+               {
+               objc_interface_context =
+                       start_protocol(PROTOCOL_INTERFACE_TYPE, $2, 
NULL_TREE);
+               }
+         methodprotolist
+         END
+               {
+               finish_protocol(objc_interface_context);
+               objc_interface_context = NULL_TREE;
+               }
+       ;
+
+ ivar_decl_list:
+           ivar_decl_list visibility_spec ivar_decls
+         | ivar_decls
+         ;
+
+ visibility_spec:
+         PUBLIC     { objc_public_flag = 1; }
+       | PRIVATE    { objc_public_flag = 2; }
+       | PROTECTED  { objc_public_flag = 0; }
+       ;
+
+ ivar_decls:
+           /* empty */
+               {
+                   $$ = NULL_TREE;
+                 }
+       | ivar_decls ivar_decl ';'
+       | ivar_decls ';'
+               {
+                   if (pedantic)
+                   warning ("extra semicolon in struct or union 
specified");
+                 }
+       ;
+
+ ivar_decl:
+       typed_typespecs .setspecs ivars
+               {
+                   $$ = $3;
+                 resume_momentary ($<itype>2);
+                 }
+       | nonempty_cv_qualifiers .setspecs ivars
+               {
+                   $$ = $3;
+                 resume_momentary ($<itype>2);
+                 }
+       | error
+               { $$ = NULL_TREE; }
+       ;
+
+ ivars:
+         /* empty */
+               { $$ = NULL_TREE; }
+       | ivar_declarator
+       | ivars ',' ivar_declarator
+       ;
+
+ ivar_declarator:
+         declarator
+               {
+                 $$ = add_instance_variable(objc_ivar_context, 
objc_public_flag,
+                            $1, current_declspecs, NULL_TREE);
+                 }
+       | declarator ':' expr_no_commas
+               {
+                 $$ = add_instance_variable(objc_ivar_context, 
objc_public_flag,
+                            $1, current_declspecs, $3);
+                 }
+       | ':' expr_no_commas
+               {
+                 $$ = add_instance_variable(objc_ivar_context, 
objc_public_flag,
+                            NULL_TREE, current_declspecs, $2);
+                 }
+       ;
+
+ methoddef:
+         '+'
+               {
+                   if (flag_dump_symbols)
+                     printf ("++m");
+                   if (flag_gen_index)
+                     dump_symbol_info ("++m ", NULL, -1);
+                 if (objc_implementation_context)
+                   objc_inherit_code = CLASS_METHOD_DECL;
+                   else
+                   fatal("Illegal method definition - must be in a 
class context.");
+                   objc_in_method_signature = 1;
+               }
+         methoddecl
+               {
+                 add_class_method(objc_implementation_context,$3);
+                 start_method_def ($3);
+                 objc_method_context = $3;
+                   objc_in_method_signature = 0;
+               }
+         optarglist
+               {
+                 continue_method_def();
+               }
+         compstmt_or_error
+               {
+                 finish_method_def ();
+                 objc_method_context = NULL_TREE;
+                   if (flag_dump_symbols)
+                     printf ("--m %u\n", lineno);
+                   if (flag_gen_index)
+                     dump_symbol_info ("--m ", NULL, lineno);
+               }
+
+       | '-'
+               {
+                   if (flag_dump_symbols)
+                     printf ("+-m");
+                   if (flag_gen_index)
+                     dump_symbol_info ("+-m ", NULL, -1);
+                 if (objc_implementation_context)
+                   objc_inherit_code = INSTANCE_METHOD_DECL;
+                   else
+                   fatal("Illegal method definition - must be in a 
class context.");
+                   objc_in_method_signature = 1;
+               }
+         methoddecl
+               {
+                 add_instance_method(objc_implementation_context,$3);
+                 start_method_def ($3);
+                 objc_method_context = $3;
+                   objc_in_method_signature = 0;
+               }
+         optarglist
+               {
+                 continue_method_def();
+               }
+         compstmt_or_error
+               {
+                 finish_method_def ();
+                 objc_method_context = NULL_TREE;
+                   if (flag_dump_symbols)
+                     printf ("--m %u\n", lineno);
+                   if (flag_gen_index)
+                     dump_symbol_info ("--m ", NULL, lineno);
+               }
+       ;
+
+ /* the reason for the strange actions in this rule
+  is so that notype_initdecls when reached via datadef
+  can find a valid list of type and sc specs in $0. */
+
+ methodprotolist:
+         /* empty  */
+       | {$<ttype>$ = NULL_TREE; } methodprotolist2
+       ;
+
+ methodprotolist2:              /* eliminates a shift/reduce conflict */
+         methodproto
+       | datadef
+       | methodprotolist2 methodproto
+       | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
+       ;
+
+ semi_or_error:
+         ';'
+       | error
+       ;
+
+ methodproto:
+         '+'
+               {
+                   if (flag_dump_symbols)
+                     printf ("++h");
+                   if (flag_gen_index)
+                     dump_symbol_info ("++h ", NULL, -1);
+                 objc_inherit_code = CLASS_METHOD_DECL;
+                   objc_in_method_signature = 1;
+               }
+         methoddecl
+               {
+                 add_class_method(objc_interface_context,$3);
+                   objc_in_method_signature = 0;
+               }
+         semi_or_error
+
+       | '-'
+               {
+                   if (flag_dump_symbols)
+                     printf ("+-h");
+                   if (flag_gen_index)
+                     dump_symbol_info ("+-h ", NULL, -1);
+                 objc_inherit_code = INSTANCE_METHOD_DECL;
+                   objc_in_method_signature = 1;
+               }
+         methoddecl
+               {
+                 add_instance_method(objc_interface_context,$3);
+                   objc_in_method_signature = 0;
+               }
+         semi_or_error
+       ;
+
+ start_method_typename:
+       '('     { remember_protocol_qualifiers (); }
+
+ end_method_typename:
+       ')'     { forget_protocol_qualifiers (); }
+
+ methodtype:
+       start_method_typename type_id end_method_typename
+               { $$ = $2.t; }
+
+ objc_return_type_mods:
+       SCSPEC
+               { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
+       | objc_return_type_mods SCSPEC
+               { $$ = tree_cons (NULL_TREE, $2, $1); }
+       ;
+
+ methoddecl:
+       start_method_typename type_id end_method_typename unaryselector
+               {
+               $$ = build_method_decl (objc_inherit_code, $2.t, $4, 
NULL_TREE, NULL_TREE);
+               }
+
+       | start_method_typename objc_return_type_mods type_id
+               end_method_typename unaryselector
+               {
+               $$ = build_method_decl (objc_inherit_code, $2, $5, 
NULL_TREE, NULL_TREE);
+               }
+
+       | unaryselector
+               {
+               $$ = build_method_decl (objc_inherit_code, NULL_TREE, 
$1, NULL_TREE, NULL_TREE);
+               }
+
+       | start_method_typename objc_return_type_mods type_id
+               end_method_typename keywordselector optparmlist
+               {
+               $$ = build_method_decl (objc_inherit_code, $2, $3.t, $5, 
$6);
+               }
+
+       | start_method_typename type_id end_method_typename 
keywordselector optparmlist
+               {
+               $$ = build_method_decl (objc_inherit_code, $2.t, $4, $5, 
NULL_TREE);
+               }
+
+       | keywordselector optparmlist
+               {
+               $$ = build_method_decl (objc_inherit_code, NULL_TREE, 
$1, $2, NULL_TREE);
+               }
+       ;
+
+
+ /* "optarglist" assumes that start_method_def() has already been 
called...
+    if it is not, the "xdecls" will not be placed in the proper scope */
+
+ optarglist:
+         /* empty */
+       | ';' myxdecls
+       ;
+
+ /* to get around the following situation: "int foo(int a) int b; {}" 
that
+    is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
+
+ myxdecls:
+         /* empty */
+       | mydecls
+       ;
+
+ mydecls:
+       mydecl
+       | errstmt
+       | mydecls mydecl
+       | mydecl errstmt
+       ;
+
+ mydecl:
+       typed_declspecs .setspecs myparms ';'
+               { resume_momentary ($<itype>2); }
+       | typed_declspecs ';'
+               { shadow_tag ($1.t); }
+       | declmods ';'
+               { warning ("empty declaration"); }
+       ;
+
+ /* this must be converted to live in the g++ world...snaroff */
+
+ myparms:
+       myparm
+               { objcplus_push_parm_decl ($1); }
+       | myparms ',' myparm
+               { objcplus_push_parm_decl ($3); }
+       ;
+
+ /* A single parameter declaration or parameter type name,
+    as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
+
+ myparm:
+        notype_declarator
+               { $$ = build_tree_list (current_declspecs, $1)  ; }
+       | absdcl
+               { $$ = build_tree_list (current_declspecs, $1)  ; }
+       ;
+
+ optparmlist:
+         /* empty */
+               {
+                 $$ = NULL_TREE;
+               }
+       | ',' ELLIPSIS
+               {
+                 /* oh what a kludge! */
+                 $$ = (tree)1;
+               }
+       | ','
+               {
+                 pushlevel (0);
+               }
+         parmlist
+               {
+                 /* returns a tree list node generated by 
`get_parm_info()' */
+                 $$ = $3;
+                 poplevel(0,0,0);
+               }
+       ;
+
+ unaryselector:
+         selector
+       ;
+
+ keywordselector:
+         keyworddecl
+       | keywordselector keyworddecl
+               {
+                 $$ = chainon($1, $2);
+               }
+       ;
+
+ selector:
+           IDENTIFIER
+         | TYPENAME
+       | PTYPENAME
+       | CLASSNAME
+       | OBJECTNAME
+       | reservedword
+       ;
+
+ reservedword:
+         ENUM { looking_for_typename = 0; $$ = get_identifier("enum"); }
+       | AGGR
+           {
+           looking_for_typename = 0;
+             if (yylval.ttype == class_type_node)
+               $$ = get_identifier("class");
+             else if (yylval.ttype == record_type_node)
+               $$ = get_identifier("struct");
+             else if (yylval.ttype == union_type_node)
+               $$ = get_identifier("union");
+           else if (yylval.ttype == enum_type_node)
+               $$ = get_identifier("enum");
+             else
+               abort ();
+           }
+       | IF { $$ = get_identifier("if"); }
+       | ELSE { $$ = get_identifier("else"); }
+       | WHILE { $$ = get_identifier("while"); }
+       | DO { $$ = get_identifier("do"); }
+       | FOR { $$ = get_identifier("for"); }
+       | SWITCH { $$ = get_identifier("switch"); }
+       | CASE { $$ = get_identifier("case"); }
+       | DEFAULT { $$ = get_identifier("default"); }
+       | BREAK { $$ = get_identifier("break"); }
+       | CONTINUE { $$ = get_identifier("continue"); }
+       | RETURN_KEYWORD  { $$ = get_identifier("return"); }
+       | GOTO { $$ = get_identifier("goto"); }
+       | ASM_KEYWORD { $$ = get_identifier("asm"); }
+         | SIZEOF { $$ = get_identifier("sizeof"); }
+       | TYPEOF { $$ = get_identifier("typeof"); }
+       | ALIGNOF { $$ = get_identifier("alignof"); }
+       | NEW { $$ = get_identifier("new"); }
+       | DELETE { $$ = get_identifier("delete"); }
+       | OPERATOR { $$ = get_identifier("operator"); }
+         | USING { $$ = get_identifier("using"); }
+         | NAMESPACE { $$ = get_identifier("namespace"); }
+         | TEMPLATE { $$ = get_identifier("template"); }
+       | VISSPEC {
+                   if ($1 == access_private_node)
+                     $$ = get_identifier ("private");
+                   else if ($1 == access_public_node)
+                     $$ = get_identifier ("public");
+                   else if ($1 == access_protected_node)
+                     $$ = get_identifier ("protected");
+                   else
+                     abort ();
+                 }
+         | SCSPEC   { $$ = yylval.ttype; }
+         | TYPESPEC { $$ = yylval.ttype; }
+       ;
+
+ keyworddecl:
+         selector ':' methodtype identifier
+               {
+                 $$ = build_keyword_decl ($1, $3, $4);
+               }
+
+       | selector ':' identifier
+               {
+                 $$ = build_keyword_decl ($1, NULL_TREE, $3);
+               }
+
+       | ':' methodtype identifier
+               {
+                 $$ = build_keyword_decl (NULL_TREE, $2, $3);
+               }
+
+       | ':' identifier
+               {
+                 $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
+               }
+       ;
+
+ messageargs:
+         selector
+         | keywordarglist
+       ;
+
+ keywordarglist:
+         keywordarg
+       | keywordarglist keywordarg
+               {
+                 $$ = chainon($1, $2);
+               }
+       ;
+
+
+ keywordexpr:
+         nonnull_exprlist
+               {
+                 if (TREE_CHAIN ($1) == NULL_TREE)
+                   /* just return the expr., remove a level of 
indirection */
+                   $$ = TREE_VALUE ($1);
+                   else
+                   /* we have a comma expr., we will collapse later */
+                   $$ = $1;
+               }
+       ;
+
+ keywordarg:
+         selector ':' keywordexpr
+               {
+                 $$ = build_tree_list ($1, $3);
+               }
+       | ':' keywordexpr
+               {
+                 $$ = build_tree_list (NULL_TREE, $2);
+               }
+       ;
+
+ receiver:
+         nonnull_exprlist
+               {
+                 $$ = build_x_compound_expr ($1);
+               }
+       | CLASSNAME
+               {
+                 $$ = get_class_reference ($1);
+               }
+       | complete_type_name
+               {
+                 $$ = get_class_reference ($1);
+               }
+       ;
+
+ objc_openbracket.expr:
+         '['
+               { objc_receiver_context = 1; objc_msg_context += 1; }
+         receiver
+               { objc_receiver_context = 0; $$ = $3; }
+       ;
+
+ objc_closebracket:
+         ']'
+               { objc_msg_context -= 1; }
+       ;
+
+ objcmessageexpr:
+         objc_openbracket.expr
+           messageargs
+         objc_closebracket
+               {
+                 $$ = build_tree_list($1, $2);
+                   TREE_TYPE ($$) = NULL_TREE;
+               }
+       ;
+
+ selectorarg:
+         selector
+         | keywordnamelist
+       ;
+
+ keywordnamelist:
+         keywordname
+       | keywordnamelist keywordname
+               {
+                 $$ = chainon ($1, $2);
+               }
+       ;
+
+ keywordname:
+         selector ':'
+               {
+                 $$ = build_tree_list ($1, NULL_TREE);
+               }
+       | ':'
+               {
+                 $$ = build_tree_list (NULL_TREE,NULL_TREE);
+               }
+       | SCOPE
+               {
+                 $$ = chainon (build_tree_list (NULL_TREE,NULL_TREE),
+                               build_tree_list (NULL_TREE,NULL_TREE));
+               }
+       ;
+
+ objcselectorexpr:
+         SELECTOR '(' selectorarg ')'
+               {
+                 $$ = $3;
+               }
+       ;
+
+ objcprotocolexpr:
+         PROTOCOL '(' identifier ')'
+               {
+                 $$ = $3;
+               }
+       ;
+
+ /* extension to support C-structures in the archiver */
+
+ objcencodeexpr:
+         ENCODE '(' type_id ')'
+               {
+                 $$ = groktypename($3.t);
+               }
         ;

   %%
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/pt.c 
/apple/MacOSX/compiler/gcc/obcp/pt.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/pt.c     Tue Sep  7 00:52:06 1999
--- /apple/MacOSX/compiler/gcc/obcp/pt.c        Wed Oct 24 17:59:45 2001
*************** Boston, MA 02111-1307, USA.  */
*** 42,47 ****
--- 42,51 ----
   #include "rtl.h"
   #include "varray.h"

+ #ifdef OBJCPLUS
+ #include "objc-act.h"
+ #endif
+
   /* The type of functions taking a tree, and some additional data, and
      returning an int.  */
   typedef int (*tree_fn_t) PROTO((tree, void*));
*************** tsubst_copy (t, args, complain, in_decl)
*** 6871,6876 ****
--- 6876,6895 ----
            NULL_TREE);
         }

+ #ifdef OBJCPLUS
+     case MESSAGE_SEND_EXPR:
+       return build_nt
+       (MESSAGE_SEND_EXPR,
+        tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl),
+        TREE_OPERAND (t, 1),  /* Do not mess with the selector!  */
+        tsubst_copy (TREE_OPERAND (t, 2), args, complain, in_decl));
+
+     case CLASS_REFERENCE_EXPR:
+       return build_nt
+       (CLASS_REFERENCE_EXPR,
+        tsubst_copy (TREE_OPERAND (t, 0), args, complain, in_decl));
+ #endif
+
       case BIND_EXPR:
       case COND_EXPR:
       case MODOP_EXPR:
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/search.c 
/apple/MacOSX/compiler/gcc/obcp/search.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/search.c Tue Jun 15 09:48:27 1999
--- /apple/MacOSX/compiler/gcc/obcp/search.c    Fri Jun  1 19:42:59 2001
*************** get_binfo (parent, binfo, protect)
*** 306,311 ****
--- 306,319 ----
         return error_mark_node;
       }

+ #ifdef OBJCPLUS
+   if (!rval)
+     {
+       if (objc_comptypes (parent, type, 1) == 1)
+       return parent;
+     }
+ #endif
+
     return rval;
   }

diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/spew.c 
/apple/MacOSX/compiler/gcc/obcp/spew.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/spew.c   Wed Dec 16 13:16:11 1998
--- /apple/MacOSX/compiler/gcc/obcp/spew.c      Fri Jun  1 19:43:00 2001
*************** yylex ()
*** 306,312 ****
--- 306,318 ----
         goto retry;

       case IDENTIFIER:
+ #ifdef OBJCPLUS
+       objc_need_raw_identifier = 1; /* suppress Obj-C class name 
lookup */
+ #endif
         scan_tokens (1);
+ #ifdef OBJCPLUS
+       objc_need_raw_identifier = 0;
+ #endif
         if (nth_token (1)->yychar == SCOPE)
         {
           /* Don't interfere with the setting from an 'aggr' prefix.  */
*************** debug_yychar (yy)
*** 486,489 ****
--- 492,525 ----
     return 1;
   }

+ #endif
+
+ #ifdef OBJCPLUS
+ /* Search the lookahead tokens for protocol qualifiers and change them 
into
+    ordinary identifiers.  */
+ void
+ forget_saved_protocol_qualifiers ()
+ {
+
+   int i;
+   struct token *tmp;
+
+   i = num_tokens ();
+   while (i-- > 0)
+     {
+       tmp = nth_token (i);
+       if (tmp->yychar == CV_QUALIFIER
+         && TREE_CODE (tmp->yylval.ttype) == IDENTIFIER_NODE)
+       {
+         char *name = IDENTIFIER_POINTER (tmp->yylval.ttype);
+         if (strcmp (name, "in") == 0
+             || strcmp (name, "out") == 0
+             || strcmp (name, "inout") == 0
+             || strcmp (name, "bycopy") == 0
+             || strcmp (name, "byref") == 0
+             || strcmp (name, "oneway") == 0)
+           tmp->yychar = IDENTIFIER;
+       }
+     }
+ }
   #endif
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/typeck.c 
/apple/MacOSX/compiler/gcc/obcp/typeck.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/typeck.c Mon Aug  9 01:46:20 1999
--- /apple/MacOSX/compiler/gcc/obcp/typeck.c    Fri Jun  1 19:43:01 2001
*************** comptypes (type1, type2, strict)
*** 897,902 ****
--- 892,901 ----

       case RECORD_TYPE:
       case UNION_TYPE:
+ #ifdef OBJCPLUS
+       if (maybe_objc_comptypes (t1, t2, 0) == 1)
+          return 1;
+ #endif
         if (TYPE_TEMPLATE_INFO (t1) && TYPE_TEMPLATE_INFO (t2)
           && (TYPE_TI_TEMPLATE (t1) == TYPE_TI_TEMPLATE (t2)
               || TREE_CODE (t1) == TEMPLATE_TEMPLATE_PARM))
*************** comptypes (type1, type2, strict)
*** 938,943 ****
--- 937,947 ----
       case REFERENCE_TYPE:
         t1 = TREE_TYPE (t1);
         t2 = TREE_TYPE (t2);
+ #ifdef OBJCPLUS
+       if (maybe_objc_comptypes (t1, t2, 0) == 1)
+         return 1;
+ #endif /* OBJCPLUS */
+
         /* first, check whether the referred types match with the
            required level of strictness */
         val = comptypes (t1, t2, strict);
*************** comp_target_types (ttl, ttr, nptrs)
*** 1024,1029 ****
--- 1028,1040 ----
   {
     ttl = TYPE_MAIN_VARIANT (ttl);
     ttr = TYPE_MAIN_VARIANT (ttr);
+
+ #ifdef OBJCPLUS
+  /* emits warnings as appropriate */
+   if (maybe_objc_comptypes (ttl, ttr, 1) == 1)
+     return 1;
+ #endif /* OBJCPLUS */
+
     if (same_type_p (ttl, ttr))
       return 1;

*************** build_binary_op_nodefault (code, orig_op
*** 3623,3630 ****
--- 3738,3752 ----
                 pedwarn ("ANSI C++ forbids comparison of `void *' with 
function pointer");
             }
           else
+ #ifdef OBJCPLUS
+               {
+                 if (maybe_objc_comptypes (tt0, tt1, 1) != 1)
+                   cp_pedwarn ("comparison of distinct object pointer 
types");
+               }
+ #else
             cp_pedwarn ("comparison of distinct pointer types `%T' and 
`%T' lacks a cast",
                         type0, type1);
+ #endif

           if (result_type == NULL_TREE)
             result_type = ptr_type_node;
*************** convert_for_assignment (type, rhs, errty
*** 6788,6793 ****
--- 6910,6921 ----
         return rhs;
       }

+ #ifdef OBJCPLUS
+   /* Check for Objective-C protocols.  */
+   if (maybe_objc_comptypes (type, rhstype, 0) == 1)
+     return rhs;
+ #endif /* OBJCPLUS */
+
     if (coder == VOID_TYPE)
       {
         error ("void value not ignored as it ought to be");
*************** convert_for_assignment (type, rhs, errty
*** 6855,6860 ****
--- 6983,6993 ----
         }
         ttr = TREE_TYPE (rhstype);

+ #ifdef OBJCPLUS
+       if (maybe_objc_comptypes (ttl, ttr, 0) == 1)
+         return convert (type, rhs);
+ #endif /* OBJCPLUS */
+
         /* If both pointers are of aggregate type, then we
          can give better error messages, and save some work
          as well.  */
*************** convert_for_assignment (type, rhs, errty
*** 6914,6921 ****
--- 7047,7062 ----
                 cp_pedwarn ("implicit conversion of signature pointer to 
type `%T'",
                             type);
               else
+ #ifdef OBJCPLUS
+                 {
+                 extern int doing_objc_thang;
+                 if (!doing_objc_thang)
+                 pedwarn ("ANSI C++ forbids implicit conversion from 
`void *' in %s", errtype);
+                 }
+ #else
                 pedwarn ("ANSI C++ forbids implicit conversion from 
`void *' in %s",
                          errtype);
+ #endif
             }
           /* Const and volatile mean something different for function 
types,
              so the usual warnings are not appropriate.  */
diff -r -c3p /gnu/gcc-2_95_2-release/gcc/gcc/cp/typeck2.c 
/apple/MacOSX/compiler/gcc/obcp/typeck2.c
*** /gnu/gcc-2_95_2-release/gcc/gcc/cp/typeck2.c        Sun Aug  8 
23:47:02 1999
--- /apple/MacOSX/compiler/gcc/obcp/typeck2.c   Fri Jun  1 19:43:01 2001
*************** check_for_new_type (string, inptree)
*** 1657,1660 ****
--- 1682,1693 ----
     if (inptree.new_type_flag
         && (pedantic || strcmp (string, "cast") != 0))
       pedwarn ("ANSI C++ forbids defining types within %s",string);
+
+ #ifdef OBJCPLUS
+   /* zlaski 2001-Apr-23: We cannot allocate Obj-C++ classes since we 
wouldn't
+      know how to initialize them! */
+   if(strcmp (string, "new") == 0 && inptree.t != NULL_TREE
+       && TREE_PURPOSE(inptree.t) != NULL_TREE)
+     objc_check_type (TREE_VALUE(TREE_PURPOSE(inptree.t)));
+ #endif
   }
diff -r -c3p /gnu/HEAD/gcc/gcc/objc/objc-act.c 
/darwin/HEAD/gcc3/gcc/objc/objc-act.c
*** /gnu/HEAD/gcc/gcc/objc/objc-act.c   Tue Oct 16 12:54:06 2001
--- /darwin/HEAD/gcc3/gcc/objc/objc-act.c       Tue Nov 20 12:03:18 2001
*************** Boston, MA 02111-1307, USA.  */
*** 44,51 ****
--- 44,59 ----
   #include "tree.h"
   #include "rtl.h"
   #include "expr.h"
+
+ /* APPLE LOCAL: Objective-C++ */
+ #ifdef OBJCPLUS
+ #include "cp-tree.h"
+ #include "lex.h"
+ #else
   #include "c-tree.h"
   #include "c-lex.h"
+ #endif
+
   #include "c-common.h"
   #include "flags.h"
   #include "objc-act.h"
*************** tree
*** 2186,2191 ****
--- 2294,2311 ----
   get_class_reference (ident)
       tree ident;
   {
+ /* APPLE LOCAL: Objective-C++ */
+ #ifdef OBJCPLUS
+   if (processing_template_decl)
+     /* Must wait until template instantiation time.  */
+     return build_min_nt (CLASS_REFERENCE_EXPR, ident);
+
+   /* When coming back from template expansion, ObjC++ class references
+      may be more sophisticated than just identifiers.  */
+   if (TREE_CODE (ident) == TYPE_DECL)
+     ident = DECL_NAME (ident);
+ #endif
+
     if (flag_next_runtime)
       {
         tree *chain;
*************** build_message_expr (mess)
*** 4811,4816 ****
--- 4938,4951 ----
         method_params = args;
       }

+ /* APPLE LOCAL: Objective-C++ */
+ #ifdef OBJCPLUS
+   if (processing_template_decl)
+     /* Must wait until template instantiation time.  */
+     return build_min_nt (MESSAGE_SEND_EXPR, receiver, sel_name,
+                        method_params);
+ #endif
+
     return finish_message_expr (receiver, sel_name, method_params);
   }

diff -r -c3p /gnu/HEAD/gcc/gcc/objc/objc-tree.def 
/darwin/HEAD/gcc3/gcc/objc/objc-tree.def
*** /gnu/HEAD/gcc/gcc/objc/objc-tree.def        Wed Oct  3 15:05:57 2001
--- /darwin/HEAD/gcc3/gcc/objc/objc-tree.def    Fri Oct  5 17:15:39 2001
*************** DEFTREECODE (PROTOCOL_INTERFACE_TYPE, "p
*** 33,35 ****
--- 33,40 ----
   DEFTREECODE (KEYWORD_DECL, "keyword_decl", 'd', 0)
   DEFTREECODE (INSTANCE_METHOD_DECL, "instance_method_decl", 'd', 0)
   DEFTREECODE (CLASS_METHOD_DECL, "class_method_decl", 'd', 0)
+
+ /* APPLE LOCAL: Objective-C++ */
+ /* Objective-C expressions.  */
+ DEFTREECODE (MESSAGE_SEND_EXPR, "message_send_expr", 'e', 3)
+ DEFTREECODE (CLASS_REFERENCE_EXPR, "class_reference_expr", 'e', 1)

--------------------------------------------------------------
Ziemowit Laski                   Apple Computer, Inc.
zlaski@apple.com                 2 Infinite Loop, MS 302-4SN
+1.408.974.6229  Fax .1344       Cupertino, CA  95014-2085


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]