summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog31
-rw-r--r--gcc/c-common.c40
-rw-r--r--gcc/c-common.h23
-rw-r--r--gcc/c-cppbuiltin.c8
-rw-r--r--gcc/c-decl.c10
-rw-r--r--gcc/c-format.c4
-rw-r--r--gcc/c-lang.c10
-rw-r--r--gcc/c-lex.c2
-rw-r--r--gcc/c-opts.c46
-rw-r--r--gcc/c-parse.in2
-rw-r--r--gcc/c-pch.c9
-rw-r--r--gcc/c-pretty-print.c8
-rw-r--r--gcc/c-typeck.c6
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/Make-lang.in3
-rw-r--r--gcc/cp/cp-lang.c4
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/lex.c17
-rw-r--r--gcc/objc/objc-lang.c11
19 files changed, 122 insertions, 122 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7f7da350399..b94a8713fe1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 43f9586d415..9e037658507 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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)
{
diff --git a/gcc/c-common.h b/gcc/c-common.h
index d97f460712d..0843e11e858 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -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);
diff --git a/gcc/c-cppbuiltin.c b/gcc/c-cppbuiltin.c
index 1dfc5d0c167..879d731268a 100644
--- a/gcc/c-cppbuiltin.c
+++ b/gcc/c-cppbuiltin.c
@@ -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
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 78b74a4ade7..70d31fe176f 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -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)
diff --git a/gcc/c-format.c b/gcc/c-format.c
index b971d3258aa..5fa06f47267 100644
--- a/gcc/c-format.c
+++ b/gcc/c-format.c
@@ -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" \
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index 6d8c89ab1c6..5da15e5fa3c 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -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
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index f9c42254527..2cca2313c2f 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -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;
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index dbe7e903f0a..09c58b91569 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -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;
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 2316ca7dfa3..55d06b4030c 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -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));
diff --git a/gcc/c-pch.c b/gcc/c-pch.c
index 2dccecd506f..2cd9b9d1a2d 100644
--- a/gcc/c-pch.c
+++ b/gcc/c-pch.c
@@ -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;
}
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index b376ac94901..3fd9f55083c 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -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);
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 4bb171f6609..a6213e2faf9 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -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;
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9289d677087..040582dc6cd 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index e340987c08f..2ca563467a0 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -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 \
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index c79943727f3..f26317bb22f 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -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
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index d98e92c0f50..cb0bdfcc803 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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);
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index b378dc1724a..a3f287878d2 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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. */
-/* 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)
{
diff --git a/gcc/objc/objc-lang.c b/gcc/objc/objc-lang.c
index 7d76b6be7b2..4457ee84ceb 100644
--- a/gcc/objc/objc-lang.c
+++ b/gcc/objc/objc-lang.c
@@ -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);
-}