PATCH: ObjC++-related common code mods

Ziemowit Laski zlaski@apple.com
Tue Aug 17 07:10:00 GMT 2004


Ok, so I've whittled down my patch from yesterday so that now it only 
contains the front-end-independent code, so that one of the blanket 
maintainers can review it.  OK if bootstrap succeeds?

Thanks,

--Zem

[gcc/ChangeLog]
2004-08-17  Ziemowit Laski  <zlaski@apple.com>

         * expr.c (categorize_ctor_elements_1): Check for existence of a
         designated initializer before grokking it.
         * gcc.c (default_compilers): Add info about ".mm", ".M" and 
".mii"
         Objective-C++ extensions.
         * gengtype.c (get_file_basename): Match entire subdirectory name
         ('cp', 'objc', 'objcp') rather than just its suffix.
         (get_base_file_bitmap): Allow for files to belong to more than 
one
         language.
         (get_output_file_with_visibility): Treat objc/objc-act.h as a 
header
         used by more than one front-end.

Index: gcc/expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.704
diff -u -3 -p -r1.704 expr.c
--- gcc/expr.c  15 Aug 2004 15:44:58 -0000      1.704
+++ gcc/expr.c  17 Aug 2004 06:38:16 -0000
@@ -4200,7 +4200,7 @@ categorize_ctor_elements_1 (tree ctor, H
        HOST_WIDE_INT mult;

        mult = 1;
-      if (TREE_CODE (purpose) == RANGE_EXPR)
+      if (purpose && TREE_CODE (purpose) == RANGE_EXPR)
         {
           tree lo_index = TREE_OPERAND (purpose, 0);
           tree hi_index = TREE_OPERAND (purpose, 1);
Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcc.c,v
retrieving revision 1.427
diff -u -3 -p -r1.427 gcc.c
--- gcc/gcc.c   3 Aug 2004 09:38:06 -0000       1.427
+++ gcc/gcc.c   17 Aug 2004 06:38:19 -0000
@@ -918,6 +918,8 @@ static const struct compiler default_com
       and be given a more meaningful error than "file not used since
       linking is not done".  */
    {".m",  "#Objective-C", 0, 0, 0}, {".mi",  "#Objective-C", 0, 0, 0},
+  {".mm", "#Objective-C++", 0, 0, 0}, {".M", "#Objective-C++", 0, 0, 
0},
+  {".mii", "#Objective-C++", 0, 0, 0},
    {".cc", "#C++", 0, 0, 0}, {".cxx", "#C++", 0, 0, 0},
    {".cpp", "#C++", 0, 0, 0}, {".cp", "#C++", 0, 0, 0},
    {".c++", "#C++", 0, 0, 0}, {".C", "#C++", 0, 0, 0},
Index: gcc/gengtype.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gengtype.c,v
retrieving revision 1.62
diff -u -3 -p -r1.62 gengtype.c
--- gcc/gengtype.c      4 Aug 2004 20:55:07 -0000       1.62
+++ gcc/gengtype.c      17 Aug 2004 06:38:20 -0000
@@ -1096,7 +1096,7 @@ get_file_basename (const char *f)
        s2 = lang_dir_names [i];
        l1 = strlen (s1);
        l2 = strlen (s2);
-      if (l1 >= l2 && !memcmp (s1, s2, l2))
+      if (l1 >= l2 && s1[-1] == '/' && !memcmp (s1, s2, l2))
          {
            basename -= l2 + 1;
            if ((basename - f - 1) != srcdir_len)
@@ -1125,6 +1125,10 @@ get_base_file_bitmap (const char *input_
    unsigned k;
    unsigned bitmap;

+  /* If the file resides in a language subdirectory (e.g., 'cp'), 
assume that
+     it belongs to the corresponding language.  The file may belong to 
other
+     languages as well (which is checked for below).  */
+
    if (slashpos)
      {
        size_t i;
@@ -1134,10 +1138,7 @@ get_base_file_bitmap (const char *input_
            {
              /* It's in a language directory, set that language.  */
              bitmap = 1 << i;
-            return bitmap;
            }
-
-      abort (); /* Should have found the language.  */
      }

    /* If it's in any config-lang.in, then set for the languages
@@ -1200,11 +1201,18 @@ get_output_file_with_visibility (const c
        memcpy (s, ".h", sizeof (".h"));
        for_name = basename;
      }
+  /* Some headers get used by more than one front-end; hence, it
+     would be inappropriate to spew them out to a single gtype-<lang>.h
+     (and gengtype doesn't know how to direct spewage into multiple
+     gtype-<lang>.h headers at this time).  Instead, we pair up these
+     headers with source files (and their special purpose gt-*.h 
headers).  */
    else if (strcmp (basename, "c-common.h") == 0)
      output_name = "gt-c-common.h", for_name = "c-common.c";
    else if (strcmp (basename, "c-tree.h") == 0)
      output_name = "gt-c-decl.h", for_name = "c-decl.c";
-  else
+  else if (strcmp (basename, "objc/objc-act.h") == 0)
+    output_name = "gt-objc-objc-act.h", for_name = "objc/objc-act.c";
+  else
      {
        size_t i;



More information about the Gcc-patches mailing list