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]

Re: [RFA]: Clean up C front ends init_options langhook


Zack Weinberg wrote:-

> ... but this can be dealt with by use of bit sets:
> 
> enum c_language_kind {
>   clk_c          = 0,
>   clk_cplusplus  = 1,
>   clk_objc       = 2,
>   clk_objcplus   = 3
> };
> 
> extern enum c_language_kind c_dialect;
> 
> #define c_dialect_objc()       (c_dialect & clk_objc)
> #define c_dialect_cplusplus()  (c_dialect & clk_cplusplus)

How's this?  Bootstrapped and regtested on x86 NetBSD.

Neil.

	* c-common.c (enum c_language_kind, flag_objc): Remove.
	(fix_string_type, check_case_value, c_common_nodes_and_builtins,
	c_add_case_label, finish_label_addr_expr, boolean_increment):
	Use c_dialect_ macros.
	* c-common.h (enum c_language_kind): Extend.
	(c_dialect_c, c_dialect_cxx, c_dialect_objc): New.
	(flag_objc): Remove.
	(c_common_init_options): Update prototype.
	* c-cppbuiltin.c (define__GNUC__, c_cpp_builtins): Use c_dialect_
	macros.
	* c-decl.c (finsih_decl, grokfield, finish_struct): Use c_dialect_
	macros.
	* c-format.c (C_STD_VER, C_STD_NAME): Similarly.
	* c-lang.c (c_init_options): Remove.
	(c_language): Define.
	(LANG_HOOKS_INIT_OPTIONS): Use common hook.
	* c-lex.c (lex_charconst): Use c_dialect_c().
	* c-opts.c (lang_flags): Make function-local.
	(c_common_init_options): Use c_dialect_ macros.  Handle
	C++ diagnostic requirements.
	(c_common_handle_option, c_common_post_options): Use flag_cxx.
	* c-parse.in (init_reswords): Use c_dialect_objc ().
	* c-pch.c (get_ident): Use c_language.
	* c-pretty-print.c (pp_c_bool_literal): Use c_dialect_ macros.
	* c-typeck.c (comptypes, build_c_cast): Similarly.
	* objc/objc-lang.c (c_language): Define.
	(LANG_HOOKS_INIT_OPTIONS): Use common hook.
	(objc_init_options): Remove.
cp:
	* Make-lang.in: Update.
	* cp-lang.c (c_language): Define.
	(LANG_HOOKS_INIT_OPTIONS): Use common hook.
	* cp-tree.h (cxx_init_options): Remove.
	* lex.c: Don't include diagnostic.h.
	(cxx_init_options): Remove.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.423
diff -u -p -r1.423 c-common.c
--- c-common.c	25 Jun 2003 22:14:26 -0000	1.423
+++ c-common.c	29 Jun 2003 12:45:16 -0000
@@ -87,10 +87,6 @@ cpp_reader *parse_in;		/* Declared in c-
 			: "long long unsigned int"))
 #endif
 
-/* The variant of the C language being processed.  */
-
-enum c_language_kind c_language;
-
 /* The following symbols are subsumed in the c_global_trees array, and
    listed here individually for documentation purposes.
 
@@ -228,9 +224,6 @@ const char *pch_file;
    user's namespace.  */
 int flag_iso;
 
-/* Nonzero whenever Objective-C functionality is being used.  */
-int flag_objc;
-
 /* Nonzero if -undef was given.  It suppresses target built-in macros
    and assertions.  */
 int flag_undef;
@@ -1166,7 +1159,7 @@ fix_string_type (tree value)
   /* Compute the number of elements, for the array type.  */
   nchars = wide_flag ? length / wchar_bytes : length;
 
-  if (pedantic && nchars - 1 > nchars_max && c_language == clk_c)
+  if (pedantic && nchars - 1 > nchars_max && c_dialect_c ())
     pedwarn ("string length `%d' is greater than the length `%d' ISO C%d compilers are required to support",
 	     nchars - 1, nchars_max, flag_isoc99 ? 99 : 89);
 
@@ -1868,7 +1861,7 @@ check_case_value (tree value)
        switch (...) { case i: ... }
 
      So, we try to reduce the VALUE to a constant that way.  */
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     {
       value = decl_constant_value (value);
       STRIP_TYPE_NOPS (value);
@@ -3155,25 +3148,25 @@ c_common_nodes_and_builtins (void)
   /* `signed' is the same as `int'.  FIXME: the declarations of "signed",
      "unsigned long", "long long unsigned" and "unsigned short" were in C++
      but not C.  Are the conditionals here needed?  */
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     record_builtin_type (RID_SIGNED, NULL, integer_type_node);
   record_builtin_type (RID_LONG, "long int", long_integer_type_node);
   record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node);
   record_builtin_type (RID_MAX, "long unsigned int",
 		       long_unsigned_type_node);
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node);
   record_builtin_type (RID_MAX, "long long int",
 		       long_long_integer_type_node);
   record_builtin_type (RID_MAX, "long long unsigned int",
 		       long_long_unsigned_type_node);
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     record_builtin_type (RID_MAX, "long long unsigned",
 			 long_long_unsigned_type_node);
   record_builtin_type (RID_SHORT, "short int", short_integer_type_node);
   record_builtin_type (RID_MAX, "short unsigned int",
 		       short_unsigned_type_node);
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     record_builtin_type (RID_MAX, "unsigned short",
 			 short_unsigned_type_node);
 
@@ -3334,7 +3327,7 @@ c_common_nodes_and_builtins (void)
   wchar_type_node = get_identifier (MODIFIED_WCHAR_TYPE);
   wchar_type_node = TREE_TYPE (identifier_global_value (wchar_type_node));
   wchar_type_size = TYPE_PRECISION (wchar_type_node);
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     {
       if (TREE_UNSIGNED (wchar_type_node))
 	wchar_type_node = make_unsigned_type (wchar_type_size);
@@ -3954,12 +3947,7 @@ c_add_case_label (splay_tree cases, tree
 
   /* Case ranges are a GNU extension.  */
   if (high_value && pedantic)
-    {
-      if (c_language == clk_cplusplus)
-	pedwarn ("ISO C++ forbids range expressions in switch statements");
-      else
-	pedwarn ("ISO C forbids range expressions in switch statements");
-    }
+    pedwarn ("range expressions in switch statements are non-standard");
 
   type = TREE_TYPE (cond);
   if (low_value)
@@ -4076,12 +4064,7 @@ finish_label_address_expr (tree label)
   tree result;
 
   if (pedantic)
-    {
-      if (c_language == clk_cplusplus)
-	pedwarn ("ISO C++ forbids taking the address of a label");
-      else
-	pedwarn ("ISO C forbids taking the address of a label");
-    }
+    pedwarn ("taking the address of a label is non-standard");
 
   if (label == error_mark_node)
     return error_mark_node;
@@ -4550,9 +4533,8 @@ tree
 boolean_increment (enum tree_code code, tree arg)
 {
   tree val;
-  tree true_res = (c_language == clk_cplusplus
-		   ? boolean_true_node
-		   : c_bool_true_node);
+  tree true_res = (c_dialect_cxx () ? boolean_true_node : c_bool_true_node);
+
   arg = stabilize_reference (arg);
   switch (code)
     {
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.184
diff -u -p -r1.184 c-common.h
--- c-common.h	23 Jun 2003 15:27:34 -0000	1.184
+++ c-common.h	29 Jun 2003 12:45:16 -0000
@@ -233,11 +233,21 @@ extern GTY(()) tree c_global_trees[CTI_M
 
 typedef enum c_language_kind
 {
-  clk_c = 0,      /* A dialect of C: K&R C, ANSI/ISO C89, C2000, etc.  */
-  clk_cplusplus   /* ANSI/ISO C++ */
+  clk_c		= 0,		/* C90, C94 or C99 */
+  clk_objc	= 1,		/* clk_c with ObjC features.  */
+  clk_cxx	= 2,		/* ANSI/ISO C++ */
+  clk_ojbcxx	= 3		/* clk_cxx with ObjC features.  */
 }
 c_language_kind;
 
+/* To test for a specific language use c_language, defined by each
+   front end.  For "ObjC features" or "not C++" use the macros.  */
+extern c_language_kind c_language;
+
+#define c_dialect_c()		(!c_dialect_cxx ())
+#define c_dialect_cxx()		(c_language & clk_cxx)
+#define c_dialect_objc()	(c_language & clk_objc)
+
 /* Information about a statement tree.  */
 
 struct stmt_tree_s GTY(()) {
@@ -351,11 +361,6 @@ struct c_lang_decl GTY(()) {
 #define DECL_NUM_STMTS(NODE) \
   (FUNCTION_DECL_CHECK (NODE)->decl.u1.i)
 
-/* The variant of the C language being processed.  Each C language
-   front-end defines this variable.  */
-
-extern c_language_kind c_language;
-
 /* Nonzero if we can read a PCH file now.  */
 
 extern int allow_pch;
@@ -394,9 +399,6 @@ extern const char *pch_file;
 
 extern int flag_iso;
 
-/* Nonzero whenever Objective-C functionality is being used.  */
-extern int flag_objc;
-
 /* Nonzero if -undef was given.  It suppresses target built-in macros
    and assertions.  */
 
@@ -952,7 +954,7 @@ extern void disable_builtin_function (co
 
 extern tree build_va_arg (tree, tree);
 
-extern int c_common_init_options (enum c_language_kind);
+extern int c_common_init_options (void);
 extern bool c_common_post_options (const char **);
 extern bool c_common_init (void);
 extern void c_common_finish (void);
Index: c-cppbuiltin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-cppbuiltin.c,v
retrieving revision 1.12
diff -u -p -r1.12 c-cppbuiltin.c
--- c-cppbuiltin.c	19 Jun 2003 19:43:58 -0000	1.12
+++ c-cppbuiltin.c	29 Jun 2003 12:45:16 -0000
@@ -255,7 +255,7 @@ define__GNUC__ (void)
   while (ISDIGIT (*v))
     v++;
   builtin_define_with_value_n ("__GNUC__", q, v - q);
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     builtin_define_with_value_n ("__GNUG__", q, v - q);
 
   if (*v != '.' || !ISDIGIT (v[1]))
@@ -294,7 +294,7 @@ c_cpp_builtins (cpp_reader *pfile)
   /* For stddef.h.  They require macros defined in c-common.c.  */
   c_stddef_cpp_builtins ();
 
-  if (c_language == clk_cplusplus)
+  if (c_dialect_cxx ())
     {
       if (SUPPORTS_ONE_ONLY)
 	cpp_define (pfile, "__GXX_WEAK__=1");
@@ -375,11 +375,11 @@ c_cpp_builtins (cpp_reader *pfile)
   if (!flag_signed_char)
     cpp_define (pfile, "__CHAR_UNSIGNED__");
 
-  if (c_language == clk_cplusplus && TREE_UNSIGNED (wchar_type_node))
+  if (c_dialect_cxx () && TREE_UNSIGNED (wchar_type_node))
     cpp_define (pfile, "__WCHAR_UNSIGNED__");
 
   /* Make the choice of ObjC runtime visible to source code.  */
-  if (flag_objc && flag_next_runtime)
+  if (c_dialect_objc () && flag_next_runtime)
     cpp_define (pfile, "__NEXT_RUNTIME__");
 
   /* A straightforward target hook doesn't work, because of problems
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.398
diff -u -p -r1.398 c-decl.c
--- c-decl.c	27 Jun 2003 09:05:44 -0000	1.398
+++ c-decl.c	29 Jun 2003 12:45:18 -0000
@@ -2863,7 +2863,7 @@ finish_decl (tree decl, tree init, tree 
   if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
     {
       /* This is a no-op in c-lang.c or something real in objc-act.c.  */
-      if (flag_objc)
+      if (c_dialect_objc ())
 	objc_check_decl (decl);
 
       if (!DECL_CONTEXT (decl))
@@ -2927,7 +2927,7 @@ finish_decl (tree decl, tree init, tree 
   if (TREE_CODE (decl) == TYPE_DECL)
     {
       /* This is a no-op in c-lang.c or something real in objc-act.c.  */
-      if (flag_objc)
+      if (c_dialect_objc ())
 	objc_check_decl (decl);
       rest_of_decl_compilation (decl, NULL, DECL_CONTEXT (decl) == 0, 0);
     }
@@ -4864,7 +4864,7 @@ grokfield (tree declarator, tree declspe
   finish_decl (value, NULL_TREE, NULL_TREE);
   DECL_INITIAL (value) = width;
 
-  if (flag_objc)
+  if (c_dialect_objc ())
     objc_check_decl (value);
   return value;
 }
@@ -5160,7 +5160,7 @@ finish_struct (tree t, tree fieldlist, t
 	    {
 	      layout_decl (decl, 0);
 	      /* This is a no-op in c-lang.c or something real in objc-act.c.  */
-	      if (flag_objc)
+	      if (c_dialect_objc ())
 		objc_check_decl (decl);
 	      rest_of_decl_compilation (decl, NULL, toplevel, 0);
 	      if (! toplevel)
@@ -5183,7 +5183,7 @@ finish_struct (tree t, tree fieldlist, t
 		  if (TREE_CODE (decl) != TYPE_DECL)
 		    {
 		      layout_decl (decl, 0);
-		      if (flag_objc)
+		      if (c_dialect_objc ())
 			objc_check_decl (decl);
 		      rest_of_decl_compilation (decl, NULL, toplevel, 0);
 		      if (! toplevel)
Index: c-format.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-format.c,v
retrieving revision 1.43
diff -u -p -r1.43 c-format.c
--- c-format.c	28 Jun 2003 16:23:17 -0000	1.43
+++ c-format.c	29 Jun 2003 12:45:19 -0000
@@ -259,7 +259,7 @@ enum format_std_version
    or inheriting from, for the purpose of format features supported.  */
 #define CPLUSPLUS_STD_VER	STD_C94
 /* The C standard version we are checking formats against when pedantic.  */
-#define C_STD_VER		((int)(c_language == clk_cplusplus	  \
+#define C_STD_VER		((int)(c_dialect_cxx ()			  \
 				 ? CPLUSPLUS_STD_VER			  \
 				 : (flag_isoc99				  \
 				    ? STD_C99				  \
@@ -267,7 +267,7 @@ enum format_std_version
 /* The name to give to the standard version we are warning about when
    pedantic.  FEATURE_VER is the version in which the feature warned out
    appeared, which is higher than C_STD_VER.  */
-#define C_STD_NAME(FEATURE_VER) (c_language == clk_cplusplus	\
+#define C_STD_NAME(FEATURE_VER) (c_dialect_cxx ()		\
 				 ? "ISO C++"			\
 				 : ((FEATURE_VER) == STD_EXT	\
 				    ? "ISO C"			\
Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v
retrieving revision 1.105
diff -u -p -r1.105 c-lang.c
--- c-lang.c	25 Jun 2003 17:29:12 -0000	1.105
+++ c-lang.c	29 Jun 2003 12:45:19 -0000
@@ -31,7 +31,7 @@ Software Foundation, 59 Temple Place - S
 #include "langhooks.h"
 #include "langhooks-def.h"
 
-static int c_init_options (void);
+enum c_language_kind c_language = clk_c;
 
 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
 
@@ -42,7 +42,7 @@ static int c_init_options (void);
 #undef LANG_HOOKS_FINISH
 #define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
-#define LANG_HOOKS_INIT_OPTIONS c_init_options
+#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_POST_OPTIONS
@@ -158,12 +158,6 @@ const char *const tree_code_name[] = {
 #include "c-common.def"
 };
 #undef DEFTREECODE
-
-static int
-c_init_options (void)
-{
-  return c_common_init_options (clk_c);
-}
 
 /* Used by c-lex.c, but only for objc.  */
 
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.205
diff -u -p -r1.205 c-lex.c
--- c-lex.c	22 Jun 2003 13:41:24 -0000	1.205
+++ c-lex.c	29 Jun 2003 12:45:19 -0000
@@ -665,7 +665,7 @@ lex_charconst (const cpp_token *token)
     type = wchar_type_node;
   /* In C, a character constant has type 'int'.
      In C++ 'char', but multi-char charconsts have type 'int'.  */
-  else if ((c_language == clk_c) || chars_seen > 1)
+  else if (c_dialect_c () || chars_seen > 1)
     type = integer_type_node;
   else
     type = char_type_node;
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.64
diff -u -p -r1.64 c-opts.c
--- c-opts.c	26 Jun 2003 06:05:28 -0000	1.64
+++ c-opts.c	29 Jun 2003 12:45:19 -0000
@@ -50,8 +50,6 @@ Software Foundation, 59 Temple Place - S
 # define TARGET_EBCDIC 0
 #endif
 
-static const int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
-
 static int saved_lineno;
 
 /* CPP's options.  */
@@ -213,25 +211,38 @@ defer_opt (enum opt_code code, const cha
 
 /* Common initialization before parsing options.  */
 int
-c_common_init_options (enum c_language_kind lang)
+c_common_init_options (void)
 {
-  c_language = lang;
-  parse_in = cpp_create_reader (lang == clk_c ? CLK_GNUC89 : CLK_GNUCXX,
+  static const int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
+
+  /* This is conditionalized only because that is the way the front
+     ends used to do it.  Maybe this should be unconditional?  */
+  if (c_dialect_cxx ())
+    {
+      /* By default wrap lines at 80 characters.  Is getenv
+	 ("COLUMNS") preferable?  */
+      diagnostic_line_cutoff (global_dc) = 80;
+      /* By default, emit location information once for every
+	 diagnostic message.  */
+      diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
+    }
+
+  parse_in = cpp_create_reader (c_dialect_c () ? CLK_GNUC89 : CLK_GNUCXX,
 				ident_hash);
+
   cpp_opts = cpp_get_options (parse_in);
   cpp_opts->dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
+  cpp_opts->objc = c_dialect_objc ();
 
   /* Reset to avoid warnings on internal definitions.  We set it just
      before passing on command-line options to cpplib.  */
   cpp_opts->warn_dollars = 0;
 
-  if (flag_objc)
-    cpp_opts->objc = 1;
-
-  flag_const_strings = (lang == clk_cplusplus);
-  warn_pointer_arith = (lang == clk_cplusplus);
+  flag_const_strings = c_dialect_cxx ();
+  flag_exceptions = c_dialect_cxx ();
+  warn_pointer_arith = c_dialect_cxx ();
 
-  return lang_flags[(c_language << 1) + flag_objc];
+  return lang_flags[c_language];
 }
 
 /* Handle switch SCODE with argument ARG.  ON is true, unless no-
@@ -366,7 +377,7 @@ c_common_handle_option (size_t scode, co
       warn_parentheses = value;
       warn_return_type = value;
       warn_sequence_point = value;	/* Was C only.  */
-      if (c_language == clk_cplusplus)
+      if (c_dialect_cxx ())
 	warn_sign_compare = value;
       warn_switch = value;
       warn_strict_aliasing = value;
@@ -381,7 +392,7 @@ c_common_handle_option (size_t scode, co
       if (warn_uninitialized != 1)
 	warn_uninitialized = (value ? 2 : 0);
 
-      if (c_language == clk_c)
+      if (c_dialect_c ())
 	/* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
 	   can turn it off only if it's not explicit.  */
 	warn_main = value * 2;
@@ -644,14 +655,14 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_Wwrite_strings:
-      if (c_language == clk_c)
+      if (c_dialect_c ())
 	flag_const_strings = value;
       else
 	warn_write_strings = value;
       break;
 
     case OPT_ansi:
-      if (c_language == clk_c)
+      if (c_dialect_c ())
 	set_std_c89 (false, true);
       else
 	set_std_cxx98 (true);
@@ -662,7 +673,7 @@ c_common_handle_option (size_t scode, co
       break;
 
     case OPT_fcond_mismatch:
-      if (c_language == clk_c)
+      if (c_dialect_c ())
 	{
 	  flag_cond_mismatch = value;
 	  break;
@@ -1053,8 +1064,7 @@ c_common_post_options (const char **pfil
   sanitize_cpp_opts ();
 
   register_include_chains (parse_in, sysroot, iprefix,
-			   std_inc, std_cxx_inc && c_language == clk_cplusplus,
-			   verbose);
+			   std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
 
   flag_inline_trees = 1;
 
Index: c-parse.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.164
diff -u -p -r1.164 c-parse.in
--- c-parse.in	28 Jun 2003 19:05:32 -0000	1.164
+++ c-parse.in	29 Jun 2003 12:45:20 -0000
@@ -3551,7 +3551,7 @@ init_reswords ()
   int mask = (flag_isoc99 ? 0 : D_C89)
 	      | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
 
-  if (!flag_objc)
+  if (!c_dialect_objc ())
      mask |= D_OBJC;
 
   ridpointers = (tree *) ggc_calloc ((int) RID_MAX, sizeof (tree));
Index: c-pch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pch.c,v
retrieving revision 1.11
diff -u -p -r1.11 c-pch.c
--- c-pch.c	22 Jun 2003 13:41:24 -0000	1.11
+++ c-pch.c	29 Jun 2003 12:45:20 -0000
@@ -60,14 +60,11 @@ get_ident(void)
 {
   static char result[IDENT_LENGTH];
   static const char template[IDENT_LENGTH] = "gpch.011";
+  static const char c_language_chars[] = "Co+O";
   
   memcpy (result, template, IDENT_LENGTH);
-  if (c_language == clk_c)
-    result[4] = flag_objc ? 'o' : 'C';
-  else if (c_language == clk_cplusplus)
-    result[4] = flag_objc ? 'O' : '+';
-  else
-    abort ();
+  result[4] = c_language_chars[c_language];
+
   return result;
 }
 
Index: c-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-pretty-print.c,v
retrieving revision 1.16
diff -u -p -r1.16 c-pretty-print.c
--- c-pretty-print.c	22 Jun 2003 13:41:24 -0000	1.16
+++ c-pretty-print.c	29 Jun 2003 12:45:20 -0000
@@ -336,18 +336,18 @@ pp_c_bool_literal (c_pretty_printer ppi,
 {
   if (b == boolean_false_node || integer_zerop (b))
     {
-      if (c_language == clk_cplusplus)
+      if (c_dialect_cxx ())
 	pp_c_identifier (ppi, "false");
-      else if (c_language == clk_c && flag_isoc99)
+      else if (c_dialect_c () && flag_isoc99)
 	pp_c_identifier (ppi, "_False");
       else
 	pp_unsupported_tree (ppi, b);
     }
   else if (b == boolean_true_node)
     {
-      if (c_language == clk_cplusplus)
+      if (c_dialect_cxx ())
 	pp_c_identifier (ppi, "true");
-      else if (c_language == clk_c && flag_isoc99)
+      else if (c_dialect_c () && flag_isoc99)
 	pp_c_identifier (ppi, "_True");
       else
 	pp_unsupported_tree (ppi, b);
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-typeck.c,v
retrieving revision 1.240
diff -u -p -r1.240 c-typeck.c
--- c-typeck.c	22 Jun 2003 13:41:25 -0000	1.240
+++ c-typeck.c	29 Jun 2003 12:45:22 -0000
@@ -560,7 +560,7 @@ comptypes (tree type1, tree type2)
       }
 
     case RECORD_TYPE:
-      if (flag_objc && objc_comptypes (t1, t2, 0) == 1)
+      if (c_dialect_objc () && objc_comptypes (t1, t2, 0) == 1)
 	val = 1;
       break;
 
@@ -3492,7 +3492,7 @@ build_c_cast (tree type, tree expr)
   /* The ObjC front-end uses TYPE_MAIN_VARIANT to tie together types differing
      only in <protocol> qualifications.  But when constructing cast expressions,
      the protocols do matter and must be kept around.  */
-  if (!flag_objc || !objc_is_id (type))
+  if (!c_dialect_objc () || !objc_is_id (type))
     type = TYPE_MAIN_VARIANT (type);
 
   if (TREE_CODE (type) == ARRAY_TYPE)
@@ -3902,7 +3902,7 @@ convert_for_assignment (tree type, tree 
       /* Check for Objective-C protocols.  This will automatically
 	 issue a warning if there are protocol violations.  No need to
 	 use the return value.  */
-      if (flag_objc)
+      if (c_dialect_objc ())
 	objc_comptypes (type, rhstype, 0);
       return rhs;
     }
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.154
diff -u -p -r1.154 Make-lang.in
--- cp/Make-lang.in	23 Jun 2003 20:52:12 -0000	1.154
+++ cp/Make-lang.in	29 Jun 2003 12:45:23 -0000
@@ -232,8 +232,7 @@ CXX_TREE_H = $(TREE_H) cp/name-lookup.h 
 	$(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
 
 cp/lex.o: cp/lex.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h \
-  c-pragma.h toplev.h output.h input.h diagnostic.h \
-  cp/operators.def $(TM_P_H)
+  c-pragma.h toplev.h output.h input.h cp/operators.def $(TM_P_H)
 cp/cp-lang.o: cp/cp-lang.c $(CXX_TREE_H) $(TM_H) toplev.h langhooks.h \
   $(LANGHOOKS_DEF_H) c-common.h
 cp/decl.o: cp/decl.c $(CXX_TREE_H) $(TM_H) flags.h cp/lex.h cp/decl.h stack.h \
Index: cp/cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.51
diff -u -p -r1.51 cp-lang.c
--- cp/cp-lang.c	24 Jun 2003 11:54:00 -0000	1.51
+++ cp/cp-lang.c	29 Jun 2003 12:45:23 -0000
@@ -30,6 +30,8 @@ Boston, MA 02111-1307, USA.  */
 #include "langhooks.h"
 #include "langhooks-def.h"
 
+enum c_language_kind c_language = clk_cxx;
+
 static HOST_WIDE_INT cxx_get_alias_set (tree);
 static bool ok_to_generate_alias_set_for_type (tree);
 static bool cxx_warn_unused_global_decl (tree);
@@ -48,7 +50,7 @@ static bool cp_var_mod_type_p (tree);
 #undef LANG_HOOKS_CLEAR_BINDING_STACK
 #define LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
 #undef LANG_HOOKS_INIT_OPTIONS
-#define LANG_HOOKS_INIT_OPTIONS cxx_init_options
+#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_POST_OPTIONS
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.861
diff -u -p -r1.861 cp-tree.h
--- cp/cp-tree.h	28 Jun 2003 16:23:25 -0000	1.861
+++ cp/cp-tree.h	29 Jun 2003 12:45:24 -0000
@@ -3905,7 +3905,6 @@ extern void yyhook				(int);
 extern int cp_type_qual_from_rid                (tree);
 extern bool cxx_init				(void);
 extern void cxx_finish (void);
-extern int cxx_init_options (void);
 
 /* in method.c */
 extern void init_method	(void);
Index: cp/lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/lex.c,v
retrieving revision 1.307
diff -u -p -r1.307 lex.c
--- cp/lex.c	24 Jun 2003 15:40:03 -0000	1.307
+++ cp/lex.c	29 Jun 2003 12:45:25 -0000
@@ -38,7 +38,6 @@ Boston, MA 02111-1307, USA.  */
 #include "output.h"
 #include "tm_p.h"
 #include "timevar.h"
-#include "diagnostic.h"
 
 static int interface_strcmp (const char *);
 static void init_cp_pragma (void);
@@ -147,22 +146,6 @@ int interface_unknown;		/* whether or no
 				   to behave according to #pragma interface.  */
 
 
-/* Initialization before switch parsing.  */
-int
-cxx_init_options (void)
-{
-  /* Default exceptions on.  */
-  flag_exceptions = 1;
-  /* By default wrap lines at 80 characters.  Is getenv ("COLUMNS")
-     preferable?  */
-  diagnostic_line_cutoff (global_dc) = 80;
-  /* By default, emit location information once for every
-     diagnostic message.  */
-  diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
-
-  return c_common_init_options (clk_cplusplus);
-}
-
 void
 cxx_finish (void)
 {
Index: objc/objc-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-lang.c,v
retrieving revision 1.31
diff -u -p -r1.31 objc-lang.c
--- objc/objc-lang.c	25 Jun 2003 17:29:14 -0000	1.31
+++ objc/objc-lang.c	29 Jun 2003 12:45:25 -0000
@@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA.  */
 #include "langhooks.h"
 #include "langhooks-def.h"
 
-static int objc_init_options                   PARAMS ((void));
+enum c_language_kind c_language = clk_objc;
 
 #undef LANG_HOOKS_NAME
 #define LANG_HOOKS_NAME "GNU Objective-C"
@@ -40,7 +40,7 @@ static int objc_init_options            
 #undef LANG_HOOKS_FINISH
 #define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
-#define LANG_HOOKS_INIT_OPTIONS objc_init_options
+#define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
 #define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_POST_OPTIONS
@@ -165,10 +165,3 @@ const char * const tree_code_name[] = {
 #include "objc-tree.def"
 };
 #undef DEFTREECODE
-
-static int 
-objc_init_options ()
-{
-  flag_objc = 1;
-  return c_common_init_options (clk_c);
-}


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