Commit 0f7866e7 by Ziemowit Laski Committed by Ziemowit Laski

c-common.c (flag_objc): New.

2002-08-09  Ziemowit Laski  <zlaski@apple.com>

        * c-common.c (flag_objc): New.
        * c-common.h (c_language_kind): Get rid of clk_objective_c
        enum value.
        (flag_objc): New extern declaration.
        * c-decl.c (implicitly_declare): Call objc_check_decl
        instead of maybe_objc_check_decl.
        (finish_decl): Likewise.
        (grokfield): Likewise.
        (finish_struct): Likewise.
        * c-lang.c (maybe_objc_check_decl): Rename to objc_check_decl.
        (maybe_objc_comptypes): Rename to objc_comptypes.
        (maybe_building_objc_message_expr): Rename to
        objc_message_selector.
        * c-lex.c (lex_charconst): Remove uses of clk_objective_c,
        replace with flag_objc as needed.
        * c-opts.c (c_common_init_options): Likewise.
        (c_common_decode_option): Likewise.
        * c-parse.in (init_reswords): Likewise.
        * c-tree.h (maybe_objc_check_decl): Rename to objc_check_decl.
        (maybe_objc_comptypes): Rename to objc_comptypes.
        (maybe_building_objc_message_expr): Rename to
        objc_message_selector.
        * c-typeck.c (comptypes): Call objc_comptypes instead of
        maybe_objc_comptypes, and/or objc_message_selector instead of
        (comp_target_types): Likewise.
        (convert_for_assignment): Likewise.
        (warn_for_assignment): Likewise.
        * cppinit.c (init_builtins): Set __OBJC__ manifest constant
        independently of those for other languages.
        * objc/objc-act.c (maybe_objc_comptypes): Delete.
        (maybe_objc_check_decl): Delete.
        (maybe_building_objc_message_expr): Rename to
        objc_message_selector.
        * objc/objc-lang.c (objc_init_options): Use clk_c instead of
        clk_objective_c; set flag_objc flag.

From-SVN: r56173
parent 9e259dd1
2002-08-09 Ziemowit Laski <zlaski@apple.com>
* c-common.c (flag_objc): New.
* c-common.h (c_language_kind): Get rid of clk_objective_c
enum value.
(flag_objc): New extern declaration.
* c-decl.c (implicitly_declare): Call objc_check_decl
instead of maybe_objc_check_decl.
(finish_decl): Likewise.
(grokfield): Likewise.
(finish_struct): Likewise.
* c-lang.c (maybe_objc_check_decl): Rename to objc_check_decl.
(maybe_objc_comptypes): Rename to objc_comptypes.
(maybe_building_objc_message_expr): Rename to
objc_message_selector.
* c-lex.c (lex_charconst): Remove uses of clk_objective_c,
replace with flag_objc as needed.
* c-opts.c (c_common_init_options): Likewise.
(c_common_decode_option): Likewise.
* c-parse.in (init_reswords): Likewise.
* c-tree.h (maybe_objc_check_decl): Rename to objc_check_decl.
(maybe_objc_comptypes): Rename to objc_comptypes.
(maybe_building_objc_message_expr): Rename to
objc_message_selector.
* c-typeck.c (comptypes): Call objc_comptypes instead of
maybe_objc_comptypes, and/or objc_message_selector instead of
maybe_building_objc_message_expr.
(comp_target_types): Likewise.
(convert_for_assignment): Likewise.
(warn_for_assignment): Likewise.
* cppinit.c (init_builtins): Set __OBJC__ manifest constant
independently of those for other languages.
* objc/objc-act.c (maybe_objc_comptypes): Delete.
(maybe_objc_check_decl): Delete.
(maybe_building_objc_message_expr): Rename to
objc_message_selector.
* objc/objc-lang.c (objc_init_options): Use clk_c instead of
clk_objective_c; set flag_objc flag.
2002-08-09 Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com> 2002-08-09 Toshiyasu Morita <toshiyasu.morita@hsa.hitachi.com>
* ifcvt.c (find_if_case_2): Test correct basic block for size. * ifcvt.c (find_if_case_2): Test correct basic block for size.
......
...@@ -200,6 +200,9 @@ int flag_preprocess_only; ...@@ -200,6 +200,9 @@ int flag_preprocess_only;
user's namespace. */ user's namespace. */
int flag_iso; 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 /* Nonzero if -undef was given. It suppresses target built-in macros
and assertions. */ and assertions. */
int flag_undef; int flag_undef;
......
...@@ -240,8 +240,7 @@ typedef enum c_language_kind ...@@ -240,8 +240,7 @@ typedef enum c_language_kind
{ {
clk_c, /* A dialect of C: K&R C, ANSI/ISO C89, C2000, clk_c, /* A dialect of C: K&R C, ANSI/ISO C89, C2000,
etc. */ etc. */
clk_cplusplus, /* ANSI/ISO C++ */ clk_cplusplus /* ANSI/ISO C++ */
clk_objective_c /* Objective C */
} }
c_language_kind; c_language_kind;
...@@ -367,7 +366,6 @@ struct c_lang_decl GTY(()) { ...@@ -367,7 +366,6 @@ struct c_lang_decl GTY(()) {
extern c_language_kind c_language; extern c_language_kind c_language;
/* Switches common to the C front ends. */ /* Switches common to the C front ends. */
/* Nonzero if prepreprocessing only. */ /* Nonzero if prepreprocessing only. */
...@@ -377,6 +375,9 @@ extern int flag_preprocess_only; ...@@ -377,6 +375,9 @@ extern int flag_preprocess_only;
user's namespace. */ user's namespace. */
extern int flag_iso; 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 /* Nonzero if -undef was given. It suppresses target built-in macros
and assertions. */ and assertions. */
extern int flag_undef; extern int flag_undef;
...@@ -794,9 +795,6 @@ extern int warn_deprecated; ...@@ -794,9 +795,6 @@ extern int warn_deprecated;
extern int max_tinst_depth; extern int max_tinst_depth;
/* C types are partitioned into three subsets: object, function, and /* C types are partitioned into three subsets: object, function, and
incomplete types. */ incomplete types. */
#define C_TYPE_OBJECT_P(type) \ #define C_TYPE_OBJECT_P(type) \
......
...@@ -2059,8 +2059,9 @@ implicitly_declare (functionid) ...@@ -2059,8 +2059,9 @@ implicitly_declare (functionid)
So we record the decl in the standard fashion. */ So we record the decl in the standard fashion. */
pushdecl (decl); pushdecl (decl);
/* This is a no-op in c-lang.c or something real in objc-actions.c. */ /* This is a no-op in c-lang.c or something real in objc-act.c. */
maybe_objc_check_decl (decl); if (flag_objc)
objc_check_decl (decl);
rest_of_decl_compilation (decl, NULL, 0, 0); rest_of_decl_compilation (decl, NULL, 0, 0);
...@@ -3097,8 +3098,9 @@ finish_decl (decl, init, asmspec_tree) ...@@ -3097,8 +3098,9 @@ finish_decl (decl, init, asmspec_tree)
if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL) 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-actions.c. */ /* This is a no-op in c-lang.c or something real in objc-act.c. */
maybe_objc_check_decl (decl); if (flag_objc)
objc_check_decl (decl);
if (!DECL_CONTEXT (decl)) if (!DECL_CONTEXT (decl))
{ {
...@@ -3160,8 +3162,9 @@ finish_decl (decl, init, asmspec_tree) ...@@ -3160,8 +3162,9 @@ finish_decl (decl, init, asmspec_tree)
if (TREE_CODE (decl) == TYPE_DECL) if (TREE_CODE (decl) == TYPE_DECL)
{ {
/* This is a no-op in c-lang.c or something real in objc-actions.c. */ /* This is a no-op in c-lang.c or something real in objc-act.c. */
maybe_objc_check_decl (decl); if (flag_objc)
objc_check_decl (decl);
rest_of_decl_compilation (decl, NULL, DECL_CONTEXT (decl) == 0, 0); rest_of_decl_compilation (decl, NULL, DECL_CONTEXT (decl) == 0, 0);
} }
...@@ -5009,7 +5012,8 @@ grokfield (filename, line, declarator, declspecs, width) ...@@ -5009,7 +5012,8 @@ grokfield (filename, line, declarator, declspecs, width)
finish_decl (value, NULL_TREE, NULL_TREE); finish_decl (value, NULL_TREE, NULL_TREE);
DECL_INITIAL (value) = width; DECL_INITIAL (value) = width;
maybe_objc_check_decl (value); if (flag_objc)
objc_check_decl (value);
return value; return value;
} }
...@@ -5297,8 +5301,9 @@ finish_struct (t, fieldlist, attributes) ...@@ -5297,8 +5301,9 @@ finish_struct (t, fieldlist, attributes)
&& TREE_CODE (decl) != TYPE_DECL) && TREE_CODE (decl) != TYPE_DECL)
{ {
layout_decl (decl, 0); layout_decl (decl, 0);
/* This is a no-op in c-lang.c or something real in objc-actions.c. */ /* This is a no-op in c-lang.c or something real in objc-act.c. */
maybe_objc_check_decl (decl); if (flag_objc)
objc_check_decl (decl);
rest_of_decl_compilation (decl, NULL, toplevel, 0); rest_of_decl_compilation (decl, NULL, toplevel, 0);
if (! toplevel) if (! toplevel)
expand_decl (decl); expand_decl (decl);
...@@ -5320,7 +5325,8 @@ finish_struct (t, fieldlist, attributes) ...@@ -5320,7 +5325,8 @@ finish_struct (t, fieldlist, attributes)
if (TREE_CODE (decl) != TYPE_DECL) if (TREE_CODE (decl) != TYPE_DECL)
{ {
layout_decl (decl, 0); layout_decl (decl, 0);
maybe_objc_check_decl (decl); if (flag_objc)
objc_check_decl (decl);
rest_of_decl_compilation (decl, NULL, toplevel, 0); rest_of_decl_compilation (decl, NULL, toplevel, 0);
if (! toplevel) if (! toplevel)
expand_decl (decl); expand_decl (decl);
......
...@@ -183,13 +183,13 @@ is_class_name (arg) ...@@ -183,13 +183,13 @@ is_class_name (arg)
} }
void void
maybe_objc_check_decl (decl) objc_check_decl (decl)
tree decl ATTRIBUTE_UNUSED; tree decl ATTRIBUTE_UNUSED;
{ {
} }
int int
maybe_objc_comptypes (lhs, rhs, reflexive) objc_comptypes (lhs, rhs, reflexive)
tree lhs ATTRIBUTE_UNUSED; tree lhs ATTRIBUTE_UNUSED;
tree rhs ATTRIBUTE_UNUSED; tree rhs ATTRIBUTE_UNUSED;
int reflexive ATTRIBUTE_UNUSED; int reflexive ATTRIBUTE_UNUSED;
...@@ -198,7 +198,7 @@ maybe_objc_comptypes (lhs, rhs, reflexive) ...@@ -198,7 +198,7 @@ maybe_objc_comptypes (lhs, rhs, reflexive)
} }
tree tree
maybe_building_objc_message_expr () objc_message_selector ()
{ {
return 0; return 0;
} }
......
...@@ -1078,8 +1078,7 @@ lex_charconst (token) ...@@ -1078,8 +1078,7 @@ lex_charconst (token)
type = wchar_type_node; type = wchar_type_node;
/* In C, a character constant has type 'int'. /* In C, a character constant has type 'int'.
In C++ 'char', but multi-char charconsts have type 'int'. */ In C++ 'char', but multi-char charconsts have type 'int'. */
else if ((c_language == clk_c || c_language == clk_objective_c) else if ((c_language == clk_c) || chars_seen > 1)
|| chars_seen > 1)
type = integer_type_node; type = integer_type_node;
else else
type = char_type_node; type = char_type_node;
......
...@@ -406,11 +406,11 @@ c_common_init_options (lang) ...@@ -406,11 +406,11 @@ c_common_init_options (lang)
#endif #endif
c_language = lang; c_language = lang;
parse_in = cpp_create_reader (lang == clk_c || lang == clk_objective_c parse_in = cpp_create_reader (lang == clk_c
? CLK_GNUC89 : CLK_GNUCXX); ? CLK_GNUC89 : CLK_GNUCXX);
cpp_opts = cpp_get_options (parse_in); cpp_opts = cpp_get_options (parse_in);
if (lang == clk_objective_c) if (flag_objc)
cpp_opts->objc = 1; cpp_opts->objc = 1;
flag_const_strings = (lang == clk_cplusplus); flag_const_strings = (lang == clk_cplusplus);
...@@ -447,9 +447,14 @@ c_common_decode_option (argc, argv) ...@@ -447,9 +447,14 @@ c_common_decode_option (argc, argv)
switch (c_language) switch (c_language)
{ {
case clk_c: lang_flag = CL_C_ONLY; break; case clk_c: lang_flag = (flag_objc
case clk_cplusplus: lang_flag = CL_CXX_ONLY; break; ? CL_C
case clk_objective_c: lang_flag = CL_OBJC_ONLY; break; : CL_C_ONLY);
break;
case clk_cplusplus: lang_flag = (flag_objc
? CL_CXX
: CL_CXX_ONLY);
break;
default: abort (); default: abort ();
} }
...@@ -557,7 +562,7 @@ c_common_decode_option (argc, argv) ...@@ -557,7 +562,7 @@ c_common_decode_option (argc, argv)
if (warn_uninitialized != 1) if (warn_uninitialized != 1)
warn_uninitialized = (on ? 2 : 0); warn_uninitialized = (on ? 2 : 0);
if (c_language == clk_c || c_language == clk_objective_c) if (c_language == clk_c)
/* We set this to 2 here, but 1 in -Wmain, so -ffreestanding /* We set this to 2 here, but 1 in -Wmain, so -ffreestanding
can turn it off only if it's not explicit. */ can turn it off only if it's not explicit. */
warn_main = on * 2; warn_main = on * 2;
...@@ -813,7 +818,7 @@ c_common_decode_option (argc, argv) ...@@ -813,7 +818,7 @@ c_common_decode_option (argc, argv)
break; break;
case OPT_Wwrite_strings: case OPT_Wwrite_strings:
if (c_language == clk_c || c_language == clk_objective_c) if (c_language == clk_c)
flag_const_strings = on; flag_const_strings = on;
else else
warn_write_strings = on; warn_write_strings = on;
...@@ -824,7 +829,7 @@ c_common_decode_option (argc, argv) ...@@ -824,7 +829,7 @@ c_common_decode_option (argc, argv)
break; break;
case OPT_fcond_mismatch: case OPT_fcond_mismatch:
if (c_language == clk_c || c_language == clk_objective_c) if (c_language == clk_c)
{ {
flag_cond_mismatch = on; flag_cond_mismatch = on;
break; break;
...@@ -1114,7 +1119,7 @@ c_common_decode_option (argc, argv) ...@@ -1114,7 +1119,7 @@ c_common_decode_option (argc, argv)
case OPT_std_iso9899_199409: case OPT_std_iso9899_199409:
case OPT_ansi: case OPT_ansi:
/* Note: -ansi is used by both the C and C++ front ends. */ /* Note: -ansi is used by both the C and C++ front ends. */
if (c_language == clk_c || c_language == clk_objective_c) if (c_language == clk_c)
{ {
flag_no_asm = 1; flag_no_asm = 1;
flag_writable_strings = 0; flag_writable_strings = 0;
......
...@@ -3546,7 +3546,7 @@ init_reswords () ...@@ -3546,7 +3546,7 @@ init_reswords ()
int mask = (flag_isoc99 ? 0 : D_C89) int mask = (flag_isoc99 ? 0 : D_C89)
| (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0); | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0);
if (c_language != clk_objective_c) if (!flag_objc)
mask |= D_OBJC; mask |= D_OBJC;
/* It is not necessary to register ridpointers as a GC root, because /* It is not necessary to register ridpointers as a GC root, because
......
...@@ -165,10 +165,10 @@ struct lang_type GTY(()) ...@@ -165,10 +165,10 @@ struct lang_type GTY(())
/* in c-lang.c and objc-act.c */ /* in c-lang.c and objc-act.c */
extern tree lookup_interface PARAMS ((tree)); extern tree lookup_interface PARAMS ((tree));
extern tree is_class_name PARAMS ((tree)); extern tree is_class_name PARAMS ((tree));
extern void maybe_objc_check_decl PARAMS ((tree)); extern void objc_check_decl PARAMS ((tree));
extern void finish_file PARAMS ((void)); extern void finish_file PARAMS ((void));
extern int maybe_objc_comptypes PARAMS ((tree, tree, int)); extern int objc_comptypes PARAMS ((tree, tree, int));
extern tree maybe_building_objc_message_expr PARAMS ((void)); extern tree objc_message_selector PARAMS ((void));
extern int recognize_objc_keyword PARAMS ((void)); extern int recognize_objc_keyword PARAMS ((void));
extern tree lookup_objc_ivar PARAMS ((tree)); extern tree lookup_objc_ivar PARAMS ((tree));
......
...@@ -568,7 +568,7 @@ comptypes (type1, type2) ...@@ -568,7 +568,7 @@ comptypes (type1, type2)
} }
case RECORD_TYPE: case RECORD_TYPE:
if (maybe_objc_comptypes (t1, t2, 0) == 1) if (flag_objc && objc_comptypes (t1, t2, 0) == 1)
val = 1; val = 1;
break; break;
...@@ -588,7 +588,7 @@ comp_target_types (ttl, ttr) ...@@ -588,7 +588,7 @@ comp_target_types (ttl, ttr)
int val; int val;
/* Give maybe_objc_comptypes a crack at letting these types through. */ /* Give maybe_objc_comptypes a crack at letting these types through. */
if ((val = maybe_objc_comptypes (ttl, ttr, 1)) >= 0) if ((val = objc_comptypes (ttl, ttr, 1)) >= 0)
return val; return val;
val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)), val = comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (ttl)),
...@@ -3985,7 +3985,8 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) ...@@ -3985,7 +3985,8 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
overflow_warning (rhs); overflow_warning (rhs);
/* Check for Objective-C protocols. This will issue a warning if /* Check for Objective-C protocols. This will issue a warning if
there are protocol violations. No need to use the return value. */ there are protocol violations. No need to use the return value. */
maybe_objc_comptypes (type, rhstype, 0); if (flag_objc)
objc_comptypes (type, rhstype, 0);
return rhs; return rhs;
} }
...@@ -4213,7 +4214,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum) ...@@ -4213,7 +4214,7 @@ convert_for_assignment (type, rhs, errtype, fundecl, funname, parmnum)
{ {
if (funname) if (funname)
{ {
tree selector = maybe_building_objc_message_expr (); tree selector = objc_message_selector ();
if (selector && parmnum > 2) if (selector && parmnum > 2)
error ("incompatible type for argument %d of `%s'", error ("incompatible type for argument %d of `%s'",
...@@ -4271,7 +4272,7 @@ warn_for_assignment (msgid, opname, function, argnum) ...@@ -4271,7 +4272,7 @@ warn_for_assignment (msgid, opname, function, argnum)
{ {
if (opname == 0) if (opname == 0)
{ {
tree selector = maybe_building_objc_message_expr (); tree selector = objc_message_selector ();
char * new_opname; char * new_opname;
if (selector && argnum > 2) if (selector && argnum > 2)
......
...@@ -694,16 +694,16 @@ init_builtins (pfile) ...@@ -694,16 +694,16 @@ init_builtins (pfile)
if (CPP_OPTION (pfile, cplusplus)) if (CPP_OPTION (pfile, cplusplus))
_cpp_define_builtin (pfile, "__cplusplus 1"); _cpp_define_builtin (pfile, "__cplusplus 1");
else if (CPP_OPTION (pfile, objc))
_cpp_define_builtin (pfile, "__OBJC__ 1");
else if (CPP_OPTION (pfile, lang) == CLK_ASM) else if (CPP_OPTION (pfile, lang) == CLK_ASM)
_cpp_define_builtin (pfile, "__ASSEMBLER__ 1"); _cpp_define_builtin (pfile, "__ASSEMBLER__ 1");
else if (CPP_OPTION (pfile, lang) == CLK_STDC94)
if (CPP_OPTION (pfile, lang) == CLK_STDC94)
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L"); _cpp_define_builtin (pfile, "__STDC_VERSION__ 199409L");
else if (CPP_OPTION (pfile, c99)) else if (CPP_OPTION (pfile, c99))
_cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L"); _cpp_define_builtin (pfile, "__STDC_VERSION__ 199901L");
if (CPP_OPTION (pfile, objc))
_cpp_define_builtin (pfile, "__OBJC__ 1");
if (pfile->cb.register_builtins) if (pfile->cb.register_builtins)
(*pfile->cb.register_builtins) (pfile); (*pfile->cb.register_builtins) (pfile);
} }
......
...@@ -518,14 +518,6 @@ define_decl (declarator, declspecs) ...@@ -518,14 +518,6 @@ define_decl (declarator, declspecs)
`a' and `b' are the same class type, or `a' and `b' are the same class type, or
`a' and `b' are of class types A and B such that B is a descendant of A. */ `a' and `b' are of class types A and B such that B is a descendant of A. */
int
maybe_objc_comptypes (lhs, rhs, reflexive)
tree lhs, rhs;
int reflexive;
{
return objc_comptypes (lhs, rhs, reflexive);
}
static tree static tree
lookup_method_in_protocol_list (rproto_list, sel_name, class_meth) lookup_method_in_protocol_list (rproto_list, sel_name, class_meth)
tree rproto_list; tree rproto_list;
...@@ -764,13 +756,6 @@ objc_check_decl (decl) ...@@ -764,13 +756,6 @@ objc_check_decl (decl)
error_with_decl (decl, "`%s' cannot be statically allocated"); error_with_decl (decl, "`%s' cannot be statically allocated");
} }
void
maybe_objc_check_decl (decl)
tree decl;
{
objc_check_decl (decl);
}
/* Implement static typing. At this point, we know we have an interface. */ /* Implement static typing. At this point, we know we have an interface. */
tree tree
...@@ -4690,7 +4675,7 @@ receiver_is_class_object (receiver) ...@@ -4690,7 +4675,7 @@ receiver_is_class_object (receiver)
static tree building_objc_message_expr = 0; static tree building_objc_message_expr = 0;
tree tree
maybe_building_objc_message_expr () objc_message_selector ()
{ {
return building_objc_message_expr; return building_objc_message_expr;
} }
......
...@@ -162,5 +162,6 @@ const char * const tree_code_name[] = { ...@@ -162,5 +162,6 @@ const char * const tree_code_name[] = {
static void static void
objc_init_options () objc_init_options ()
{ {
c_common_init_options (clk_objective_c); flag_objc = 1;
c_common_init_options (clk_c);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment