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]

More sensible ObjC handling in cpplib.


When looking to remove most of the remaining alpha/ specs, most of which
are based on the choice of language, I noticed that we don't seem to be
handling ObjC intelligently as a language selector in cpplib.

IMO, "-std=c99 -lang-objc" and "-lang-objc -std=c99" should both give
the C99 standard with ObjC extensions (namely, @ strings).  However,
with the current implementation the former gives C89 ObjC, and the latter
C99 with no ObjC, because they are considered mutually exclusive, and
the latter wins.

Similarly for when ObjC++ appears, IMO ObjC-ness should be an
"additionally-ObjC" boolean flag rather than a standard in and of itself.

Zack / Stan, do you agree with this approach?

This patch does that, and removes -lang-objc++ (internal to cpplib,
and unused by the driver since we don't do objc++ yet, so should not be
an issue).  When we do obj-c++, the driver would either pass -lang-objc
and the default c++ standard to the common front-end, or if the front
ends are still separate, the cc1objplus would default things correctly
like cc1obj does now.

I also removed the -+ option, whose semantics were incredibly vague,
and have therefore changed with time.  The option was undocumented apart
from in --help, not passed on by the driver, and unused to the best of
my knowledge.

OK with you Zack and Stan?

Neil.

	* c-common.c (c_common_init_options): Use C89 for Objective-C,
	and set the options flag.
	* cppinit.c (lang_flags): Remove objc.
	(lang_defaults): Remove OBJC and OBJCXX.
	(set_lang): Update.
	(COMMAND_LINE_OPTIONS): Remove -+ and -lang-objc++.
	(cpp_handle_option): Remove -+ and -lang-objc++.
	For ObjC, just set a flag.
	(print_help): Update.
	* cpplib.h (enum c_lang): Remove CLK_OBJC and CLK_OBJCXX.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.322
diff -u -p -r1.322 c-common.c
--- c-common.c	15 May 2002 05:29:43 -0000	1.322
+++ c-common.c	15 May 2002 21:47:43 -0000
@@ -4263,8 +4263,10 @@ c_common_init_options (lang)
      enum c_language_kind lang;
 {
   c_language = lang;
-  parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89:
-				lang == clk_cplusplus ? CLK_GNUCXX: CLK_OBJC);
+  parse_in = cpp_create_reader (lang == clk_c || lang == clk_objective_c
+				? CLK_GNUC89 : CLK_GNUCXX);
+  if (lang == clk_objective_c)
+    cpp_get_options (parse_in)->objc = 1;
 
   /* Mark as "unspecified" (see c_common_post_options).  */
   flag_bounds_check = -1;
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.223
diff -u -p -r1.223 cppinit.c
--- cppinit.c	15 May 2002 05:29:44 -0000	1.223
+++ cppinit.c	15 May 2002 21:47:48 -0000
@@ -391,7 +391,6 @@ merge_include_chains (pfile)
 struct lang_flags
 {
   char c99;
-  char objc;
   char cplusplus;
   char extended_numbers;
   char trigraphs;
@@ -402,17 +401,15 @@ struct lang_flags
 
 /* ??? Enable $ in identifiers in assembly? */
 static const struct lang_flags lang_defaults[] =
-{ /*              c99 objc c++ xnum trig dollar c++comm digr  */
-  /* GNUC89 */  { 0,  0,   0,  1,   0,   1,     1,      1     },
-  /* GNUC99 */  { 1,  0,   0,  1,   0,   1,     1,      1     },
-  /* STDC89 */  { 0,  0,   0,  0,   1,   0,     0,      0     },
-  /* STDC94 */  { 0,  0,   0,  0,   1,   0,     0,      1     },
-  /* STDC99 */  { 1,  0,   0,  1,   1,   0,     1,      1     },
-  /* GNUCXX */  { 0,  0,   1,  1,   0,   1,     1,      1     },
-  /* CXX98  */  { 0,  0,   1,  1,   1,   0,     1,      1     },
-  /* OBJC   */  { 0,  1,   0,  1,   0,   1,     1,      1     },
-  /* OBJCXX */  { 0,  1,   1,  1,   0,   1,     1,      1     },
-  /* ASM    */  { 0,  0,   0,  1,   0,   0,     1,      0     }
+{ /*              c99 c++ xnum trig dollar c++comm digr  */
+  /* GNUC89 */  { 0,  0,  1,   0,   1,     1,      1     },
+  /* GNUC99 */  { 1,  0,  1,   0,   1,     1,      1     },
+  /* STDC89 */  { 0,  0,  0,   1,   0,     0,      0     },
+  /* STDC94 */  { 0,  0,  0,   1,   0,     0,      1     },
+  /* STDC99 */  { 1,  0,  1,   1,   0,     1,      1     },
+  /* GNUCXX */  { 0,  1,  1,   0,   1,     1,      1     },
+  /* CXX98  */  { 0,  1,  1,   1,   0,     1,      1     },
+  /* ASM    */  { 0,  0,  1,   0,   0,     1,      0     }
 };
 
 /* Sets internal flags correctly for a given language.  */
@@ -426,7 +423,6 @@ set_lang (pfile, lang)
   CPP_OPTION (pfile, lang) = lang;
 
   CPP_OPTION (pfile, c99)		 = l->c99;
-  CPP_OPTION (pfile, objc)		 = l->objc;
   CPP_OPTION (pfile, cplusplus)		 = l->cplusplus;
   CPP_OPTION (pfile, extended_numbers)	 = l->extended_numbers;
   CPP_OPTION (pfile, trigraphs)		 = l->trigraphs;
@@ -1186,7 +1182,6 @@ new_pending_directive (pend, text, handl
    "-" removed.  It must be sorted in ASCII collating order.  */
 #define COMMAND_LINE_OPTIONS                                                  \
   DEF_OPT("$",                        0,      OPT_dollar)                     \
-  DEF_OPT("+",                        0,      OPT_plus)                       \
   DEF_OPT("-help",                    0,      OPT__help)                      \
   DEF_OPT("-target-help",             0,      OPT_target__help)               \
   DEF_OPT("-version",                 0,      OPT__version)                   \
@@ -1232,7 +1227,6 @@ new_pending_directive (pend, text, handl
   DEF_OPT("lang-c++",                 0,      OPT_lang_cplusplus)             \
   DEF_OPT("lang-c89",                 0,      OPT_lang_c89)                   \
   DEF_OPT("lang-objc",                0,      OPT_lang_objc)                  \
-  DEF_OPT("lang-objc++",              0,      OPT_lang_objcplusplus)          \
   DEF_OPT("nostdinc",                 0,      OPT_nostdinc)                   \
   DEF_OPT("nostdinc++",               0,      OPT_nostdincplusplus)           \
   DEF_OPT("o",                        no_fil, OPT_o)                          \
@@ -1502,10 +1496,6 @@ cpp_handle_option (pfile, argc, argv, ig
 	case OPT_trigraphs:
  	  CPP_OPTION (pfile, trigraphs) = 1;
 	  break;
-	case OPT_plus:
-	  CPP_OPTION (pfile, cplusplus) = 1;
-	  CPP_OPTION (pfile, cplusplus_comments) = 1;
-	  break;
 	case OPT_remap:
 	  CPP_OPTION (pfile, remap) = 1;
 	  break;
@@ -1520,10 +1510,7 @@ cpp_handle_option (pfile, argc, argv, ig
 	  set_lang (pfile, CLK_GNUCXX);
 	  break;
 	case OPT_lang_objc:
-	  set_lang (pfile, CLK_OBJC);
-	  break;
-	case OPT_lang_objcplusplus:
-	  set_lang (pfile, CLK_OBJCXX);
+	  CPP_OPTION (pfile, objc) = 1;
 	  break;
 	case OPT_lang_asm:
 	  set_lang (pfile, CLK_ASM);
@@ -1968,14 +1955,12 @@ Switches:\n\
   fputs (_("\
   -lang-c++                 Assume that the input sources are in C++\n\
   -lang-objc                Assume that the input sources are in ObjectiveC\n\
-  -lang-objc++              Assume that the input sources are in ObjectiveC++\n\
   -lang-asm                 Assume that the input sources are in assembler\n\
 "), stdout);
   fputs (_("\
   -std=<std name>           Specify the conformance standard; one of:\n\
                             gnu89, gnu99, c89, c99, iso9899:1990,\n\
                             iso9899:199409, iso9899:1999\n\
-  -+                        Allow parsing of C++ style features\n\
   -w                        Inhibit warning messages\n\
   -Wtrigraphs               Warn if trigraphs are encountered\n\
   -Wno-trigraphs            Do not warn about trigraphs\n\
Index: cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.216
diff -u -p -r1.216 cpplib.h
--- cpplib.h	7 May 2002 21:07:15 -0000	1.216
+++ cpplib.h	15 May 2002 21:47:49 -0000
@@ -153,7 +153,7 @@ enum cpp_ttype
 
 /* C language kind, used when calling cpp_reader_init.  */
 enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_STDC89, CLK_STDC94, CLK_STDC99,
-	     CLK_GNUCXX, CLK_CXX98, CLK_OBJC, CLK_OBJCXX, CLK_ASM};
+	     CLK_GNUCXX, CLK_CXX98, CLK_ASM};
 
 /* Payload of a NUMBER, STRING, CHAR or COMMENT token.  */
 struct cpp_string
@@ -263,7 +263,8 @@ struct cpp_options
   /* Nonzero means handle cplusplus style comments */
   unsigned char cplusplus_comments;
 
-  /* Nonzero means handle #import, for objective C.  */
+  /* Nonzero means define __OBJC__, treat @ as a special token, and
+     use the OBJC[PLUS]_INCLUDE_PATH environment variable.  */
   unsigned char objc;
 
   /* Nonzero means don't copy comments into the output file.  */


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