Yet more Objective-C++...

* c-common.h (objc_finish_try_stmt): Add.
        (objc_build_synchronized): Add.
        (objc_generate_write_barrier): Add.
        * stub-objc.c (objc_build_synchronized): Add return value.
        (objc_finish_try_stmt): Likewise.
        (objc_generate_write_barrier): Add.

        * c-common.h (objc_rewrite_function_call): Add.
        * c-typeck.c (build_function_call): Allow objc to rewrite
        FUNCTION_DECLs.
        (build_modify_expr): Allow objc to generate write barriers.
        * c.opt (Wassign-intercept): Add.
        (Wstrict-selector-match): Add.
        (fobjc-call-cxx-cdtors): Add.
        (fobjc-direct-dispatch): Add.
        (fobjc-gc): Add.
        * dbxout.c (get_lang_number): Add Objective-C++ support.
        * doc/invoke.texi (-fobjc-call-cxx-cdtors): Likewise.
        (-Wstrict-selector-match): Likewise.
        (-fobjc-direct-dispatch): Likewise.
        (-Wassign-intercept): Likewise.
        (Overall Options): Likewise.
        * gengtype.c (get_output_file_with_visibility): Likewise.
        * stub-objc.c (objc_rewrite_function_call): Add.
        * config/darwin.h (ASM_OUTPUT_LABELREF): Improved quoting support.

        * c-common.c (flag_objc_exceptions): Remove.
        (flag_objc_sjlj_exceptions): Remove.
        * c-decl.c (objc_mark_locals_volatile): Don't change decls
        that are already ok.
        * c-opts.c (c_common_handle_option, case
        OPT_fobjc_exceptions): Remove.
        (case OPT_fobjc_sjlj_exceptions): Remove
        * c.opt (fobjc-call-cxx-cdtors): Have opt create the flag.
        (fobjc-exceptions): Likewise.
        (fobjc-sjlj-exceptions): Likewise.
        * config/rs6000/darwin.h (OFFS_MSGSEND_FAST): Add.
        (OFFS_ASSIGNIVAR_FAST): Add.

From-SVN: r99858
This commit is contained in:
Ziemowit Laski 2005-05-17 20:11:44 +00:00 committed by Mike Stump
parent 38b9c8c3a9
commit 6e95543072
13 changed files with 206 additions and 30 deletions

View File

@ -1,3 +1,46 @@
2005-05-17 Mike Stump <mrs@apple.com>
Yet more Objective-C++...
* c-common.h (objc_finish_try_stmt): Add.
(objc_build_synchronized): Add.
(objc_generate_write_barrier): Add.
* stub-objc.c (objc_build_synchronized): Add return value.
(objc_finish_try_stmt): Likewise.
(objc_generate_write_barrier): Add.
* c-common.h (objc_rewrite_function_call): Add.
* c-typeck.c (build_function_call): Allow objc to rewrite
FUNCTION_DECLs.
(build_modify_expr): Allow objc to generate write barriers.
* c.opt (Wassign-intercept): Add.
(Wstrict-selector-match): Add.
(fobjc-call-cxx-cdtors): Add.
(fobjc-direct-dispatch): Add.
(fobjc-gc): Add.
* dbxout.c (get_lang_number): Add Objective-C++ support.
* doc/invoke.texi (-fobjc-call-cxx-cdtors): Likewise.
(-Wstrict-selector-match): Likewise.
(-fobjc-direct-dispatch): Likewise.
(-Wassign-intercept): Likewise.
(Overall Options): Likewise.
* gengtype.c (get_output_file_with_visibility): Likewise.
* stub-objc.c (objc_rewrite_function_call): Add.
* config/darwin.h (ASM_OUTPUT_LABELREF): Improved quoting support.
* c-common.c (flag_objc_exceptions): Remove.
(flag_objc_sjlj_exceptions): Remove.
* c-decl.c (objc_mark_locals_volatile): Don't change decls
that are already ok.
* c-opts.c (c_common_handle_option, case
OPT_fobjc_exceptions): Remove.
(case OPT_fobjc_sjlj_exceptions): Remove
* c.opt (fobjc-call-cxx-cdtors): Have opt create the flag.
(fobjc-exceptions): Likewise.
(fobjc-sjlj-exceptions): Likewise.
* config/rs6000/darwin.h (OFFS_MSGSEND_FAST): Add.
(OFFS_ASSIGNIVAR_FAST): Add.
2005-05-17 Eric Botcazou <ebotcazou@libertysurf.fr>
* config/sparc/sparc.md (movhi): Do not test constness
@ -38,6 +81,7 @@
* cfgloopanal.c (just_once_each_iteration_p): Make the loop argument
const.
>>>>>>> 2.8834
2005-05-17 Zdenek Dvorak <dvorakz@suse.cz>
* ggc-page.c (ggc_alloc_stat): Record amount of memory allocated.

View File

@ -290,13 +290,6 @@ int warn_strict_null_sentinel;
will most likely result in crashes. */
int flag_nil_receivers = 1;
/* Nonzero means that we will allow new ObjC exception syntax (@throw,
@try, etc.) in source code. */
int flag_objc_exceptions = 0;
/* Nonzero means that we generate NeXT setjmp based exceptions. */
int flag_objc_sjlj_exceptions = -1;
/* Nonzero means that code generation will be altered to support
"zero-link" execution. This currently affects ObjC only, but may
affect other languages in the future. */

View File

@ -874,6 +874,7 @@ extern tree objc_is_object_ptr (tree);
extern void objc_check_decl (tree);
extern int objc_is_reserved_word (tree);
extern int objc_comptypes (tree, tree, int);
extern tree objc_rewrite_function_call (tree, tree);
extern tree objc_message_selector (void);
extern tree objc_lookup_ivar (tree, tree);
extern void objc_clear_super_receiver (void);
@ -910,13 +911,14 @@ extern void objc_add_instance_variable (tree);
extern tree objc_build_keyword_decl (tree, tree, tree);
extern tree objc_build_throw_stmt (tree);
extern void objc_begin_try_stmt (location_t, tree);
extern void objc_finish_try_stmt (void);
extern tree objc_finish_try_stmt (void);
extern void objc_begin_catch_clause (tree);
extern void objc_finish_catch_clause (void);
extern void objc_build_finally_clause (location_t, tree);
extern void objc_build_synchronized (location_t, tree, tree);
extern tree objc_build_synchronized (location_t, tree, tree);
extern int objc_static_init_needed_p (void);
extern tree objc_generate_static_init_call (tree);
extern tree objc_generate_write_barrier (tree, enum tree_code, tree);
/* The following are provided by the C and C++ front-ends, and called by
ObjC/ObjC++. */

View File

@ -567,12 +567,22 @@ objc_mark_locals_volatile (void *enclosing_blk)
{
for (b = scope->bindings; b; b = b->prev)
{
if (TREE_CODE (b->decl) == VAR_DECL
|| TREE_CODE (b->decl) == PARM_DECL)
tree decl = b->decl;
/* Do not mess with variables that are 'static' or (already)
'volatile'. */
if (!TREE_THIS_VOLATILE (decl) && !TREE_STATIC (decl)
&& (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL))
{
C_DECL_REGISTER (b->decl) = 0;
DECL_REGISTER (b->decl) = 0;
TREE_THIS_VOLATILE (b->decl) = 1;
TREE_TYPE (decl)
= build_qualified_type (TREE_TYPE (decl),
(TYPE_QUALS (TREE_TYPE (decl))
| TYPE_QUAL_VOLATILE));
TREE_THIS_VOLATILE (decl) = 1;
TREE_SIDE_EFFECTS (decl) = 1;
DECL_REGISTER (decl) = 0;
C_DECL_REGISTER (decl) = 0;
}
}

View File

@ -699,14 +699,6 @@ c_common_handle_option (size_t scode, const char *arg, int value)
flag_no_nonansi_builtin = !value;
break;
case OPT_fobjc_exceptions:
flag_objc_exceptions = value;
break;
case OPT_fobjc_sjlj_exceptions:
flag_objc_sjlj_exceptions = value;
break;
case OPT_foperator_names:
cpp_opts->operator_names = value;
break;

View File

@ -2023,6 +2023,10 @@ build_function_call (tree function, tree params)
else
function = default_conversion (function);
/* For Objective-C, convert any calls via a cast to OBJC_TYPE_REF
expressions, like those used for ObjC messenger dispatches. */
function = objc_rewrite_function_call (function, params);
fntype = TREE_TYPE (function);
if (TREE_CODE (fntype) == ERROR_MARK)
@ -3485,6 +3489,14 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
if (TREE_CODE (newrhs) == ERROR_MARK)
return error_mark_node;
/* Emit ObjC write barrier, if necessary. */
if (c_dialect_objc () && flag_objc_gc)
{
result = objc_generate_write_barrier (lhs, modifycode, newrhs);
if (result)
return result;
}
/* Scan operands. */
result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);

View File

@ -120,6 +120,10 @@ Wall
C ObjC C++ ObjC++
Enable most warning messages
Wassign-intercept
ObjC ObjC++ Var(warn_assign_intercept)
Warn whenever an Objective-C assignment is being intercepted by the garbage collector
Wbad-function-cast
C ObjC Var(warn_bad_function_cast)
Warn about casting functions to incompatible types
@ -362,6 +366,10 @@ Wstrict-prototypes
C ObjC Var(warn_strict_prototypes)
Warn about unprototyped function declarations
Wstrict-selector-match
ObjC ObjC++ Var(warn_strict_selector_match)
Warn if type signatures of candidate methods do not match exactly
Wsynth
C++ ObjC++ Var(warn_synth)
Warn when synthesis behavior differs from Cfront
@ -564,12 +572,29 @@ C++ ObjC++
fnonnull-objects
C++ ObjC++
; Generate special '- .cxx_construct' and '- .cxx_destruct' methods
; to initialize any non-POD ivars in Objective-C++ classes.
fobjc-call-cxx-cdtors
ObjC++ Var(flag_objc_call_cxx_cdtors)
Generate special Objective-C methods to initialize/destroy non-POD C++ ivars, if needed
fobjc-direct-dispatch
ObjC ObjC++ Var(flag_objc_direct_dispatch)
Allow fast jumps to the message dispatcher
; Nonzero means that we will allow new ObjC exception syntax (@throw,
; @try, etc.) in source code.
fobjc-exceptions
ObjC ObjC++
ObjC ObjC++ Var(flag_objc_exceptions)
Enable Objective-C exception and synchronization syntax
fobjc-gc
ObjC ObjC++ Var(flag_objc_gc)
Enable garbage collection (GC) in Objective-C/Objective-C++ programs
; Nonzero means that we generate NeXT setjmp based exceptions.
fobjc-sjlj-exceptions
ObjC ObjC++
ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)
Enable Objective-C setjmp exception handling runtime
foperator-names

View File

@ -533,7 +533,10 @@ Boston, MA 02111-1307, USA. */
machopic_validate_stub_or_non_lazy_ptr (xname); \
else if (len > 14 && !strcmp ("$non_lazy_ptr", xname + len - 13)) \
machopic_validate_stub_or_non_lazy_ptr (xname); \
fputs (&xname[1], FILE); \
if (xname[1] != '"' && name_needs_quotes (&xname[1])) \
fprintf (FILE, "\"%s\"", &xname[1]); \
else \
fputs (&xname[1], FILE); \
} \
else if (xname[0] == '+' || xname[0] == '-') \
fprintf (FILE, "\"%s\"", xname); \
@ -541,6 +544,8 @@ Boston, MA 02111-1307, USA. */
fprintf (FILE, "L%s", xname); \
else if (!strncmp (xname, ".objc_class_name_", 17)) \
fprintf (FILE, "%s", xname); \
else if (xname[0] != '"' && name_needs_quotes (xname)) \
fprintf (FILE, "\"%s\"", xname); \
else \
asm_fprintf (FILE, "%U%s", xname); \
} while (0)

View File

@ -407,3 +407,9 @@ do { \
references for data to the original instance of that data. */
#define TARGET_FIX_AND_CONTINUE (darwin_fix_and_continue)
/* This is the reserved direct dispatch address for Objective-C. */
#define OFFS_MSGSEND_FAST 0xFFFEFF00
/* This is the reserved ivar address Objective-C. */
#define OFFS_ASSIGNIVAR_FAST 0xFFFEFEC0

View File

@ -971,6 +971,8 @@ get_lang_number (void)
return N_SO_PASCAL;
else if (strcmp (language_string, "GNU Objective-C") == 0)
return N_SO_OBJC;
else if (strcmp (language_string, "GNU Objective-C++") == 0)
return N_SO_OBJCPLUS;
else
return 0;

View File

@ -197,11 +197,17 @@ Objective-C and Objective-C++ Dialects}.
-fconstant-string-class=@var{class-name} @gol
-fgnu-runtime -fnext-runtime @gol
-fno-nil-receivers @gol
-fobjc-call-cxx-cdtors @gol
-fobjc-direct-dispatch @gol
-fobjc-exceptions @gol
-fobjc-gc @gol
-freplace-objc-classes @gol
-fzero-link @gol
-gen-decls @gol
-Wno-protocol -Wselector -Wundeclared-selector}
-Wassign-intercept @gol
-Wno-protocol -Wselector @gol
-Wstrict-selector-match @gol
-Wundeclared-selector}
@item Language Independent Options
@xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
@ -816,6 +822,13 @@ C++ source code which must be preprocessed. Note that in @samp{.cxx},
the last two letters must both be literally @samp{x}. Likewise,
@samp{.C} refers to a literal capital C@.
@item @var{file}.mm
@itemx @var{file}.M
Objective-C++ source code which must be preprocessed.
@item @var{file}.mii
Objective-C++ source code which should not be preprocessed.
@item @var{file}.hh
@itemx @var{file}.H
C++ header file to be turned into a precompiled header.
@ -1897,6 +1910,35 @@ is not @code{nil}. This allows for more efficient entry points in the runtime
to be used. Currently, this option is only available in conjunction with
the NeXT runtime on Mac OS X 10.3 and later.
@item -fobjc-call-cxx-cdtors
@opindex fobjc-call-cxx-cdtors
For each Objective-C class, check if any of its instance variables is a
C++ object with a non-trivial default constructor. If so, synthesize a
special @code{- (id) .cxx_construct} instance method that will run
non-trivial default constructors on any such instance variables, in order,
and then return @code{self}. Similarly, check if any instance variable
is a C++ object with a non-trivial destructor, and if so, synthesize a
special @code{- (void) .cxx_destruct} method that will run
all such default destructors, in reverse order.
The @code{- (id) .cxx_construct} and/or @code{- (void) .cxx_destruct} methods
thusly generated will only operate on instance variables declared in the
current Objective-C class, and not those inherited from superclasses. It
is the responsibility of the Objective-C runtime to invoke all such methods
in an object's inheritance hierarchy. The @code{- (id) .cxx_construct} methods
will be invoked by the runtime immediately after a new object
instance is allocated; the @code{- (void) .cxx_destruct} methods will
be invoked immediately before the runtime deallocates an object instance.
As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has
support for invoking the @code{- (id) .cxx_construct} and
@code{- (void) .cxx_destruct} methods.
@item -fobjc-direct-dispatch
@opindex fobjc-direct-dispatch
Allow fast jumps to the message dispatcher. On Darwin this is
accompilished via the comm page.
@item -fobjc-exceptions
@opindex fobjc-exceptions
Enable syntactic support for structured exception handling in Objective-C,
@ -1989,6 +2031,10 @@ Unlike Java, Objective-C does not allow for entire methods to be marked
@code{@@synchronized} blocks is allowed, and will cause the guarding object
to be unlocked properly.
@item -fobjc-gc
@opindex fobjc-gc
Enable garbage collection (GC) in Objective-C and Objective-C++ programs.
@item -freplace-objc-classes
@opindex freplace-objc-classes
Emit a special marker instructing @command{ld(1)} not to statically link in
@ -2015,6 +2061,11 @@ for individual class implementations to be modified during program execution.
Dump interface declarations for all classes seen in the source file to a
file named @file{@var{sourcename}.decl}.
@item -Wassign-intercept
@opindex Wassign-intercept
Warn whenever an Objective-C assignment is being intercepted by the
garbage collector.
@item -Wno-protocol
@opindex Wno-protocol
If a class is declared to implement a protocol, a warning is issued for
@ -2038,6 +2089,15 @@ stage of compilation is not reached, for example because an error is
found during compilation, or because the @option{-fsyntax-only} option is
being used.
@item -Wstrict-selector-match
@opindex Wstrict-selector-match
Warn if multiple methods with differing argument and/or return types are
found for a given selector when attempting to send a message using this
selector to a receiver of type @code{id} or @code{Class}. When this flag
is off (which is the default behavior), the compiler will omit such warnings
if any differences found are confined to types which share the same size
and alignment.
@item -Wundeclared-selector
@opindex Wundeclared-selector
Warn if a @code{@@selector(@dots{})} expression referring to an

View File

@ -1238,6 +1238,15 @@ get_output_file_with_visibility (const char *input_file)
output_name = "gt-c-common.h", for_name = "c-common.c";
else if (strcmp (basename, "c-tree.h") == 0)
output_name = "gt-c-decl.h", for_name = "c-decl.c";
else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
&& strcmp (basename + 3, "cp-tree.h") == 0)
output_name = "gt-cp-tree.h", for_name = "cp/tree.c";
else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
&& strcmp (basename + 3, "decl.h") == 0)
output_name = "gt-cp-decl.h", for_name = "cp/decl.c";
else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
&& strcmp (basename + 3, "name-lookup.h") == 0)
output_name = "gt-cp-name-lookup.h", for_name = "cp/name-lookup.c";
else if (strncmp (basename, "objc", 4) == 0 && IS_DIR_SEPARATOR (basename[4])
&& strcmp (basename + 5, "objc-act.h") == 0)
output_name = "gt-objc-objc-act.h", for_name = "objc/objc-act.c";

View File

@ -70,6 +70,12 @@ objc_comptypes (tree ARG_UNUSED (lhs), tree ARG_UNUSED (rhs),
return -1;
}
tree
objc_rewrite_function_call (tree function, tree ARG_UNUSED (params))
{
return function;
}
tree
objc_message_selector (void)
{
@ -257,21 +263,22 @@ objc_is_public (tree ARG_UNUSED (expr), tree ARG_UNUSED (identifier))
}
tree
objc_get_class_ivars (tree ARG_UNUSED (class_name))
objc_get_class_ivars (tree ARG_UNUSED (name))
{
return 0;
}
tree
objc_build_throw_stmt (tree ARG_UNUSED (throw_expr))
objc_build_throw_stmt (tree ARG_UNUSED (expr))
{
return 0;
}
void
tree
objc_build_synchronized (location_t ARG_UNUSED (start_locus),
tree ARG_UNUSED (mutex), tree ARG_UNUSED (body))
{
return 0;
}
void
@ -295,7 +302,16 @@ objc_build_finally_clause (location_t ARG_UNUSED (finally_locus),
{
}
void
tree
objc_finish_try_stmt (void)
{
return 0;
}
tree
objc_generate_write_barrier (tree ARG_UNUSED (lhs),
enum tree_code ARG_UNUSED (modifycode),
tree ARG_UNUSED (rhs))
{
return 0;
}