]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-common.c (enum c_language_kind, flag_objc): Remove.
authorNeil Booth <neil@daikokuya.co.uk>
Mon, 30 Jun 2003 19:36:25 +0000 (19:36 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Mon, 30 Jun 2003 19:36:25 +0000 (19:36 +0000)
* 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_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_cxx().
* 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.

From-SVN: r68734

19 files changed:
gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-cppbuiltin.c
gcc/c-decl.c
gcc/c-format.c
gcc/c-lang.c
gcc/c-lex.c
gcc/c-opts.c
gcc/c-parse.in
gcc/c-pch.c
gcc/c-pretty-print.c
gcc/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/Make-lang.in
gcc/cp/cp-lang.c
gcc/cp/cp-tree.h
gcc/cp/lex.c
gcc/objc/objc-lang.c

index 7f7da350399193bc6ca15251170bb7f088743c7d..b94a8713fe1174507fe9f68e34d31894956c1a54 100644 (file)
@@ -1,3 +1,34 @@
+2003-06-30  Neil Booth  <neil@daikokuya.co.uk>
+
+       * 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_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_ macros.
+       * 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.
+
 2003-06-30  Kazu Hirata  <kazu@cs.umass.edu>
 
        * config/alpha/alpha.h (FUNCTION_ARG_PADDING): Remove.
index 43f9586d415782f799b8da7fcd4011c9d91c1c74..9e037658507a50c48c8b74c208260daa451d7f01 100644 (file)
@@ -87,10 +87,6 @@ cpp_reader *parse_in;                /* Declared in c-pragma.h.  */
                        : "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_cxx ())
     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 cond, tree low_value,
 
   /* 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 d97f460712db200d8bd4ca490a44dac5b2529bbd..0843e11e85830b2435531c6eac2eeabc8490e532 100644 (file)
@@ -233,11 +233,20 @@ extern GTY(()) tree c_global_trees[CTI_MAX];
 
 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_objcxx   = 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_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 +360,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 +398,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 +953,7 @@ extern void disable_builtin_function (const char *);
 
 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 1dfc5d0c167a37327d2aeae67fab9b1cbd9093bb..879d731268a3f5a94320539785ee28550a98a381 100644 (file)
@@ -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 78b74a4ade7407c18d5a3e4778726cf8acf00079..70d31fe176fd0f540b94ab307e15fb6d51ebd92d 100644 (file)
@@ -2863,7 +2863,7 @@ finish_decl (tree decl, tree init, tree asmspec_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 asmspec_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 declspecs, tree width)
   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, tree attributes)
            {
              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, tree attributes)
                  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 b971d3258aad40ecfce4dc173ba34d538f5cd996..5fa06f472679d8780335e709bcd8c312343a063d 100644 (file)
@@ -261,7 +261,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                             \
@@ -269,7 +269,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 6d8c89ab1c608fe596066a895eae18abd72463f8..5da15e5fa3c1609e46867e7d2063f7ea0fdf6bdd 100644 (file)
@@ -31,7 +31,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #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
@@ -159,12 +159,6 @@ const char *const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
-static int
-c_init_options (void)
-{
-  return c_common_init_options (clk_c);
-}
-
 /* Used by c-lex.c, but only for objc.  */
 
 tree
index f9c422545270d88cd0ca146e77442ee0c95e6ae1..2cca2313c2fe0640c86ac6c6829c7c1378aa7952 100644 (file)
@@ -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_cxx () || chars_seen > 1)
     type = integer_type_node;
   else
     type = char_type_node;
index dbe7e903f0a9401bda8e6224e80504bfc1a86fd9..09c58b91569a37d8f6be2901de0122a36d403ee5 100644 (file)
@@ -50,8 +50,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 # 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 char *arg)
 
 /* 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_cxx () ? CLK_GNUCXX: CLK_GNUC89,
                                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, const char *arg, int value)
       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, const char *arg, int value)
       if (warn_uninitialized != 1)
        warn_uninitialized = (value ? 2 : 0);
 
-      if (c_language == clk_c)
+      if (!c_dialect_cxx ())
        /* 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, const char *arg, int value)
       break;
 
     case OPT_Wwrite_strings:
-      if (c_language == clk_c)
+      if (!c_dialect_cxx ())
        flag_const_strings = value;
       else
        warn_write_strings = value;
       break;
 
     case OPT_ansi:
-      if (c_language == clk_c)
+      if (!c_dialect_cxx ())
        set_std_c89 (false, true);
       else
        set_std_cxx98 (true);
@@ -662,7 +673,7 @@ c_common_handle_option (size_t scode, const char *arg, int value)
       break;
 
     case OPT_fcond_mismatch:
-      if (c_language == clk_c)
+      if (!c_dialect_cxx ())
        {
          flag_cond_mismatch = value;
          break;
@@ -1053,8 +1064,7 @@ c_common_post_options (const char **pfilename)
   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 2316ca7dfa394fd242b6aeec55f4ffacc520ba1f..55d06b4030c7de066ca775a44e26c09f673379ac 100644 (file)
@@ -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 2dccecd506ff9add271ac08d5f94cf111f71d28a..2cd9b9d1a2dae152e9e6afd4caef603f5c4289d7 100644 (file)
@@ -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 b376ac94901cde42a4810311862004bf6895b637..3fd9f55083ca450e86c5ccc91fcf8c51d8fb8adf 100644 (file)
@@ -336,18 +336,18 @@ pp_c_bool_literal (c_pretty_printer ppi, tree b)
 {
   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 (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 (flag_isoc99)
        pp_c_identifier (ppi, "_True");
       else
        pp_unsupported_tree (ppi, b);
index 4bb171f660961db57036cf79beaf9b3f012e175f..a6213e2faf9bd1e0f94e725b4cd11bec96d60b1d 100644 (file)
@@ -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 rhs, const char *errtype, tree fundecl,
       /* 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 9289d6770874c7ab4c9f18b12bcda4dadff92907..040582dc6cd8999a37a954bd10d71f682486b92c 100644 (file)
@@ -1,3 +1,12 @@
+2003-06-30  Neil Booth  <neil@daikokuya.co.uk>
+
+       * 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.
+
 2003-06-30  Giovanni Bajo  <giovannibajo@libero.it>
 
         PR c++/4933
index e340987c08f3f0b9d0eae1b87ce24f21495ea4f3..2ca563467a01d135ec78e4b9f5a45b385e70d02d 100644 (file)
@@ -232,8 +232,7 @@ CXX_TREE_H = $(TREE_H) cp/name-lookup.h cp/cp-tree.h c-common.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 c79943727f3b078fe7932f2320842056d227c193..f26317bb22f501ba1e154623efcb1b6130603fbd 100644 (file)
@@ -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 d98e92c0f50b59c7f10a148afe9056220664b18c..cb0bdfcc8038f96d86d9b575d7f04ca60ee46839 100644 (file)
@@ -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 b378dc1724a64418be5e53ce4a1e06a2646e0550..a3f287878d2628671d6cb18a5bfc1a44c6291cd2 100644 (file)
@@ -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 not we know this class
                                   to behave according to #pragma interface.  */
 
 \f
-/* 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 7d76b6be7b2f56be79383f0a34fbd93c4efd607d..4457ee84ceb1bbd3c4e06a6678e8e6d9e3b3bc89 100644 (file)
@@ -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                   PARAMS ((void));
 #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);
-}