gcc: Add support for Apple's Block extension

Block objects [1] are a C-level syntactic and runtime feature. They
are similar to standard C functions, but in addition to executable
code they may also contain variable bindings to automatic (stack)
or managed (heap) memory. A block can therefore maintain a set of
state (data) that it can use to impact behavior when executed.

This port is based on Apple's GCC 5646 with some bugfixes from
Apple GCC 5666.3. It has some small differences with the support
in clang, which remains the recommended compiler.

Perhaps the most notable difference is that in GCC that __block
is not actually a keyword, but a macro. There will be workaround
for this issue in a near future. Other issues can be consulted in
the clang documentation [2]

For better compatiblity with Apple's GCC and llvm-gcc some related
fixes and features from Apple have been included. Support for the
non-standard nested functions in GCC is now off by default.

No effort was made to update the ObjC support since FreeBSD doesn't
carry ObjC in the base system, but some of the code crept in and
was more difficult to remove than to adjust.

Reference:
[1]
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html
[2]
http://clang.llvm.org/compatibility.html#block-variable-initialization

Obtained from:	Apple GCC 4.2
MFC after:	3 weeks
This commit is contained in:
Pedro F. Giffuni 2014-01-05 00:43:28 +00:00
parent e1b3bb5380
commit 5bfc7db451
67 changed files with 10055 additions and 409 deletions

View File

@ -1,8 +1,908 @@
006-02-15 Fariborz Jahanian <fjahanian@apple.com>
2010-03-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 7760213
* c-common.h (HasByrefArray): New decl.
* c-common.c (HasByrefArray): New definition.
* c-typeck.c (build_external_ref): Diagnose access of
__block array.
2010-03-12 Jim Grosbach <grosbach@apple.com>
Radar 7744816
* expmed.c (synth_mult): Remove incorrect special case handling for
0xffffffff.
2010-03-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 7735196
* c-parser.c (build_block_struct_initlist):
Set BLOCK_USE_STRET flag in block descriptor for
blocks which return their aggregate value in memory.
* c-common.h (BLOCK_USE_STRET): New flag.
2010-03-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 7721728
* c-typeck.c (build_external_ref): Diagnose
importation of copied-in variables.
2009-03-12 Caroline Tice <ctice@apple.com>
Radar 6144634
* c-parser.c (c_parser_statement_after_labels): When
re-setting the expression location at the end, use the input
location for Block pointer assignments.
2009-02-11 Fariborz Jahanian <fjahanian@apple.com>
Radar 6573923
* c-decl.c (synth_block_byref_id_object_copy_func,
synth_block_byref_id_object_dispose_func): Set BLOCK_BYREF_CALLER
flag in call to copy/dispose helper functions.
* c-common.h (BLOCK_BYREF_CALLER): New flag.
2008-12-21 Caroline Tice <ctice@apple.com>
Radar 6455678
* cp/typeck.c (original_type): Stop if the type
and its DECL_ORIGINAL_TYPE are the same.
2008-12-18 Bill Wendling <wendling@apple.com>
Radar 6457359
* c-parser.c (build_block_struct_initlist): Changed type.
* cp/parser.c (build_block_struct_initlist): Ditto.
2008-12-02 Caroline Tice <ctice@apple.com>
Radar 6386976
* objcp/objcp-decl.h (TYPE_HAS_OBJCXX_INFO): New macro.
* objcp/objcp-lang.c (objcp-decl.h): New include statement, with
required define.
(LANG_HOOKS_IS_RUNTIME_SPECIFIC_TYPE): Redefine for
obj-c++.
(objcxx_is_runtime_type): New function.
2008-12-02 Fariborz Jahanian <fjahanian@apple.com>
Radar 6411649
* funciton.h: Added new field.
* c-common.c (build_block_helper_name): Produce a unique
block number per each enclosing function when building
the block helper function name.
2008-11-18 Stuart Hastings <stuart@apple.com>
Radar 6353006
* tree.c (generic_block_literal_struct_type): Fix APPLE LOCAL.
* langhooks-def.h (lhd_build_generic_block_struct_type): Fix
APPLE LOCAL.
2008-11-07 Fariborz Jahanian <fjahanian@apple.com>
Radar 5847976
* c-decl.c (synth_block_byref_id_object_copy_func): Takes a new
'flag' argument and generates the much simplified API.
(synth_block_byref_id_object_dispose_func): Ditto.
(new_block_byref_decl): Hack to prevent issuing bogus warning
on a field declared as __weak.
(init_byref_decl): Takes an additional 'flag' argument
and passes it down to synth_block_byref_id_object_copy_func and
synth_block_byref_id_object_dispose_func.
(finish_decl): Computes the flag for the block variable declaration.
* c-common.c (build_block_byref_release_decl,
build_block_byref_assign_copy_decl): Removed.
(build_block_byref_release_exp): Use the new API.
(build_block_object_assign_decl, build_block_object_assign_call_exp,
build_block_object_dispose_decl, build_block_object_dispose_call_exp): New.
(build_indirect_object_id_exp): Fixed a code gen bug which was exposed in
c/c++ mode, but not in ObjC/ObjC++ mode.
* c-common.h (build_block_object_assign_call_exp,
build_block_object_dispose_call_exp,
objc_is_gcable_type): New decls.
Declaration of several new flags.
(cast_to_pointer_to_id): Removed.
* stub-objc.c (objc_is_gcable_type): New
(copy_in_object, retain_block_component, release_block_component): Removed.
(cast_to_pointer_to_id): Removed.
* c-parser.c (build_block_struct_initlist): Remove call to copy_in_object.
(synth_copy_helper_block_func): Generates much simplified API.
(synth_destroy_helper_block_func): Ditto.
(block_object_dispose): Removed.
* config/darwin-c.c (darwin_cpp_builtins): Define __weak even when
-fobjc-gc is off.
2008-10-31 Fariborz Jahanian <fjahanian@apple.com>
Radar 6175959
* stub-objc.c (block_requires_copying): Object pointers with
NSObject attribute also require copy/release API.
* c-parser.c (synth_copy_helper_block_func): Use the new API
_Block_object_assign for ObjC object copying.
(block_object_dispose): New
(synth_destroy_helper_block_func): Call block_object_dispose
to use new _Block_object_dispose API for ObjC object release.
2008-10-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 6231433
* c-typeck.c (objc_compare_types, objc_have_common_type):
Take an extra argument for better diagnostics.
* c-common.c (objc_compare_types, objc_have_common_type):
Take extra argument.
* stub-objc.c: Ditto
2008-10-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 6305545
* cgraph.h (lower_if_nested_functions): New decl.
* tree-gimple.h (lower_nested_functions): Takes one more arg.
* cgraphunit.c (lower_if_nested_functions): New
* tree-nested.c (lower_nested_functions): Skip structors.
2008-10-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 5847213 (minor tweak)
* c-decl.c (build_block_descriptor_type):
Make descriptor_ptr_type and descriptor_ptr_type_with_copydispose
visible to pch.
2008-10-23 Caroline Tice <ctice@apple.com>
Radar 6300081
* tree.c(build_block_pointer_type): Add call to
build_generic_block_struct_type to initialize
generic_block_literal_struct_type if necessary.
* cp/parser.c (build_generic_block_struct_type): Update comments.
(build_block_struct_type): Remove call to
build_generic_block_struct_type.
(make_block_pointer_declarator): Likewise.
* c-decl.c (make_block_pointer_declarator): Likewise.
* c-parser.c (build_block_struct_type): Likewise.
(build_generic_block_struct_type): Update comments.
2008-10-22 Caroline Tice <ctice@apple.com>
Radar 6300081 & Radar 6163705
* tree.h (generic_block_literal_struct_type): Extern global variable
decl.
(build_generic_block_struct_type): New extern function decl.
* cp/parser (build_generic_block_struct_type): New function.
(build_block_struct_type): Call build_generic_block_struct_type
to initialize generic_block_literal_struct_type.
(make_block_pointer_declarator): Likewise.
(declare_block_prologue_local_vars): Temporarily set input_location
to 1 before the start of the block function; re-set input_location at
the end of this function.
* dwarf2out.c (add_type_attribute): If the type is a
BLOCK_POINTER_TYPE, assign it to be a pointer to a
generic_block_literal_struct_type.
* c-decl.c (make_block_pointer_declarator): Call
build_generic_block_struct_type to initialize
generic_block_literal_struct_type.
* c-common.c (generic_block_literal_struct_type): New global variable.
* c-parser.c (build_generic_block_struct_type): New function.
(build_block_struct_type): Call build_generic_block_struct_type
to initialize generic_block_literal_struct_type.
* testsuite/gcc.apple/block-debug-1.c: Fix test to work with new
compiler modifications.
* testsuite/gcc.apple/block-debug-2.c: Likewise.
* testsuite/g++.apple/block-debug-1.C: Likewise.
* testsuite/g++.apple/block-debug-2.C: Likewise.
2008-10-10 Fariborz Jahanian <fjahanian@apple.com>
Radar 5847213 - New Block ABI
* dwarf2out.c (add_type_attribute): Unusuable code
for radar 5811943 is removed.
* c-decl.c (build_block_byref_decl): Removed unneeded
build of block_original_byref_decl_list.
(build_block_internal_types): Removed.
(build_block_descriptor_type): New routine to build the descriptor type.
(make_block_pointer_declarator): Unused code is removed.
* c-typeck.c (build_block_call): New code gen for block calls.
* c-common.c (invoke_impl_ptr_type): Removed.
* c-common.h (block_original_byref_decl_list, build_block_internal_types): Removed
(build_block_descriptor_type, BLOCK_HAS_DESCRIPTOR): Decls added.
* c-parser.c (build_block_struct_type): Block literal expression internal type
is redeclared into its new layout.
(build_block_struct_initlist): Initializer list for above type is redone.
(build_descriptor_block_decl): New routine to declare the descriptor variable
(build_block_literal_tmp): Modified for the new type and initiazation.
2008-10-06 Fariborz Jahanian <fjahanian@apple.com>
Radar 6268817
* c-decl.c (check_for_loop_decls): Block helper function
is OK if declared in a for-loop main statement block.
2008-10-02 Fariborz Jahanian <fjahanian@apple.com>
Radar 6246527
* attribs.c (decl_attributes): Added support for adding attributes
on block pointer variable declarations.
* c-common.c (block_delta_format_args): Add
(any_recognized_block_attribute): Add
* c-common.h (any_recognized_block_attribute): New decl.
* c-parser.c (c_parser_block_literal_expr): Call to do the delta
on printf attribute.
2008-09-30 Fariborz Jahanian <fjahanian@apple.com>
Radar 6225809
* c-decl.c (build_block_byref_decl): Add __block vaiables
to intervening blocks.
2008-09-25 Fariborz Jahanian <fjahanian@apple.com>
Radar 6237713
* c-common.c (handle_noreturn_attribute): Add 'noreturn'
attribute to block pointer decls.
* c-parser.c (c_parser_block_literal_expr): Parse and set
attributes on block literals.
2008-09-25 Fariborz Jahanian <fjahanian@apple.com>
Radar 6244520 - minor addition
* c-common.c (build_indirect_object_id_exp): offset needs
be updated to accomodate addition of the new field.
2008-09-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 6214617
* c-common: New flag BLOCK_HAS_CXX_OBJ replaces BLOCK_NO_COPY.
(BlockImportsCxxObjects): New field replaces BlockHasByrefVar.
* c-parser.c (build_block_struct_type): Remove setting of
BLOCK_NO_COPY flag.
2008-09-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 6217257
* c-common.c (handle_blocks_attribute): Diagnose
vla __block declarations.
2008-09-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 6212722 (tweak)
* c-decl.c (build_block_ref_decl): Use array_to_pointer_conversion
and function_to_pointer_conversion.
* c-typeck.c (array_to_pointer_conversion, function_to_pointer_conversion):
Made them global.
* c-common.h (array_to_pointer_conversion, function_to_pointer_conversion):
Declare.
2008-09-09 Fariborz Jahanian <fjahanian@apple.com>
Radar 6169580
* c-commmon.c (build_block_helper_name): Fix bug in
block helper function name mangling.
2008-09-03 Fariborz Jahanian <fjahanian@apple.com>
Radar 6185344
* c-typeck.c (c_finish_return): Don't do block specific
stuff when block has a return type.
* c-common.h (block_sema_info): block_has_return_type is
a new field.
* c-parser.c (c_parser_direct_declarator): Terminate type
parsing for block return types.
(c_parser_block_literal_expr): Added support to parse and
handle explicit return type for blocks.
2008-08-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 6160536
* c-commmon.c (build_block_helper_name): New
* c-common.h (build_block_helper_name): New decl.
* c-parser.c (c_parser_block_literal_expr): Call
build_block_helper_name to build pretty helper function
name.
2008-08-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 6180456
* c-decl.c (synth_block_byref_id_object_copy_func): Different
API for copying __block declared objects in c.
(synth_block_byref_id_object_dispose_func): Different API
for releasing __block declared objects in c.
* c-common.c (block_byref_assign_copy_decl): New
(build_indirect_object_id_exp): Cast to 'id *' in objective-c
mode only.
* c-common.h (build_block_byref_assign_copy_decl): New decl.
* c-parser.c (synth_copy_helper_block_func): Refactored code
to call build_block_byref_assign_copy_decl().
2008-08-24 Caroline Tice <ctice@apple.com>
Radars 6144664, 6145471, 6144634
c-decl.c (build_block_byref_decl): Assign the source
location for each byref decl to the source location of
the helper function decl.
(build_block_ref_decl): Ditto for ref decls.
2008-08-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 5822844
* c-typeck.c (digest_init): Handler block as initializer.
(c_finish_return): check for completed block before
analyzing block's return expression.
* varasm.c (output_constant): Allow outputting block data.
* c-common.h (BLOCK_IS_GLOBAL): New flag.
(block_is_complete): New field in block data structure.
* c-parser.c (build_block_struct_initlist): New initializer and
flag for global block data.
(build_block_literal_tmp): Temporary data for global block is
declared as global static.
(c_parser_block_literal_expr): Removed diagnostics for global blocks.
Moved fixing helper function type earlier before its tree is built.
2008-08-06 Fariborz Jahanian <fjahanian@apple.com>
Radar 6014138
* c-decl.c (build_block_byref_decl): In the presence of nested "{"
move up the scope chain until reaching the main function body's scope.
2008-08-04 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305 - work in progress.
* c-decl.c (build_indirect_object_id_exp): Removed.
* c-common.c (build_indirect_object_id_exp): Added
* c-common.h (build_indirect_object_id_exp): New decl.
* config/darwin-c.c (darwin_cpp_builtins): Define __byref
in c++ mode as well.
2008-07-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 6083129 - twiked
* c-decl.c (release_all_local_byrefs_at_return): Do not release
imported __byref variables in the block.
* c-parser.c (gen_block_byref_release_exp): Do not release __byref
variables outside of the block when returning from the block.
2008-07-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 5988451
* c-decl.c (build_block_ref_decl): Insert copied in variable
in each enclosing block which does not use it.
(begin_block): Remove setting of "the_scope" field of the block.
(in_imm_block): Fix effect of changing the "the_scope" field.
(lookup_name_in_block): Do not skip over copied-in variables when
looking up a variable in the block.
* c-parser.c (c_parser_block_literal_expr): Set block's "the_scope" field
to the helper function's outer-most body scope.
2008-07-08 Fariborz Jahanian <fjahanian@apple.com>
Radar 6048570
* c-typeck.c (c_finish_return): Error on returning a block on the stack.
2008-06-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 5988995
* c-typeck.c (types_are_closure_compatible): Nested block pointer
types must be considered when matching block types.
2008-06-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 5982990
* c-parser.c (c_parser_objc_synch_compound_statement): New
(c_parser_objc_synchronized_statement): Call
c_parser_objc_synch_compound_statement.
2008-06-04 Fariborz Jahanian <fjahanian@apple.com>
Radar 5985368
* c-parser.c (c_parser_declaration_or_fndef): Better diagnostics for
a bad block definition.
2008-05-23 Fariborz Jahanian <fjahanian@apple.com>
Radar 5925781
* c-common.c (handle_nonnull_attribute): Support block pointer
just like a pointer for nonnull attribute.
(check_nonnull_arg): Ditto.
2008-05-20 Fariborz Jahanian <fjahanian@apple.com>
Radar 5932809 - minor change for runtime delight.
* c-parser.c (build_closure_struct_type): Add strcutor fields
for __byref 'id' object blocks as well.
(build_closure_struct_initlist): And their initializers.
2008-04-30 Caroline Tice <ctice@apple.com>
Radar 5811961
* c-decl.c: (declare_closure_prologue_local_vars): Set the source
location for the new decl expr statement to be the source location of
the decl tree.
2008-04-25 Fariborz Jahanian <fjahanian@apple.com>
Radar 5803005 (tweaked)
* c-typeck.c (build_external_ref): Refactored global decl checks.
2008-04-24 Caroline Tice <ctice@apple.com>
Radar 5811943
* tree.h (TYPE_CLOSURE_IMPL_STRUCT): New macro.
(lang_flag_2): Use previously unused field in tree_type to indicate
closure structs.
* dwarf2out.c (c-common.h): New include statement.
(dwarf_attr_name): Add case for DW_AT_APPLE_closure.
(gen_variable_die): Give pointers to closures the
invoke_impl_ptr_type.
(gen_struct_or_union_type_die): Add DW_AT_APPLE_closure
to structs that define closures.
* dwarf2.h (DW_AT_APPLE_closure): New Dwarf attribute.
* c-typeck.c (invoke_impl_ptr_type): Move declaration from here to
c-common.c
(build_closure_internal_types): Set TYPE_CLOSURE_IMPL_STRUCT
flag for closure structs.
* c-common.c (invoke_impl_ptr_type): Move declaration to here from
c-typeck.c.
2008-04-23 Fariborz Jahanian <fjahanian@apple.com>
Radar 5882266
* c-typeck.c (types_are_closure_compatible): Check for underlying
pointer types as well.
2008-04-15 Stuart Hastings <stuart@apple.com>
Radar 5862465
* tree.h (PTR_OR_REF_CHECK, POINTER_TYPE_P): Add
CLOSURE_POINTER_TYPE.
* fold-const.c (fold_convert): Add CLOSURE_POINTER_TYPE.
* testsuite/gcc.apple/closure-5862465.c: New.
2008-03-31 Fariborz Jahanian <fjahanian@apple.com>
Radar 5831855
* c-typeck.c (convert_for_assignment): Block and 'id' types
are interchangeable.
2008-03-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 5809099
* convert.c (convert_to_pointer): Allow typecast of closure
pointer to 'id'.
(convert_to_closure_pointer): Allow typecast of 'id'
of a closure pointer expression.
2008-03-25 Fariborz Jahanian <fjahanian@apple.com>
Radar 5811887 (minor change)
* c-opts.c (c_common_post_options): Remove conditional check
of pedantic when setting flag_blocks.
2008-03-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 5811887
* c-cppbuiltin.c: flag_closures renamed to flag_blocks
* c-parser.c: Ditto.
* c.opt: flag_closures renamed to flag_blocks. flag_blocks
defaulted to -1.
* c-opts.c (c_common_post_options): All flavors of c99, blocks are off by
default unless requested via -fblocks.
2008-03-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 5814025
* c-tree.h (make_closure_pointer_declarator): Takes
additional argument.
* c-decl.c (grokdeclarator): Get 'const'-ness of closure
pointer.
(make_closure_pointer_declarator): Takes additional argument for
const/volatile.
* c-parser.c (c_parser_declarator): Pass down attribute info.
to make_closure_pointer_declarator.
2008-03-20 Fariborz Jahanian <fjahanian@apple.com>
Radar 5802025
* c-common.h (objc_build_property_getter_func_call): New decl.
* stub-objc.c (objc_build_property_getter_func_call): New stub.
2008-03-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 5803600
* c-decl.c (add_closure_global_byref_list,
in_closure_global_byref_list): New defs.
* c-common.h (add_closure_global_byref_list,
in_closure_global_byref_list): New decls.
* c-typeck.c (build_external_ref): global variables
declared as 'byref' are enterred in their own list
of such declarations per each closure.
* c-parser.c (c_parser_postfix_expression): Remove previous fix.
(c_parser_closure_byref_declaration): Check for global
'byref' by calling in_closure_global_byref_list.
2008-03-13 Fariborz Jahanian <fjahanian@apple.com>
Radar 5795493
* c-typeck.c: Renamed typesAreClosureCompatible to
types_are_closure_compatible.
2008-03-11 Fariborz Jahanian <fjahanian@apple.com>
Radar 5732232 (Related to change of command option/macro)
* c-cppbuiltin.c: __CLOSURES__ macro rename __BLOCKS__
* c.opt: -fclosures change to -fblocks.
2008-03-10 Fariborz Jahanian <fjahanian@apple.com>
Radar 5782740 - part 2 (bug fix).
* c-parser.c (synth_copy_helper_closure,
synth_destroy_helper_closure): set DECL_ARG_TYPE field of input
arguments for the two synthesized helper functions.
2008-02-21 Caroline Tice <ctice@apple.com>
Radar 5741070
* objc/objc-act.c (objc_finish_message_expr): Find
the record-type tree from the class interface, and mark the record
type as used, for emitting debug info.
* cp/cp-objcp-common.c (c_return_interface_record_type): New function.
* cp/cp-tree.h (c_return_interface_record_type): New extern function
declaration.
* c-tree.h (c_return_interface_record_type): Likewise
* c-decl.c (c_return_interface_record_type): New function.
2007-08-22 Fariborz Jahanian <fjahanian@apple.com>
Radar 4947311
* c-common.h (objc_declare_protocols, objc_start_protocol): Decl changed.
* stub-objc.c (objc_declare_protocols, objc_start_protocol): Changed.
* c-parser.c (c_parser_external_declaration): Call to
c_parser_objc_protocol_definition takes additional argument.
(c_parser_declaration_or_fndef): Protocols with attributes are processed
here by passing it to c_parser_objc_protocol_definition.
(c_parser_objc_protocol_definition): Takes additional argument and passes
it to objc_declare_protocols or objc_start_protocol.
2007-07-13 Fariborz Jahanian <fjahanian@apple.com>
Radar 5277239
* c-parser.c (c_parser_next_token_starts_declspecs): Exclude
objc2's property dot-syntax as a declarator.
(c_parser_postfix_expression): Convert property dot-syntax on
class objects into a property reference expression.
2007-07-10 Fariborz Jahanian <fjahanian@apple.com>
Radar 5285911
* tree.h (CALL_EXPR_OBJC_PROPERTY_GETTER): Macro removed.
* c-typeck.c (build_component_ref): Call
objc_build_property_reference_expr instead of objc_build_getter_call.
(build_modify_expr): Call objc_property_reference_expr instead of
objc_property_call.
* c-common.h (objc_build_getter_call, objc_property_call): Decl removed.
(objc_build_property_reference_expr, objc_property_reference_expr): Decl.
added.
* stub-objc.c (objc_build_getter_call, objc_property_call): Stub removed.
(objc_build_property_reference_expr, objc_property_reference_expr):
Stub added.
2007-06-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 5276085
* c-parser.c (c_parser_binary_expression) : objc_generate_weak_read
replaced with call to objc_build_weak_reference_tree
* c-typeck.c (build_modify_expr, c_objc_common_truthvalue_conversion):
objc_remove_weak_read replaced with call to objc_weak_reference_expr.
* c-common.h (objc_weak_reference_expr,
objc_build_weak_reference_tree) : New decl.
(objc_generate_weak_read, objc_remove_weak_read): remove.
* stub-objc.c (objc_weak_reference_expr,
objc_build_weak_reference_tree): New stub.
(objc_generate_weak_read, objc_remove_weak_read): remove.
2007-05-23 Fariborz Jahanian <fjahanian@apple.com>
Radar 5195402
* c-format.c (handle_format_arg_attribute): Check for NSString *
and CFStringRef as valid formatting types.
(check_format_string): Ditto.
* c-common.h (objc_check_format_nsstring,
objc_check_cfstringref_type): New decls.
* stub-objc.c (objc_check_nsstring_pointer_type): New stub.
* config/darwin-c.c (objc_check_cfstringref_type): New
(objc_check_format_cfstring): Call objc_check_cfstringref_type
for valid CFStringRef argument type.
* config/darwin-protos.h (objc_check_cfstringref_type): New decl.
* config/darwin.h (CFSTRING_TYPE_CHECK): New macro.
2007-05-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 5202926
* c-common.h (objc_anonymous_local_objc_name): New decl.
* config/darwin-protos.h (objc_anonymous_local_objc_name): Decl.
* stub-objc.c (objc_anonymous_local_objc_name): New stub.
* config/darwin.h (ASM_OUTPUT_LABELREF) Call
objc_anonymous_local_objc_name.
2007-05-07 Fariborz Jahanian <fjahanian@apple.com>
Radar 4157812
* c-common.h (objc_build_keyword_decl): Takes a new argument.
* stub-objc.c (objc_build_keyword_decl): Ditto.
* c-parser.c (c_parser_objc_method_decl): Recognize optional
method's argument attribute.
(c_parser_objc_method_decl): Handle errornous selector.
2007-05-02 Fariborz Jahanian <fjahanian@apple.com>
Radar 4502186
* c-typeck.c (convert_for_assignment): Remove synthesized 'volatile'
type before doing type comparison.
2007-03-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 4564694
* c-parse.c (c_parser_objc_class_instance_variables): Add @package
support to syntax.
* c-common.h (RID_AT_PACKAGE): Add
2007-03-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 4947014 - objc atomic property
* c-common.h (RID_NONATOMIC): Add
* c-parse.c (c_parser_objc_property_attribute) : Recognize 'nonatomic'
as new property.
2007-03-23 Fariborz Jahanian <fjahanian@apple.com>
Radar 4985544
* c-format.c (enum format_type): New entry for NSString format.
(format_typ): Has a new entry for NSString format.
(decode_format_attr): Error on use of NSString format on a
non-objective-c program.
(objc_check_nsformat_arg): New.
(check_format_info): Call back for NSString is objc_check_nsformat_arg
(handle_format_attribute): Use objc_check_format_nsstring for
NSString format.
* c-common.h (objc_NSString_format): New decl.
(objc_check_format_nsstring): New decl.
* stub-objc.c (objc_NSString_format, objc_check_format_nsstring): New
stubs.
* config/darwin-protos.h (darwin_cfstring_type_node): New decl.
* config/darwin.c (darwin_cfstring_type_node): New
* config/darwin.h (TARGET_CFSTRING_P): New macro
2007-03-23 Fariborz Jahanian <fjahanian@apple.com>
Radar 4985544
* c-format.c (enum format_type): New entry for NSString format.
(format_typ): Has a new entry for NSString format.
(decode_format_attr): Error on use of NSString format on a
non-objective-c program.
(objc_check_nsformat_arg): New.
(check_format_info): Call back for NSString is objc_check_nsformat_arg
(handle_format_attribute): Use objc_check_format_nsstring for
NSString format.
* c-common.h (objc_NSString_format): New decl.
(objc_check_format_nsstring): New decl.
* stub-objc.c (objc_NSString_format, objc_check_format_nsstring): New
stubs.
* config/darwin-protos.h (darwin_cfstring_type_node): New decl.
* config/darwin.c (darwin_cfstring_type_node): New
* config/darwin.h (TARGET_CFSTRING_P): New macro
2007-03-22 Fariborz Jahanian <fjahanian@apple.com>
Radar 4965989
* c-parser.c (c_parser_objc_class_definition): Add supprt for anonymous
category syntax.
2007-03-21 Fariborz Jahanian <fjahanian@apple.com>
Radar 2848255
* c-parser.c (c_parser_objc_try_catch_statement): Parse @catch(...).
* c.opt: Add -fobjc-zerocost-exceptions option.
* c-opts.c (c_common_post_options): Set the flags for
-fobjc-zerocost-exceptions.
* c-common.h: Add some declarations.
* stub-objc.c (objc2_valid_objc_catch_type, objc2_build_throw_call):
New stubs.
* config/darwin.h (OBJC_FLAG_OBJC_ABI): Check for proper
use of -fobjc-zerocost-exceptions option.
2006-11-06 Fariborz Jahanian <fjahania@apple.com>
Radar 4781080 (part 2)
* targhooks.c (default_objc_fpreturn_msgcall): Takes 2nd argument.
* targhooks.h (default_objc_fpreturn_msgcall): Changed Decl.
* target.h (objc_fpreturn_msgcall): Changed Decl.
* config/i386/i386.h (OBJC_FPRETURN_MSGCALL): Changed Decl.
* config/i386/i386-protos.h (ix86_objc_fpreturn_msgcall): Changed Decl.
* config/i386/i386.c (ix86_objc_fpreturn_msgcall): Changed definition.
2006-09-15 Fariborz Jahanian <fjahania@apple.com>
Radar 4727659
* c-common.c (handle_noreturn_attribute): Handle method_decl
nodes as well.
2006-09-01 Fariborz Jahanian <fjahania@apple.com>
Radar 4712269
* c-common.h (objc_build_incr_decr_setter_call): New decl.
* stub-objc.c (objc_build_incr_decr_setter_call): New stub.
* c-typeck.c (build_unary_op): Call objc_build_incr_decr_setter_call
for potential ince/decr pre/post expressions involving properties.
2006-08-31 Fariborz Jahanian <fjahanian@apple.com>
Radar 4697411
* c-common.h (objc_volatilize_component_ref): New decl.
* c-typeck.c (build_component_ref): Call objc_volatilize_component_ref.
* stub-objc.c (objc_volatilize_component_ref): New stub.
2006-07-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 4592503
* c-decl.c (finish_struct): Check on illegal use of __weak
on struct fields.
* decl.c (start_decl): Check on illegal use of __weak on
variable declarations.
* stub-objc.c (objc_checkon_weak_attribute): New stub.
* c-common.h (objc_checkon_weak_attribute): New decl.
2006-06-26 Fariborz Jahanian <fjahanian@apple.com>
Radar 4591909
* c-parse.in: New/modified grammar for new attributes in
properties.
(yylexname): Change to recognize new attribute terminals.
* c-common.h (RID_DYNAMIC): New enum declaration.
2006-07-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 4621020
* c-parse.in: Added 'weak' attribute keyword for @property.
* c-common.h: 'weak' related declarations.
2006-05-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 4548636 (objc attributes on class)
* c-parse.in: Add attribute non-terminal before
AT_INTERFACE.
* c-common.h (objc_start_class_interface): New argument added.
* stub-objc.c (objc_start_class_interface): Ditto.
2006-05-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 4547045
* c-gimplify.c (obj_reuse_bc_block): Removed.
(objc_pop_label, objc_push_label): New.
(gimplify_c_loop): Fix up foreach's innerloop break label.
2006-04-26 Fariborz Jahanian <fjahanian@apple.com>
Radar 3803157 (method attributes)
* c-parse.in: Add grammar support for declaring
attribute for objc methods.
* c-common.c (handle_deprecated_attribute): Recognize
objc methods as valid declarations.
(handle_unavailable_attribute): Ditto.
* c-common.h: Bunch of new extern declarations.
* stub-objc.c (objc_add_method_declaration, objc_start_method_definition):
Added new argument.
(objc_method_decl): New stub.
2006-04-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 4507230
* c-common.h (objc_type_valid_for_messaging): Declare.
* stub-objc.c (objc_type_valid_for_messaging): New stub.
2006-04-06 Fariborz Jahanian <fjahanian@apple.com>
Radar 4436866
(Missing copies attribute)
* c-parse.in: Add grammer for 'copies' attribute.
* c-common.h (RID_COPIES): New enumerator.
2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 4133425
* c-common.h (objc_diagnose_private_ivar): New decl.
* stub-objc.c (objc_diagnose_private_ivar): New stub.
* c-decl.c (undeclared_variable): Issue disnostic on
private 'ivar' access.
2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 4491608
* c-typeck.c (convert_arguments): function name must come from 'selector'
when diagnosing 'too many arguments'.
2006-03-23 Fariborz Jahanian <fjahanian@apple.com>
Radar 4193359
* c-typeck.c (convert_for_assignment): Remove Objective-C EH machinery
'volatile' qualifier before doing type comparison.
2006-02-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 4441049
* c-common.h (objc_v2_bitfield_ivar_bitpos): New decl.
* expr.h (objc_v2_bitfield_ivar_bitpos): New decl.
* stub-objc.c (objc_v2_bitfield_ivar_bitpos): New stub.
* expr.c (get_inner_reference): Compute ivar's bitfield bit offset.
2006-02-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4445586
* c-common.def (DO_STMT): Takes an extra argument.
2006-02-02 Fariborz Jahanian <fjahanian@apple.com>
Radar 4426814
* c-parse.in (cast_expr): generate objc_read_weak call on
each __weak object in the expession.
* c-typeck.c (build_modify_expr): Undo the call to objc_read_weak
on LHS expression.
* c-objc-common.c (c_objc_common_truthvalue_conversion): Generate
objc_read_weak call before generating tree for !exp, etc.
* c-common.h (objc_generate_weak_read, objc_remove_weak_read): New decl.
* stub-objc.c (objc_generate_weak_read, objc_remove_weak_read): New stubs.
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* c-typeck.c (build_conditional_expr): Call objc_have_common_type when
looking for objective-c common pointer types.
* c-common.h objc_have_common_type): New declaration.
* stub-objc.c (objc_have_common_type): New stub.
2005-12-05 Mike Stump <mrs@apple.com>
Radar 4357979
* doc/invoke.texi (C Dialect Options): Improve -fnested-functions wording.
* doc/extend.texi (Nested Functions): Note that on darwin nested
functions are off by default.
2005-11-08 Fariborz Jahanian <fjahanian@apple.com>
Radar 4330422
* c-common.h (objc_non_volatilized_type): New declaration
* stub-objc.c (objc_non_volatilized_type): New stub.
2005-10-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 4291785
* c-common.h (objc_get_interface_ivars): New declaration
(objc_detect_field_duplicates): Ditto.
* c-decl.c (finish_struct): Check for duplicate among
flattened fields if objective-c.
* stub-objc.c (objc_get_interface_ivars): New stub.
(objc_detect_field_duplicates): Ditto.
2005-09-28 Devang Patel <dpatel@apple.com>
Radar 4258406
* c-parse.in (nested_function): Report an error, instead of a warning.
(nontype_nested_function): Same.
* c.opt (Wnested-funcs): Remove.
* doc/invoke.texi: Remove Wnested-funcs documentations.
2005-08-03 Fariborz Jahanian <fjahanian@apple.com>
Radar 4188876
* c-typeck.c (pop_init_level): Issue diagnostic on non-constant
vector initializers.
2005-06-22 Ziemowit Laski <zlaski@apple.com>
Radar 4154928
* c-common.h (objc_common_type): New prototype.
* c-typeck.c (build_conditional_expr): For two ObjC pointer types,
use their ObjC common type.
* stub-objc.c (objc_common_type): New stub.
/* APPLE LOCAL merge marger */
/* Stuff under is in fsf mainline, but not in the 4.2 branch */

View File

@ -216,7 +216,8 @@ decl_attributes (tree *node, tree attributes, int flags)
if (spec->function_type_required && TREE_CODE (*anode) != FUNCTION_TYPE
&& TREE_CODE (*anode) != METHOD_TYPE)
{
if (TREE_CODE (*anode) == POINTER_TYPE
/* APPLE LOCAL radar 6246527 */
if ((TREE_CODE (*anode) == POINTER_TYPE || TREE_CODE (*anode) == BLOCK_POINTER_TYPE)
&& (TREE_CODE (TREE_TYPE (*anode)) == FUNCTION_TYPE
|| TREE_CODE (TREE_TYPE (*anode)) == METHOD_TYPE))
{
@ -323,6 +324,14 @@ decl_attributes (tree *node, tree attributes, int flags)
if (fn_ptr_tmp)
{
/* APPLE LOCAL begin radar 6246527 */
if (DECL_P (*node) && TREE_TYPE (*node) &&
TREE_CODE (TREE_TYPE (*node)) == BLOCK_POINTER_TYPE)
/* Rebuild the block pointer type and put it in the
appropriate place. */
fn_ptr_tmp = build_block_pointer_type (fn_ptr_tmp);
else
/* APPLE LOCAL end radar 6246527 */
/* Rebuild the function pointer type and put it in the
appropriate place. */
fn_ptr_tmp = build_pointer_type (fn_ptr_tmp);

View File

@ -552,6 +552,8 @@ static tree handle_cleanup_attribute (tree *, tree, tree, int, bool *);
static tree handle_warn_unused_result_attribute (tree *, tree, tree, int,
bool *);
static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
/* APPLE LOCAL radar 5932809 - copyable byref blocks */
static tree handle_blocks_attribute (tree *, tree, tree, int, bool *);
static void check_function_nonnull (tree, tree);
static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
@ -607,7 +609,8 @@ const struct attribute_spec c_common_attribute_table[] =
handle_section_attribute },
{ "aligned", 0, 1, false, false, false,
handle_aligned_attribute },
{ "weak", 0, 0, true, false, false,
/* APPLE LOCAL weak types 5954418 */
{ "weak", 0, 0, false, false, false,
handle_weak_attribute },
{ "alias", 1, 1, true, false, false,
handle_alias_attribute },
@ -650,6 +653,8 @@ const struct attribute_spec c_common_attribute_table[] =
handle_warn_unused_result_attribute },
{ "sentinel", 0, 1, false, true, true,
handle_sentinel_attribute },
/* APPLE LOCAL radar 5932809 - copyable byref blocks */
{ "blocks", 1, 1, true, false, false, handle_blocks_attribute },
{ NULL, 0, 0, false, false, false, NULL }
};
@ -4259,7 +4264,10 @@ handle_noreturn_attribute (tree *node, tree name, tree ARG_UNUSED (args),
tree type = TREE_TYPE (*node);
/* See FIXME comment in c_common_attribute_table. */
if (TREE_CODE (*node) == FUNCTION_DECL)
/* APPLE LOCAL begin radar 4727659 */
if (TREE_CODE (*node) == FUNCTION_DECL
|| objc_method_decl (TREE_CODE (*node)))
/* APPLE LOCAL end radar 4727659 */
TREE_THIS_VOLATILE (*node) = 1;
else if (TREE_CODE (type) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
@ -4267,6 +4275,14 @@ handle_noreturn_attribute (tree *node, tree name, tree ARG_UNUSED (args),
= build_pointer_type
(build_type_variant (TREE_TYPE (type),
TYPE_READONLY (TREE_TYPE (type)), 1));
/* APPLE LOCAL begin radar 6237713 */
else if (TREE_CODE (type) == BLOCK_POINTER_TYPE
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
TREE_TYPE (*node)
= build_block_pointer_type
(build_type_variant (TREE_TYPE (type),
TYPE_READONLY (TREE_TYPE (type)), 1));
/* APPLE LOCAL end radar 6237713 */
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
@ -4893,6 +4909,23 @@ handle_weak_attribute (tree *node, tree name,
if (TREE_CODE (*node) == FUNCTION_DECL
|| TREE_CODE (*node) == VAR_DECL)
declare_weak (*node);
/* APPLE LOCAL begin weak types 5954418 */
else if (!DECL_P (*node)
/* If the weak flag can be associated with something else,
prefer that. */
&& (flags & (ATTR_FLAG_FUNCTION_NEXT
|ATTR_FLAG_DECL_NEXT
|ATTR_FLAG_ARRAY_NEXT)))
{
*no_add_attrs = true;
return tree_cons (name, args, NULL_TREE);
}
else if (! targetm.cxx.class_data_always_comdat ()
&& TREE_CODE (*node) == RECORD_TYPE)
{
/* Leave on the type for the C++ front end */
}
/* APPLE LOCAL end weak types 5954418 */
else
warning (OPT_Wattributes, "%qE attribute ignored", name);
@ -5381,8 +5414,10 @@ handle_unavailable_attribute (tree *node, tree name,
|| TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == FUNCTION_DECL
|| TREE_CODE (decl) == FIELD_DECL)
/* Removed radar 3803157 - objc attribute */
/* APPLE LOCAL begin radar 3803157 - objc attribute */
|| TREE_CODE (decl) == FIELD_DECL
|| objc_method_decl (TREE_CODE (decl)))
/* APPLE LOCAL end radar 3803157 - objc attribute */
{
TREE_UNAVAILABLE (decl) = 1;
}
@ -5558,7 +5593,10 @@ handle_nonnull_attribute (tree *node, tree ARG_UNUSED (name),
return NULL_TREE;
}
if (TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE)
/* APPLE LOCAL begin blocks 5925781 */
if (TREE_CODE (TREE_VALUE (argument)) != POINTER_TYPE &&
TREE_CODE (TREE_VALUE (argument)) != BLOCK_POINTER_TYPE)
/* APPLE LOCAL end blocks 5925781 */
{
error ("nonnull argument references non-pointer operand (argument %lu, operand %lu)",
(unsigned long) attr_arg_num, (unsigned long) arg_num);
@ -5705,8 +5743,11 @@ check_nonnull_arg (void * ARG_UNUSED (ctx), tree param,
happen if the "nonnull" attribute was given without an operand
list (which means to check every pointer argument). */
if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE)
return;
/* APPLE LOCAL begin blocks 5925781 */
if (TREE_CODE (TREE_TYPE (param)) != POINTER_TYPE &&
TREE_CODE (TREE_TYPE (param)) != BLOCK_POINTER_TYPE)
/* APPLE LOCAL end blocks 5925781 */
return;
if (integer_zerop (param))
warning (OPT_Wnonnull, "null argument where non-null required "
@ -5809,6 +5850,168 @@ handle_warn_unused_result_attribute (tree *node, tree name,
return NULL_TREE;
}
/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
/* Handle "blocks" attribute. */
static tree
handle_blocks_attribute (tree *node, tree name,
tree args,
int ARG_UNUSED (flags), bool *no_add_attrs)
{
tree arg_ident;
/* APPLE LOCAL radar 6217257 */
tree type;
*no_add_attrs = true;
if (!(*node) || TREE_CODE (*node) != VAR_DECL)
{
error ("__block attribute can be specified on variables only");
return NULL_TREE;
}
arg_ident = TREE_VALUE (args);
gcc_assert (TREE_CODE (arg_ident) == IDENTIFIER_NODE);
/* APPLE LOCAL radar 6096219 */
if (strcmp (IDENTIFIER_POINTER (arg_ident), "byref"))
{
/* APPLE LOCAL radar 6096219 */
warning (OPT_Wattributes, "Only \"byref\" is allowed - %qE attribute ignored",
name);
return NULL_TREE;
}
/* APPLE LOCAL begin radar 6217257 */
type = TREE_TYPE (*node);
if (TREE_CODE (type) == ERROR_MARK)
return NULL_TREE;
if (TREE_CODE (type) == ARRAY_TYPE)
{
if (!TYPE_SIZE (type) || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
{
error ("__block not allowed on a variable length array declaration");
return NULL_TREE;
}
}
/* APPLE LOCAL end radar 6217257 */
COPYABLE_BYREF_LOCAL_VAR (*node) = 1;
COPYABLE_BYREF_LOCAL_NONPOD (*node) = block_requires_copying (*node);
return NULL_TREE;
}
/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
/* APPLE LOCAL begin blocks 6040305 */
/* This routine builds:
*(void **)(EXP+20) expression which references the object pointer.
*/
tree
build_indirect_object_id_exp (tree exp)
{
tree dst_obj;
int int_size = int_cst_value (TYPE_SIZE_UNIT (unsigned_type_node));
int offset;
/* dst->object In thid case 'object' is the field
of the object passed offset by: void * + void* + int + int + void* + void *
This must match definition of Block_byref structs. */
/* APPLE LOCAL radar 6244520 */
offset = GET_MODE_SIZE (Pmode) + GET_MODE_SIZE (Pmode)
+ int_size + int_size + GET_MODE_SIZE (Pmode) +
GET_MODE_SIZE (Pmode);
dst_obj = build2 (PLUS_EXPR, ptr_type_node, exp,
build_int_cst (NULL_TREE, offset));
/* APPLE LOCAL begin radar 6180456 */
/* Type case to: 'void **' */
dst_obj = build_c_cast (build_pointer_type (ptr_type_node), dst_obj);
dst_obj = build_indirect_ref (dst_obj, "unary *");
/* APPLE LOCAL end radar 6180456 */
return dst_obj;
}
/* This routine builds call to:
_Block_object_dispose(VAR_DECL.__forwarding, BLOCK_FIELD_IS_BYREF);
and adds it to the statement list.
*/
tree
build_block_byref_release_exp (tree var_decl)
{
tree exp = var_decl, call_exp;
tree type = TREE_TYPE (var_decl);
/* __block variables imported into Blocks are not _Block_object_dispose()
from within the Block statement itself; otherwise, each envokation of
the block causes a release. Make sure to release __block variables declared
and used locally in the block though. */
if (cur_block
&& (BLOCK_DECL_COPIED (var_decl) || BLOCK_DECL_BYREF (var_decl)))
return NULL_TREE;
if (BLOCK_DECL_BYREF (var_decl)) {
/* This is a "struct Block_byref_X *" type. Get its pointee. */
gcc_assert (POINTER_TYPE_P (type));
type = TREE_TYPE (type);
exp = build_indirect_ref (exp, "unary *");
}
TREE_USED (var_decl) = 1;
/* Declare: _Block_object_dispose(void*, BLOCK_FIELD_IS_BYREF) if not done already. */
exp = build_component_ref (exp, get_identifier ("__forwarding"));
call_exp = build_block_object_dispose_call_exp (exp, BLOCK_FIELD_IS_BYREF);
return call_exp;
}
/* APPLE LOCAL end blocks 6040305 */
/* APPLE LOCAL begin radar 5803600 */
/** add_block_global_byref_list - Adds global variable decl to the list of
byref global declarations in the current block.
*/
void add_block_global_byref_list (tree decl)
{
cur_block->block_byref_global_decl_list =
tree_cons (NULL_TREE, decl, cur_block->block_byref_global_decl_list);
}
/** in_block_global_byref_list - returns TRUE if global variable is
in the list of 'byref' declarations.
*/
bool in_block_global_byref_list (tree decl)
{
tree chain;
if (TREE_STATIC (decl)) {
for (chain = cur_block->block_byref_global_decl_list; chain;
chain = TREE_CHAIN (chain))
if (TREE_VALUE (chain) == decl)
return true;
}
return false;
}
/* APPLE LOCAL end radar 5803600 */
/* APPLE LOCAL begin radar 6160536 */
tree
build_block_helper_name (int unique_count)
{
char *buf;
if (!current_function_decl)
{
/* APPLE LOCAL begin radar 6411649 */
static int global_count;
buf = (char *)alloca (32);
sprintf (buf, "__block_global_%d", ++global_count);
/* APPLE LOCAL end radar 6411649 */
}
else
{
tree outer_decl = current_function_decl;
/* APPLE LOCAL begin radar 6169580 */
while (outer_decl &&
DECL_CONTEXT (outer_decl) && TREE_CODE (DECL_CONTEXT (outer_decl)) == FUNCTION_DECL)
/* APPLE LOCAL end radar 6169580 */
outer_decl = DECL_CONTEXT (outer_decl);
/* APPLE LOCAL begin radar 6411649 */
if (!unique_count)
unique_count = ++DECL_STRUCT_FUNCTION(outer_decl)->unqiue_block_number;
/* APPLE LOCAL end radar 6411649 */
buf = (char *)alloca (IDENTIFIER_LENGTH (DECL_NAME (outer_decl)) + 32);
sprintf (buf, "__%s_block_invoke_%d",
IDENTIFIER_POINTER (DECL_NAME (outer_decl)), unique_count);
}
return get_identifier (buf);
}
/* APPLE LOCAL end radar 6160536 */
/* Handle a "sentinel" attribute. */
static tree
@ -6725,5 +6928,147 @@ warn_about_parentheses (enum tree_code code, enum tree_code code_left,
"have their mathematical meaning");
}
/* APPLE LOCAL begin radar 6246527 */
/* This routine is called for a "format" attribute. It adds the number of
hidden argument ('1') to the format's 2nd and 3rd argument to compensate
for these two arguments. This is to make rest of the "format" attribute
processing done in the middle-end to work seemlessly. */
static void
block_delta_format_args (tree format)
{
tree format_num_expr, first_arg_num_expr;
int val;
tree args = TREE_VALUE (format);
gcc_assert (TREE_CHAIN (args) && TREE_CHAIN (TREE_CHAIN (args)));
format_num_expr = TREE_VALUE (TREE_CHAIN (args));
first_arg_num_expr = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args)));
if (format_num_expr && TREE_CODE (format_num_expr) == INTEGER_CST)
{
val = TREE_INT_CST_LOW (format_num_expr);
TREE_VALUE (TREE_CHAIN (args)) = build_int_cst (NULL_TREE, val+1);
}
if (first_arg_num_expr && TREE_CODE (first_arg_num_expr) == INTEGER_CST)
{
val = TREE_INT_CST_LOW (first_arg_num_expr);
if (val != 0)
TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args))) =
build_int_cst (NULL_TREE, val+1);
}
}
/* This routine recognizes legal block attributes. In case of block's "format"
attribute, it calls block_delta_format_args to compensate for hidden
argument _self getting passed to block's helper function. */
bool
any_recognized_block_attribute (tree attributes)
{
tree chain;
bool res = false;
for (chain = attributes; chain; chain = TREE_CHAIN (chain))
{
if (is_attribute_p ("format", TREE_PURPOSE (chain)))
{
block_delta_format_args (chain);
res = true;
}
else if (is_attribute_p ("sentinel", TREE_PURPOSE (chain)))
res = true;
}
return res;
}
/* APPLE LOCAL end radar 6246527 */
/* APPLE LOCAL begin radar 5847976 */
static GTY(()) tree block_object_assign_decl;
static GTY(()) tree block_object_dispose_func_decl;
/* This routine declares:
void _Block_object_assign (void *, void *, int) or uses an
existing one.
*/
static tree
build_block_object_assign_decl (void)
{
tree func_type;
if (block_object_assign_decl)
return block_object_assign_decl;
block_object_assign_decl = lookup_name (get_identifier ("_Block_object_assign"));
if (block_object_assign_decl)
return block_object_assign_decl;
func_type =
build_function_type (void_type_node,
tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, integer_type_node, void_list_node))));
block_object_assign_decl = builtin_function ("_Block_object_assign", func_type,
0, NOT_BUILT_IN, 0, NULL_TREE);
TREE_NOTHROW (block_object_assign_decl) = 0;
return block_object_assign_decl;
}
/* This routine builds:
_Block_object_assign(dest, src, flag)
*/
tree build_block_object_assign_call_exp (tree dst, tree src, int flag)
{
tree func_params = tree_cons (NULL_TREE, dst,
tree_cons (NULL_TREE, src,
tree_cons (NULL_TREE,
build_int_cst (integer_type_node, flag),
NULL_TREE)));
return build_function_call (build_block_object_assign_decl (), func_params);
}
/* This routine declares:
void _Block_object_dispose (void *, int) or uses an
existing one.
*/
static tree
build_block_object_dispose_decl (void)
{
tree func_type;
if (block_object_dispose_func_decl)
return block_object_dispose_func_decl;
block_object_dispose_func_decl = lookup_name (get_identifier ("_Block_object_dispose"));
if (block_object_dispose_func_decl)
return block_object_dispose_func_decl;
func_type =
build_function_type (void_type_node,
tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, integer_type_node, void_list_node)));
block_object_dispose_func_decl = builtin_function ("_Block_object_dispose", func_type,
0, NOT_BUILT_IN, 0, NULL_TREE);
TREE_NOTHROW (block_object_dispose_func_decl) = 0;
return block_object_dispose_func_decl;
}
/* This routine builds the call tree:
_Block_object_dispose(src, flag)
*/
tree build_block_object_dispose_call_exp (tree src, int flag)
{
tree func_params = tree_cons (NULL_TREE, src,
tree_cons (NULL_TREE,
build_int_cst (integer_type_node, flag),
NULL_TREE));
return build_function_call (build_block_object_dispose_decl (), func_params);
}
/* APPLE LOCAL end radar 5847976 */
/* APPLE LOCAL begin radar 7760213 */
int HasByrefArray(tree byrefType)
{
tree s1;
/* Check for possibility of an error condition. */
if (TREE_CODE(byrefType) != RECORD_TYPE)
return 0;
for (s1 = TYPE_FIELDS (byrefType); s1; s1 = TREE_CHAIN (s1))
{
if (TREE_CODE(TREE_TYPE(s1)) == ARRAY_TYPE)
return 1;
}
return 0;
}
/* APPLE LOCAL end radar 7760213 */
#include "gt-c-common.h"

View File

@ -93,12 +93,20 @@ enum rid
/* Objective-C */
RID_AT_ENCODE, RID_AT_END,
RID_AT_CLASS, RID_AT_ALIAS, RID_AT_DEFS,
RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC,
/* APPLE LOCAL radar 4564694 */
RID_AT_PACKAGE, RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC,
RID_AT_PROTOCOL, RID_AT_SELECTOR,
RID_AT_THROW, RID_AT_TRY, RID_AT_CATCH,
RID_AT_FINALLY, RID_AT_SYNCHRONIZED,
RID_AT_INTERFACE,
/* APPLE LOCAL C* language */
RID_AT_OPTIONAL, RID_AT_REQUIRED,
/* APPLE LOCAL C* property (Radar 4436866) */
RID_AT_PROPERTY,
RID_AT_IMPLEMENTATION,
/* APPLE LOCAL C* property (Radar 4436866, 4591909, 4621020) */
RID_READONLY, RID_GETTER, RID_SETTER,
RID_NONATOMIC,
RID_MAX,
@ -888,8 +896,23 @@ extern void c_parse_error (const char *, enum cpp_ttype, tree);
extern tree objc_is_class_name (tree);
extern tree objc_is_object_ptr (tree);
extern void objc_check_decl (tree);
/* APPLE LOCAL radar 4281748 */
extern void objc_check_global_decl (tree);
extern int objc_is_reserved_word (tree);
extern bool objc_compare_types (tree, tree, int, tree);
/* APPLE LOCAL 4154928 */
extern tree objc_common_type (tree, tree);
/* APPLE LOCAL 4330422 */
extern tree objc_non_volatilized_type (tree);
/* APPLE LOCAL radar 4697411 */
extern void objc_volatilize_component_ref (tree, tree);
/* APPLE LOCAL radar 6231433 */
extern bool objc_compare_types (tree, tree, int, tree, const char *);
/* APPLE LOCAL radar 4229905 - radar 6231433 */
extern bool objc_have_common_type (tree, tree, int, tree, const char *);
/* APPLE LOCAL radar 4133425 */
extern bool objc_diagnose_private_ivar (tree);
/* APPLE LOCAL radar 4507230 */
bool objc_type_valid_for_messaging (tree);
extern void objc_volatilize_decl (tree);
extern bool objc_type_quals_match (tree, tree);
extern tree objc_rewrite_function_call (tree, tree);
@ -900,7 +923,8 @@ extern int objc_is_public (tree, tree);
extern tree objc_is_id (tree);
extern void objc_declare_alias (tree, tree);
extern void objc_declare_class (tree);
extern void objc_declare_protocols (tree);
/* APPLE LOCAL radar 4947311 - protocol attributes */
extern void objc_declare_protocols (tree, tree);
extern tree objc_build_message_expr (tree);
extern tree objc_finish_message_expr (tree, tree, tree);
extern tree objc_build_selector_expr (tree);
@ -910,23 +934,40 @@ extern tree objc_build_string_object (tree);
extern tree objc_get_protocol_qualified_type (tree, tree);
extern tree objc_get_class_reference (tree);
extern tree objc_get_class_ivars (tree);
extern void objc_start_class_interface (tree, tree, tree);
/* APPLE LOCAL begin radar 4291785 */
extern tree objc_get_interface_ivars (tree);
extern void objc_detect_field_duplicates (tree);
/* APPLE LOCAL end radar 4291785 */
/* APPLE LOCAL radar 4548636 */
extern void objc_start_class_interface (tree, tree, tree, tree);
extern void objc_start_category_interface (tree, tree, tree);
extern void objc_start_protocol (tree, tree);
/* APPLE LOCAL radar 4947311 - protocol attributes */
extern void objc_start_protocol (tree, tree, tree);
extern void objc_continue_interface (void);
extern void objc_finish_interface (void);
extern void objc_start_class_implementation (tree, tree);
extern void objc_start_category_implementation (tree, tree);
/* APPLE LOCAL radar 4592503 */
extern void objc_checkon_weak_attribute (tree);
/* APPLE LOCAL begin radar 5847976 */
extern tree build_block_object_assign_call_exp (tree, tree, int);
extern tree build_block_object_dispose_call_exp (tree, int);
extern int objc_is_gcable_type (tree);
/* APPLE LOCAL end radar 5847976 */
extern void objc_continue_implementation (void);
extern void objc_finish_implementation (void);
extern void objc_set_visibility (int);
extern void objc_set_method_type (enum tree_code);
extern tree objc_build_method_signature (tree, tree, tree, bool);
extern void objc_add_method_declaration (tree);
extern void objc_start_method_definition (tree);
/* APPLE LOCAL begin radar 3803157 - objc attribute */
extern bool objc_method_decl (enum tree_code);
extern void objc_add_method_declaration (tree, tree);
extern void objc_start_method_definition (tree, tree);
/* APPLE LOCAL end radar 3803157 - objc attribute */
extern void objc_finish_method_definition (tree);
extern void objc_add_instance_variable (tree);
extern tree objc_build_keyword_decl (tree, tree, tree);
/* APPLE LOCAL radar 4157812 */
extern tree objc_build_keyword_decl (tree, tree, tree, tree);
extern tree objc_build_throw_stmt (tree);
extern void objc_begin_try_stmt (location_t, tree);
extern tree objc_finish_try_stmt (void);
@ -937,6 +978,52 @@ 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);
/* APPLE LOCAL radar 5276085 */
extern void objc_weak_reference_expr (tree*);
/* APPLE LOCAL begin 5276085 */
extern tree objc_build_weak_reference_tree (tree);
/* APPLE LOCAL end 5276085 */
/* APPLE LOCAL begin C* language */
extern void objc_set_method_opt (int);
void objc_finish_foreach_loop (location_t, tree, tree, tree, tree);
tree objc_build_component_ref (tree, tree);
tree objc_build_foreach_components (tree, tree*, tree*, tree*,
tree*, tree*, tree*);
/* APPLE LOCAL end C* language */
/* APPLE LOCAL begin C* property (Radar 4436866) */
void objc_set_property_attr (int, tree);
void objc_add_property_variable (tree);
/* APPLE LOCAL begin radar 5285911 */
tree objc_build_property_reference_expr (tree, tree);
bool objc_property_reference_expr (tree);
/* APPLE LOCAL end radar 5285911 */
/* APPLE LOCAL radar 5802025 */
tree objc_build_property_getter_func_call (tree);
tree objc_build_setter_call (tree, tree);
/* APPLE LOCAL end C* property (Radar 4436866) */
/* APPLE LOCAL radar 4712269 */
tree objc_build_incr_decr_setter_call (enum tree_code, tree, tree);
/* APPLE LOCAL begin C* warnings to easy porting to new abi */
void diagnose_selector_cast (tree cast_type, tree sel_exp);
/* APPLE LOCAL end C* warnings to easy porting to new abi */
/* APPLE LOCAL begin radar 4441049 */
tree objc_v2_component_ref_field_offset (tree);
tree objc_v2_bitfield_ivar_bitpos (tree);
/* APPLE LOCAL end radar 4441049 */
/* APPLE LOCAL begin 4985544 */
bool objc_check_format_nsstring (tree, unsigned HOST_WIDE_INT, bool *);
/* APPLE LOCAL end 4985544 */
/* APPLE LOCAL radar 5202926 */
bool objc_anonymous_local_objc_name (const char *);
/* APPLE LOCAL begin radar 5195402 */
bool objc_check_nsstring_pointer_type (tree);
bool objc_check_cfstringref_type (tree);
/* APPLE LOCAL end radar 5195402 */
/* The following are provided by the C and C++ front-ends, and called by
ObjC/ObjC++. */
@ -950,6 +1037,116 @@ extern void pp_file_change (const struct line_map *);
extern void pp_dir_change (cpp_reader *, const char *);
extern bool check_missing_format_attribute (tree, tree);
/* APPLE LOCAL begin radar 5847976 */
/* Runtime support functions used by compiler when generating copy/dispose helpers */
enum {
BLOCK_FIELD_IS_OBJECT = 3, /* id, NSObject, __attribute__((NSObject)), block, ... */
BLOCK_FIELD_IS_BLOCK = 7, /* a block variable */
BLOCK_FIELD_IS_BYREF = 8, /* the on stack structure holding the __block variable */
BLOCK_FIELD_IS_WEAK = 16, /* declared __weak, only used in byref copy helpers */
BLOCK_BYREF_CALLER = 128, /* called from __block (byref) copy/dispose support routines */
BLOCK_BYREF_CURRENT_MAX = 256
};
/* APPLE LOCAL end radar 5847976 */
/* APPLE LOCAL begin radar 5732232 - blocks */
enum {
BLOCK_NEEDS_FREE = (1 << 24),
BLOCK_HAS_COPY_DISPOSE = (1 << 25),
/* APPLE LOCAL radar 6214617 */
BLOCK_HAS_CXX_OBJ = (1 << 26),
BLOCK_IS_GC = (1 << 27),
/* APPLE LOCAL radar 5822844 */
BLOCK_IS_GLOBAL = (1 << 28),
/* APPLE LOCAL radar 7735196 */
BLOCK_USE_STRET = (1 << 29)
};
struct block_sema_info {
tree helper_func_decl;
tree copy_helper_func_decl;
tree destroy_helper_func_decl;
tree block_arg_ptr_type;
/* This is for C. */
struct c_arg_info * arg_info;
tree block_ref_decl_list;
tree block_byref_decl_list;
/* APPLE LOCAL radar 5803600 */
tree block_byref_global_decl_list;
tree block_original_ref_decl_list;
/* APPLE LOCAL radar 5847213 - tree block_original_byref_decl_list is removed. */
tree block_body;
bool BlockHasCopyDispose;
/* APPLE LOCAL radar 6214617 */
bool BlockImportsCxxObjects;
/* APPLE LOCAL radar 6185344 */
bool block_has_return_type; /* When true, block has a declared return type. */
/* the_scope - This is the scope for the block itself, which
contains arguments etc. Use only for C. */
struct c_scope *the_scope;
/* Same as the above, only for C++. */
struct cp_binding_level *cp_the_scope;
/* return_type - This will get set to block result type, by looking
at return types, if any, in the block body. */
tree return_type;
/* prev_block_info - If this is nested inside another block, this points
to the outer block. */
struct block_sema_info *prev_block_info;
};
extern struct block_sema_info *cur_block;
extern tree build_helper_func_decl (tree, tree);
extern tree build_block_byref_decl (tree, tree, tree);
extern tree build_block_ref_decl (tree, tree);
extern tree begin_block (void);
extern struct block_sema_info *finish_block (tree);
extern bool in_imm_block (void);
extern bool lookup_name_in_block (tree, tree*);
extern void push_to_top_level (void);
extern void pop_from_top_level (void);
extern void start_block_helper_function (tree func_decl);
extern void block_build_prologue (struct block_sema_info *block_impl);
extern tree c_finish_return (tree);
extern bool block_requires_copying (tree);
/* APPLE LOCAL begin radar 5803600 */
extern void add_block_global_byref_list (tree);
extern bool in_block_global_byref_list (tree);
/* APPLE LOCAL end radar 5803600 */
/* APPLE LOCAL end radar 5732232 - blocks */
/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
extern tree build_byref_local_var_access (tree, tree);
extern tree do_digest_init (tree, tree);
/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
/* APPLE LOCAL begin radar 6237713 */
extern bool any_recognized_block_attribute (tree);
/* APPLE LOCAL end radar 6237713 */
/* APPLE LOCAL begin radar 5847213 */
extern tree build_block_descriptor_type (bool);
/* APPLE LOCAL end radar 5847213 */
/* APPLE LOCAL begin radar 6083129 - byref escapes */
extern tree build_block_byref_release_exp (tree);
/* APPLE LOCAL end radar 6083129 - byref escapes */
/* APPLE LOCAL radar 6040305 - blocks */
extern tree build_indirect_object_id_exp (tree);
/* APPLE LOCAL begin radar 6212722 */
extern tree array_to_pointer_conversion (tree);
extern tree function_to_pointer_conversion (tree);
/* APPLE LOCAL end radar 6212722 */
/* APPLE LOCAL radar 6160536 */
extern tree build_block_helper_name (int);
/* APPLE LOCAL radar 6353006 */
extern tree c_build_generic_block_struct_type (void);
/* APPLE LOCAL radar 7760213 */
extern int HasByrefArray(tree);
/* In c-omp.c */
extern tree c_finish_omp_master (tree);
extern tree c_finish_omp_critical (tree, tree);

View File

@ -104,6 +104,10 @@ convert (tree type, tree expr)
return fold_convert (type, c_objc_common_truthvalue_conversion (expr));
if (code == POINTER_TYPE || code == REFERENCE_TYPE)
return fold (convert_to_pointer (type, e));
/* APPLE LOCAL begin blocks (C++ ck) */
if (code == BLOCK_POINTER_TYPE)
return fold (convert_to_block_pointer (type, e));
/* APPLE LOCAL end blocks (C++ ck) */
if (code == REAL_TYPE)
return fold (convert_to_real (type, e));
if (code == COMPLEX_TYPE)

View File

@ -501,6 +501,11 @@ c_cpp_builtins (cpp_reader *pfile)
/* Other target-independent built-ins determined by command-line
options. */
/* APPLE LOCAL begin blocks */
/* APPLE LOCAL radar 5868913 */
if (flag_blocks)
cpp_define (pfile, "__BLOCKS__=1");
/* APPLE LOCAL end blocks */
if (optimize_size)
cpp_define (pfile, "__OPTIMIZE_SIZE__");
if (optimize)

File diff suppressed because it is too large Load Diff

View File

@ -140,4 +140,10 @@ extern void c_initialize_diagnostics (diagnostic_context *);
#undef LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P
#define LANG_HOOKS_TREE_INLINING_VAR_MOD_TYPE_P c_vla_unspec_p
/* APPLE LOCAL begin radar 6353006 */
#undef LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
c_build_generic_block_struct_type
/* APPLE LOCAL end radar 6353006 */
#endif /* GCC_C_OBJC_COMMON */

View File

@ -1040,6 +1040,13 @@ c_common_post_options (const char **pfilename)
if (flag_inline_functions)
flag_inline_trees = 2;
/* APPLE LOCAL begin radar 5811887 - radar 6084601 */
/* In all flavors of c99, except for ObjC/ObjC++, blocks are off by default
unless requested via -fblocks. */
if (flag_blocks == -1 && flag_iso && !c_dialect_objc())
flag_blocks = 0;
/* APPLE LOCAL end radar 5811887 - radar 6084601 */
/* By default we use C99 inline semantics in GNU99 or C99 mode. C99
inline semantics are not supported in GNU89 or C89 mode. */
if (flag_gnu89_inline == -1)

File diff suppressed because it is too large Load Diff

View File

@ -137,6 +137,15 @@ pp_c_star (c_pretty_printer *pp)
pp_base (pp)->padding = pp_none;
}
/* APPLE LOCAL begin blocks */
void
pp_c_caret (c_pretty_printer *pp)
{
pp_carret (pp);
pp_base (pp)->padding = pp_none;
}
/* APPLE LOCAL end blocks */
void
pp_c_arrow (c_pretty_printer *pp)
{
@ -260,6 +269,12 @@ pp_c_pointer (c_pretty_printer *pp, tree t)
pp_c_ampersand (pp);
pp_c_type_qualifier_list (pp, t);
break;
/* APPLE LOCAL begin blocks */
case BLOCK_POINTER_TYPE:
pp_c_caret (pp);
pp_c_type_qualifier_list (pp, t);
break;
/* APPLE LOCAL end blocks */
/* ??? This node is now in GENERIC and so shouldn't be here. But
we'll fix that later. */
@ -405,6 +420,8 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
{
case REFERENCE_TYPE:
case POINTER_TYPE:
/* APPLE LOCAL blocks */
case BLOCK_POINTER_TYPE:
{
/* Get the types-specifier of this type. */
tree pointee = strip_pointer_operator (TREE_TYPE (t));
@ -487,7 +504,10 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
static void
pp_c_abstract_declarator (c_pretty_printer *pp, tree t)
{
if (TREE_CODE (t) == POINTER_TYPE)
/* APPLE LOCAL begin blocks */
if (TREE_CODE (t) == POINTER_TYPE ||
TREE_CODE (t) == BLOCK_POINTER_TYPE)
/* APPLE LOCAL end blocks */
{
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE
|| TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
@ -510,6 +530,8 @@ pp_c_direct_abstract_declarator (c_pretty_printer *pp, tree t)
switch (TREE_CODE (t))
{
case POINTER_TYPE:
/* APPLE LOCAL blocks */
case BLOCK_POINTER_TYPE:
pp_abstract_declarator (pp, t);
break;
@ -635,6 +657,8 @@ pp_c_direct_declarator (c_pretty_printer *pp, tree t)
case ARRAY_TYPE:
case POINTER_TYPE:
/* APPLE LOCAL blocks */
case BLOCK_POINTER_TYPE:
pp_abstract_declarator (pp, TREE_TYPE (t));
break;

View File

@ -167,6 +167,8 @@ void pp_c_right_bracket (c_pretty_printer *);
void pp_c_dot (c_pretty_printer *);
void pp_c_ampersand (c_pretty_printer *);
void pp_c_star (c_pretty_printer *);
/* APPLE LOCAL blocks */
void pp_c_caret (c_pretty_printer *);
void pp_c_arrow (c_pretty_printer *);
void pp_c_semicolon (c_pretty_printer *);
void pp_c_complement (c_pretty_printer *);

View File

@ -298,6 +298,8 @@ enum c_declarator_kind {
cdk_array,
/* A pointer. */
cdk_pointer,
/* APPLE LOCAL blocks (C++ ch) */
cdk_block_pointer,
/* Parenthesized declarator with nested attributes. */
cdk_attrs
};
@ -468,6 +470,8 @@ extern tree finish_struct (tree, tree, tree);
extern struct c_arg_info *get_parm_info (bool);
extern tree grokfield (struct c_declarator *, struct c_declspecs *, tree);
extern tree groktypename (struct c_type_name *);
/* APPLE LOCAL blocks 6339747 */
extern tree grokblockdecl (struct c_declspecs *, struct c_declarator *);
extern tree grokparm (const struct c_parm *);
extern tree implicitly_declare (tree);
extern void keep_next_level (void);
@ -501,6 +505,10 @@ extern struct c_declarator *build_function_declarator (struct c_arg_info *,
extern struct c_declarator *build_id_declarator (tree);
extern struct c_declarator *make_pointer_declarator (struct c_declspecs *,
struct c_declarator *);
/* APPLE LOCAL begin radar 5814025 - blocks (C++ cg) */
extern struct c_declarator *make_block_pointer_declarator (struct c_declspecs *,
struct c_declarator *);
/* APPLE LOCAL end radar 5814025 - blocks (C++ cg) */
extern struct c_declspecs *build_null_declspecs (void);
extern struct c_declspecs *declspecs_add_qual (struct c_declspecs *, tree);
extern struct c_declspecs *declspecs_add_type (struct c_declspecs *,
@ -627,6 +635,8 @@ extern bool c_eh_initialized_p;
extern void c_finish_incomplete_decl (tree);
extern void c_write_global_declarations (void);
/* APPLE LOCAL radar 5741070 */
extern tree c_return_interface_record_type (tree);
/* In order for the format checking to accept the C frontend
diagnostic framework extensions, you must include this file before
toplev.h, not after. */

View File

@ -75,6 +75,10 @@ static int missing_braces_mentioned;
static int require_constant_value;
static int require_constant_elements;
/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
static bool types_are_block_compatible (tree lhptee, tree rhptee);
static tree build_block_call (tree, tree, tree);
/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
static bool null_pointer_constant_p (tree);
static tree qualify_type (tree, tree);
static int tagged_types_tu_compatible_p (tree, tree);
@ -542,8 +546,12 @@ common_pointer_type (tree t1, tree t2)
if (t2 == error_mark_node)
return t1;
gcc_assert (TREE_CODE (t1) == POINTER_TYPE
&& TREE_CODE (t2) == POINTER_TYPE);
/* APPLE LOCAL begin blocks 6065211 */
gcc_assert ((TREE_CODE (t1) == POINTER_TYPE
&& TREE_CODE (t2) == POINTER_TYPE)
|| (TREE_CODE (t1) == BLOCK_POINTER_TYPE
&& TREE_CODE (t2) == BLOCK_POINTER_TYPE));
/* APPLE LOCAL end blocks 6065211 */
/* Merge the attributes. */
attributes = targetm.merge_type_attributes (t1, t2);
@ -558,10 +566,15 @@ common_pointer_type (tree t1, tree t2)
if (TREE_CODE (mv2) != ARRAY_TYPE)
mv2 = TYPE_MAIN_VARIANT (pointed_to_2);
target = composite_type (mv1, mv2);
t1 = build_pointer_type (c_build_qualified_type
(target,
TYPE_QUALS (pointed_to_1) |
TYPE_QUALS (pointed_to_2)));
/* APPLE LOCAL begin blocks 6065211 */
t1 = c_build_qualified_type (target,
TYPE_QUALS (pointed_to_1) |
TYPE_QUALS (pointed_to_2));
if (TREE_CODE (t2) == BLOCK_POINTER_TYPE)
t1 = build_block_pointer_type (t1);
else
t1 = build_pointer_type (t1);
/* APPLE LOCAL end blocks 6065211 */
return build_type_attribute_variant (t1, attributes);
}
@ -845,6 +858,13 @@ comptypes_internal (tree type1, tree type2)
switch (TREE_CODE (t1))
{
/* APPLE LOCAL begin radar 5795493 */
case BLOCK_POINTER_TYPE:
val = (TREE_CODE (t2) == BLOCK_POINTER_TYPE) &&
types_are_block_compatible (TREE_TYPE (t1), TREE_TYPE (t2));
break;
/* APPLE LOCAL end radar 5795493 */
case POINTER_TYPE:
/* Do not remove mode or aliasing information. */
if (TYPE_MODE (t1) != TYPE_MODE (t2)
@ -937,6 +957,15 @@ comp_target_types (tree ttl, tree ttr)
int val;
tree mvl, mvr;
/* APPLE LOCAL begin blocks 6065211 */
if (TREE_CODE (ttl) == BLOCK_POINTER_TYPE
&& TREE_CODE (ttr) == BLOCK_POINTER_TYPE)
return types_are_block_compatible (TREE_TYPE (ttl),
TREE_TYPE (ttr));
if (TREE_CODE (ttl) != TREE_CODE (ttr))
return 0;
/* APPLE LOCAL end blocks 6065211 */
/* Do not lose qualifiers on element types of array types that are
pointer targets by taking their TYPE_MAIN_VARIANT. */
mvl = TREE_TYPE (ttl);
@ -1485,7 +1514,8 @@ decl_constant_value_for_broken_optimization (tree decl)
}
/* Convert the array expression EXP to a pointer. */
static tree
/* APPLE LOCAL radar 6212722 */
tree
array_to_pointer_conversion (tree exp)
{
tree orig_exp = exp;
@ -1526,7 +1556,8 @@ array_to_pointer_conversion (tree exp)
}
/* Convert the function expression EXP to a pointer. */
static tree
/* APPLE LOCAL radar 6212722 */
tree
function_to_pointer_conversion (tree exp)
{
tree orig_exp = exp;
@ -1803,6 +1834,12 @@ build_component_ref (tree datum, tree component)
if (!objc_is_public (datum, component))
return error_mark_node;
/* APPLE LOCAL begin C* property (Radar 4436866) */
/* APPLE LOCAL radar 5285911 */
if ((ref = objc_build_property_reference_expr (datum, component)))
return ref;
/* APPLE LOCAL end C* property (Radar 4436866) */
/* See if there is a field or component with name COMPONENT. */
if (code == RECORD_TYPE || code == UNION_TYPE)
@ -1841,6 +1878,8 @@ build_component_ref (tree datum, tree component)
ref = build3 (COMPONENT_REF, subtype, datum, subdatum,
NULL_TREE);
/* APPLE LOCAL radar 4697411 */
objc_volatilize_component_ref (ref, TREE_TYPE (subdatum));
if (TREE_READONLY (datum) || TREE_READONLY (subdatum))
TREE_READONLY (ref) = 1;
if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (subdatum))
@ -2073,9 +2112,62 @@ build_external_ref (tree id, int fun, location_t loc)
/* In Objective-C, an instance variable (ivar) may be preferred to
whatever lookup_name() found. */
decl = objc_lookup_ivar (decl, id);
/* APPLE LOCAL begin radar 5732232 - blocks (C++ ci) */
if (decl && decl != error_mark_node)
ref = decl;
{
if (cur_block
&& (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL)
&& !lookup_name_in_block (id, &decl))
{
/* APPLE LOCAL begin radar 5803005 (C++ ci) */
bool gdecl;
/* We are referencing a variable inside a block whose declaration
is outside. */
gcc_assert (decl &&
(TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL));
gdecl = (TREE_CODE (decl) == VAR_DECL &&
/* APPLE LOCAL radar 6177162 */
(DECL_EXTERNAL (decl) || TREE_STATIC (decl)));
/* Treat all 'global' variables as 'byref' by default. */
/* APPLE LOCAL begin radar 6014138 (C++ ci) */
if (gdecl || (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl)))
/* APPLE LOCAL end radar 6014138 (C++ ci) */
{
/* APPLE LOCAL begin radar 5803600 (C++ ci) */
/* byref globals are directly accessed. */
/* APPLE LOCAL begin radar 7760213 */
if (!gdecl) {
if (HasByrefArray(TREE_TYPE (decl)))
error ("cannot access __block variable of array type inside block");
/* build a decl for the byref variable. */
decl = build_block_byref_decl (id, decl, decl);
}
/* APPLE LOCAL end radar 7760213 */
else
add_block_global_byref_list (decl);
}
else
{
/* 'byref' globals are never copied-in. So, do not add
them to the copied-in list. */
if (!in_block_global_byref_list (decl)) {
/* APPLE LOCAL begin radar 7721728 */
if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
error ("cannot access copied-in variable of array type inside block");
/* APPLE LOCAL end radar 7721728 */
/* build a new decl node. set its type to 'const' type
of the old decl. */
decl = build_block_ref_decl (id, decl);
}
/* APPLE LOCAL end radar 5803600 (C++ ci) */
/* APPLE LOCAL end radar 5803005 (C++ ci) */
}
}
ref = decl;
}
/* APPLE LOCAL end radar 5732232 - blocks (C++ ci) */
else if (fun)
/* Implicit function declaration. */
ref = implicitly_declare (id);
@ -2285,8 +2377,10 @@ build_function_call (tree function, tree params)
if (TREE_CODE (fntype) == ERROR_MARK)
return error_mark_node;
if (!(TREE_CODE (fntype) == POINTER_TYPE
/* APPLE LOCAL begin radar 5732232 - blocks */
if (!((TREE_CODE (fntype) == POINTER_TYPE
|| TREE_CODE (fntype) == BLOCK_POINTER_TYPE)
/* APPLE LOCAL end radar 5732232 - blocks */
&& TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE))
{
error ("called object %qE is not a function", function);
@ -2353,6 +2447,11 @@ build_function_call (tree function, tree params)
check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params,
TYPE_ARG_TYPES (fntype));
/* APPLE LOCAL begin radar 5732232 - blocks */
if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
result = build_block_call (fntype, function, coerced_params);
else
/* APPLE LOCAL end radar 5732232 - blocks */
if (require_constant_value)
{
result = fold_build3_initializer (CALL_EXPR, TREE_TYPE (fntype),
@ -2424,7 +2523,17 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
if (type == void_type_node)
{
error ("too many arguments to function %qE", function);
/* APPLE LOCAL begin radar 5732232 - blocks */
if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
{
error ("too many arguments to block call");
break;
}
/* APPLE LOCAL end radar 5732232 - blocks */
/* APPLE LOCAL begin radar 4491608 */
error ("too many arguments to function %qE", selector ? selector
: function);
/* APPLE LOCAL end radar 4491608 */
break;
}
@ -2607,7 +2716,12 @@ convert_arguments (tree typelist, tree values, tree function, tree fundecl)
if (typetail != 0 && TREE_VALUE (typetail) != void_type_node)
{
error ("too few arguments to function %qE", function);
/* APPLE LOCAL begin radar 5732232 - blocks */
if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
error ("too few arguments to block %qE", function);
else
error ("too few arguments to function %qE", function);
/* APPLE LOCAL end radar 5732232 - blocks */
return error_mark_node;
}
@ -2870,6 +2984,8 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
case TRUTH_NOT_EXPR:
if (typecode != INTEGER_TYPE
/* APPLE LOCAL radar 5732232 - blocks */
&& typecode != BLOCK_POINTER_TYPE
&& typecode != REAL_TYPE && typecode != POINTER_TYPE
&& typecode != COMPLEX_TYPE)
{
@ -3321,7 +3437,12 @@ build_conditional_expr (tree ifexp, tree op1, tree op2)
pedwarn ("ISO C forbids conditional expr with only one void side");
result_type = void_type_node;
}
else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
/* APPLE LOCAL begin blocks 6065211 */
else if ((code1 == POINTER_TYPE
|| code1 == BLOCK_POINTER_TYPE)
&& (code2 == POINTER_TYPE
|| code2 == BLOCK_POINTER_TYPE))
/* APPLE LOCAL end blocks 6065211 */
{
if (comp_target_types (type1, type2))
result_type = common_pointer_type (type1, type2);
@ -3329,6 +3450,14 @@ build_conditional_expr (tree ifexp, tree op1, tree op2)
result_type = qualify_type (type2, type1);
else if (null_pointer_constant_p (orig_op2))
result_type = qualify_type (type1, type2);
/* APPLE LOCAL begin blocks 6065211 */
else if (code2 == BLOCK_POINTER_TYPE
&& VOID_TYPE_P (TREE_TYPE (type1)))
result_type = type2;
else if (code1 == BLOCK_POINTER_TYPE
&& VOID_TYPE_P (TREE_TYPE (type2)))
result_type = type1;
/* APPLE LOCAL end blocks 6065211 */
else if (VOID_TYPE_P (TREE_TYPE (type1)))
{
if (pedantic && TREE_CODE (TREE_TYPE (type2)) == FUNCTION_TYPE)
@ -3371,7 +3500,31 @@ build_conditional_expr (tree ifexp, tree op1, tree op2)
}
result_type = type2;
}
/* APPLE LOCAL begin radar 5732232 - blocks (C++ co) */
/* APPLE LOCAL radar 5957801 */
else if (code1 == BLOCK_POINTER_TYPE && code2 == INTEGER_TYPE)
{
if (!null_pointer_constant_p (orig_op2))
error ("block pointer/integer type mismatch in conditional expression");
else
{
op2 = convert (type1, null_pointer_node);
}
result_type = type1;
}
/* APPLE LOCAL radar 5957801 */
else if (code2 == BLOCK_POINTER_TYPE && code1 == INTEGER_TYPE)
{
if (!null_pointer_constant_p (orig_op1))
error ("block pointer/integer type mismatch in conditional expression");
else
{
op1 = convert (type2, null_pointer_node);
}
result_type = type2;
}
/* APPLE LOCAL end radar 5732232 - blocks (C++ co) */
if (!result_type)
{
if (flag_cond_mismatch)
@ -3510,6 +3663,12 @@ build_c_cast (tree type, tree expr)
otype = TREE_TYPE (value);
/* APPLE LOCAL begin radar 5732232 - blocks */
if (TREE_CODE (otype) == BLOCK_POINTER_TYPE &&
TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type)))
return build1 (NOP_EXPR, type, value);
/* APPLE LOCAL end radar 5732232 - blocks */
/* Optionally warn about potentially worrisome casts. */
if (warn_cast_qual
@ -3613,6 +3772,13 @@ build_c_cast (tree type, tree expr)
pedwarn ("ISO C forbids conversion of object pointer to function pointer type");
ovalue = value;
/* APPLE LOCAL begin don't sign-extend pointers cast to integers */
if (TREE_CODE (type) == INTEGER_TYPE
&& TREE_CODE (otype) == POINTER_TYPE
&& TYPE_PRECISION (type) > TYPE_PRECISION (otype)
&& TYPE_UNSIGNED (type))
value = convert (c_common_type_for_size (POINTER_SIZE, 1), value);
/* APPLE LOCAL end don't sign-extend pointers cast to integers */
value = convert (type, value);
/* Ignore any integer overflow caused by the cast. */
@ -3641,6 +3807,78 @@ build_c_cast (tree type, tree expr)
return value;
}
/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
static bool
functiontypes_are_block_compatible (tree f1, tree f2)
{
tree arg1, arg2;
if (!types_are_block_compatible (TREE_TYPE (f1), TREE_TYPE (f2)))
return false;
arg1 = TYPE_ARG_TYPES (f1);
arg2 = TYPE_ARG_TYPES (f2);
/* APPLE LOCAL radar 6246965, 6196572 */
return (!arg1) || (type_lists_compatible_p (arg1, arg2) == 1);
}
static bool
types_are_block_compatible (tree lhptee, tree rhptee)
{
if (TYPE_MAIN_VARIANT (lhptee) == TYPE_MAIN_VARIANT (rhptee))
return true;
if (TREE_CODE (lhptee) == FUNCTION_TYPE && TREE_CODE (rhptee) == FUNCTION_TYPE)
return functiontypes_are_block_compatible (lhptee, rhptee);
/* APPLE LOCAL begin radar 5882266 (C++ cm) */
if (TREE_CODE (lhptee) == POINTER_TYPE && TREE_CODE (rhptee) == POINTER_TYPE)
return types_are_block_compatible (TREE_TYPE (lhptee), TREE_TYPE (rhptee));
/* APPLE LOCAL end radar 5882266 (C++ cm) */
/* APPLE LOCAL begin radar 5988995 (C++ cm) */
if (TREE_CODE (lhptee) == BLOCK_POINTER_TYPE
&& TREE_CODE (rhptee) == BLOCK_POINTER_TYPE)
return types_are_block_compatible (TREE_TYPE (lhptee), TREE_TYPE (rhptee));
/* APPLE LOCAL end radar 5988995 (C++ cm) */
return false;
}
/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
/**
build_block_call - Routine to build a block call; as in:
((double(*)(void *, int))(BLOCK_PTR_EXP->__FuncPtr))(I, 42);
FNTYPE is the original function type derived from the syntax.
BLOCK_PTR_EXP is the block pointer variable.
PARAMS is the parameter list.
*/
static tree
build_block_call (tree fntype, tree block_ptr_exp, tree params)
{
tree function_ptr_exp;
tree typelist;
bool block_ptr_exp_side_effect = TREE_SIDE_EFFECTS (block_ptr_exp);
/* First convert BLOCK_PTR_EXP to 'void *'. */
block_ptr_exp = convert (ptr_type_node, block_ptr_exp);
gcc_assert (generic_block_literal_struct_type);
block_ptr_exp = convert (build_pointer_type (generic_block_literal_struct_type),
block_ptr_exp);
if (block_ptr_exp_side_effect)
block_ptr_exp = save_expr (block_ptr_exp);
/* BLOCK_PTR_VAR->__FuncPtr */
function_ptr_exp = build_component_ref (build_indirect_ref (block_ptr_exp, "->"),
get_identifier ("__FuncPtr"));
gcc_assert (function_ptr_exp);
/* Build: result_type(*)(void *, function-arg-type-list) */
typelist = TYPE_ARG_TYPES (fntype);
typelist = tree_cons (NULL_TREE, ptr_type_node, typelist);
fntype = build_function_type (TREE_TYPE (fntype), typelist);
function_ptr_exp = convert (build_pointer_type (fntype), function_ptr_exp);
params = tree_cons (NULL_TREE, block_ptr_exp, params);
return fold_build3 (CALL_EXPR, TREE_TYPE (fntype),
function_ptr_exp, params, NULL_TREE);
}
/* APPLE LOCAL end radar 5847213 - radar 6329245 */
/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
/* Interpret a cast of expression EXPR to type TYPE. */
tree
c_cast_expr (struct c_type_name *type_name, tree expr)
@ -3670,6 +3908,18 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
tree newrhs;
tree lhstype = TREE_TYPE (lhs);
tree olhstype = lhstype;
/* APPLE LOCAL __block assign sequence point 6639533 */
bool insert_sequence_point = false;
/* APPLE LOCAL begin radar 4426814 */
if (c_dialect_objc () && flag_objc_gc)
{
/* APPLE LOCAL radar 5276085 */
objc_weak_reference_expr (&lhs);
lhstype = TREE_TYPE (lhs);
olhstype = lhstype;
}
/* APPLE LOCAL end radar 4426814 */
/* Types that aren't fully specified cannot be used in assignments. */
lhs = require_complete_type (lhs);
@ -3678,11 +3928,46 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
return error_mark_node;
/* APPLE LOCAL radar 5285911 */
if (!lvalue_or_else (lhs, lv_assign))
return error_mark_node;
STRIP_TYPE_NOPS (rhs);
/* APPLE LOCAL begin __block assign sequence point 6639533 */
/* For byref = x;, we have to transform this into {( typeof(x) x' =
x; byref = x`; )} to ensure there is a sequence point before the
evaluation of the byref, inorder to ensure that the access
expression for byref doesn't start running before x is evaluated,
as it will access the __forwarding pointer and that must be done
after x is evaluated. */
/* First we check to see if lhs is a byref... byrefs look like:
__Block_byref_X.__forwarding->x */
if (TREE_CODE (lhs) == COMPONENT_REF)
{
tree inner = TREE_OPERAND (lhs, 0);
/* now check for -> */
if (TREE_CODE (inner) == INDIRECT_REF)
{
inner = TREE_OPERAND (inner, 0);
if (TREE_CODE (inner) == COMPONENT_REF)
{
inner = TREE_OPERAND (inner, 0);
if (TREE_CODE (inner) == VAR_DECL
&& COPYABLE_BYREF_LOCAL_VAR (inner))
{
tree old_rhs = rhs;
/* then we save the rhs. */
rhs = save_expr (rhs);
if (rhs != old_rhs)
/* And arrange for the sequence point to be inserted. */
insert_sequence_point = true;
}
}
}
}
/* APPLE LOCAL end __block assign sequence point 6639533 */
newrhs = rhs;
/* If a binary op has been requested, combine the old LHS value with the RHS
@ -3694,6 +3979,21 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
newrhs = build_binary_op (modifycode, lhs, rhs, 1);
}
/* APPLE LOCAL begin C* property (Radar 4436866) */
if (c_dialect_objc ())
{
result = objc_build_setter_call (lhs, newrhs);
if (result)
/* APPLE LOCAL begin __block assign sequence point 6639533 */
{
if (insert_sequence_point)
result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build1 (NOP_EXPR, void_type_node, rhs), result);
return result;
}
/* APPLE LOCAL end __block assign sequence point 6639533 */
}
/* APPLE LOCAL end C* property (Radar 4436866) */
/* Give an error for storing in something that is 'const'. */
if (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
@ -3738,7 +4038,13 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
{
result = objc_generate_write_barrier (lhs, modifycode, newrhs);
if (result)
return result;
/* APPLE LOCAL begin __block assign sequence point 6639533 */
{
if (insert_sequence_point)
result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build1 (NOP_EXPR, void_type_node, rhs), result);
return result;
}
/* APPLE LOCAL end __block assign sequence point 6639533 */
}
/* Scan operands. */
@ -3746,6 +4052,11 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
result = build2 (MODIFY_EXPR, lhstype, lhs, newrhs);
TREE_SIDE_EFFECTS (result) = 1;
/* APPLE LOCAL begin __block assign sequence point 6639533 */
if (insert_sequence_point)
result = build2 (COMPOUND_EXPR, TREE_TYPE (result), build1 (NOP_EXPR, void_type_node, rhs), result);
/* APPLE LOCAL end __block assign sequence point 6639533 */
/* If we got the LHS in a different type for storing in,
convert the result back to the nominal type of LHS
so that the value we return always has the same type
@ -3859,7 +4170,8 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
break;
}
objc_ok = objc_compare_types (type, rhstype, parmno, rname);
/* APPLE LOCAL radar 6231433 */
objc_ok = objc_compare_types (type, rhstype, parmno, rname, "comparison");
}
if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
@ -3879,7 +4191,10 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
This code doesn't fully support references, it's just for the
special case of va_start and va_copy. */
if (codel == REFERENCE_TYPE
&& comptypes (TREE_TYPE (type), TREE_TYPE (rhs)) == 1)
/* APPLE LOCAL begin radar 4502186 */
&& comptypes (objc_non_volatilized_type (TREE_TYPE (type)),
objc_non_volatilized_type (TREE_TYPE (rhs))) == 1)
/* APPLE LOCAL end radar 4502186 */
{
if (!lvalue_p (rhs))
{
@ -4030,8 +4345,13 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
else if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
&& (coder == codel))
{
tree ttl = TREE_TYPE (type);
tree ttr = TREE_TYPE (rhstype);
/* APPLE LOCAL begin radar 4193359 */
/* Types differing only by the presence of the 'volatile'
qualifier are acceptable if the 'volatile' has been added
in by the Objective-C EH machinery. */
tree ttl = objc_non_volatilized_type (TREE_TYPE (type));
tree ttr = objc_non_volatilized_type (TREE_TYPE (rhstype));
/* APPLE LOCAL end radar 4193359 */
tree mvl = ttl;
tree mvr = ttr;
bool is_opaque_pointer;
@ -4123,10 +4443,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
{
if (TYPE_QUALS (ttr) & ~TYPE_QUALS (ttl))
{
/* Types differing only by the presence of the 'volatile'
qualifier are acceptable if the 'volatile' has been added
in by the Objective-C EH machinery. */
if (!objc_type_quals_match (ttl, ttr))
/* APPLE LOCAL begin radar 4193359 */
WARN_FOR_ASSIGNMENT (G_("passing argument %d of %qE discards "
"qualifiers from pointer target type"),
G_("assignment discards qualifiers "
@ -4207,6 +4524,43 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
return convert (type, rhs);
}
/* APPLE LOCAL begin radar 5732232 - blocks */
else if (codel == BLOCK_POINTER_TYPE && coder == INTEGER_TYPE)
{
if (!null_pointer_constant_p (rhs))
{
error("invalid conversion %s integer 'int', expected block pointer",
errtype == ic_assign ? "assigning" : "initializing");
return error_mark_node;
}
return build_int_cst (type, 0);
}
else if (codel == BLOCK_POINTER_TYPE && coder == codel)
{
tree lhptee = TREE_TYPE (type);
tree rhptee = TREE_TYPE(rhstype);
if (lhptee == rhptee)
return rhs;
if (!types_are_block_compatible (lhptee, rhptee))
{
error ("incompatible block pointer types %s %qT, expected %qT",
errtype == ic_assign ? "assigning" : "initializing",
rhstype, type);
return error_mark_node;
}
return rhs;
}
/* APPLE LOCAL begin radar 5831855 */
/* APPLE LOCAL radar 5878380 */
else if (codel == BLOCK_POINTER_TYPE && POINTER_TYPE_P (rhstype) &&
(VOID_TYPE_P (TREE_TYPE (rhstype)) || objc_is_id (rhstype)))
return convert (type, rhs);
/* APPLE LOCAL radar 5878380 */
else if (coder == BLOCK_POINTER_TYPE && POINTER_TYPE_P (type) &&
(VOID_TYPE_P (TREE_TYPE (type)) || objc_is_id (type)))
/* APPLE LOCAL end radar 5831855 */
return convert (type, rhs);
/* APPLE LOCAL end radar 5732232 - blocks */
else if (codel == INTEGER_TYPE && coder == POINTER_TYPE)
{
WARN_FOR_ASSIGNMENT (G_("passing argument %d of %qE makes integer "
@ -4228,7 +4582,7 @@ convert_for_assignment (tree type, tree rhs, enum impl_conv errtype,
case ic_argpass_nonproto:
/* ??? This should not be an error when inlining calls to
unprototyped functions. */
error ("incompatible type for argument %d of %qE", parmnum, rname);
error ("convert_for_assignment: incompatible type for argument %d of %qE", parmnum, rname);
break;
case ic_assign:
error ("incompatible types in assignment");
@ -4541,6 +4895,13 @@ maybe_warn_string_init (tree type, struct c_expr expr)
pedwarn_init ("array initialized from parenthesized string constant");
}
/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
tree do_digest_init (tree type, tree init)
{
return digest_init (type, init, true, false);
}
/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
/* Digest the parser output INIT as an initializer for type TYPE.
Return a C expression of type TYPE to represent the initial value.
@ -4750,7 +5111,10 @@ digest_init (tree type, tree init, bool strict_string, int require_constant)
}
/* Added to enable additional -Wmissing-format-attribute warnings. */
if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE)
/* APPLE LOCAL begin radar 5822844 */
if (TREE_CODE (TREE_TYPE (inside_init)) == POINTER_TYPE ||
TREE_CODE (TREE_TYPE (inside_init)) == BLOCK_POINTER_TYPE)
/* APPLE LOCAL end radar 5822844 */
inside_init = convert_for_assignment (type, inside_init, ic_init, NULL_TREE,
NULL_TREE, 0);
return inside_init;
@ -4759,6 +5123,8 @@ digest_init (tree type, tree init, bool strict_string, int require_constant)
/* Handle scalar types, including conversions. */
if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
/* APPLE LOCAL radar 5732232 - blocks */
|| code == BLOCK_POINTER_TYPE
|| code == ENUMERAL_TYPE || code == BOOLEAN_TYPE || code == COMPLEX_TYPE
|| code == VECTOR_TYPE)
{
@ -5475,6 +5841,16 @@ pop_init_level (int implicit)
{
if (constructor_erroneous)
ret.value = error_mark_node;
/* APPLE LOCAL begin radar 4188876 */
else if (!constructor_constant
&& TREE_CODE (constructor_type) == VECTOR_TYPE && constructor_decl
&& (TREE_CODE (TREE_TYPE (constructor_decl)) == RECORD_TYPE
|| TREE_CODE (TREE_TYPE (constructor_decl)) == UNION_TYPE))
{
error ("Initializer is a non-const vector type");
ret.value = error_mark_node;
}
/* APPLE LOCAL end radar 4188876 */
else
{
ret.value = build_constructor (constructor_type,
@ -6943,14 +7319,85 @@ c_finish_goto_ptr (tree expr)
return add_stmt (build1 (GOTO_EXPR, void_type_node, expr));
}
/* APPLE LOCAL begin radar 5732232 - blocks (C++ cm) */
/** c_finish_block_return_stmt - Utilty routine to figure out block's return
type.
*/
static tree
c_finish_block_return_stmt (tree retval)
{
tree valtype;
/* If this is the first return we've seen in the block, infer the type of
the block from it. */
if (cur_block->return_type == NULL_TREE)
{
tree restype;
if (retval)
{
restype = TYPE_MAIN_VARIANT (TREE_TYPE (retval));
TREE_TYPE (current_function_decl)
= build_function_type (restype,
TYPE_ARG_TYPES (TREE_TYPE (current_function_decl)));
TREE_TYPE (DECL_RESULT (current_function_decl)) = restype;
relayout_decl (DECL_RESULT (current_function_decl));
}
else
restype = void_type_node;
cur_block->return_type = restype;
}
/* Verify that this result type matches the previous one. We are
pickier with blocks than for normal functions because this is a
new feature and we set the rules. */
if (TREE_CODE (cur_block->return_type) == VOID_TYPE)
{
if (retval)
{
error ("void block should not return a value");
retval = NULL_TREE;
}
return retval;
}
if (!retval)
{
error ("non-void block should return a value");
return error_mark_node;
}
/* We have a non-void block with an expression, continue checking. */
valtype = TREE_TYPE (retval);
/* For now, restrict multiple return statements in a block to have
strict compatible types only. */
if (!types_are_block_compatible (cur_block->return_type, valtype))
error ("incompatible type returning %qT, expected %qT",
valtype, cur_block->return_type);
return retval;
}
/* APPLE LOCAL end radar 5732232 - blocks (C++ cm) */
/* Generate a C `return' statement. RETVAL is the expression for what
to return, or a null pointer for `return;' with no value. */
tree
c_finish_return (tree retval)
{
tree valtype = TREE_TYPE (TREE_TYPE (current_function_decl)), ret_stmt;
/* APPLE LOCAL begin radar 5732232 - blocks */
tree valtype, ret_stmt;
bool no_warning = false;
/* APPLE LOCAL radar 5822844 - radar 6185344 */
if (cur_block && !cur_block->block_has_return_type)
{
retval = c_finish_block_return_stmt (retval);
if (retval == error_mark_node)
return NULL_TREE;
}
valtype = TREE_TYPE (TREE_TYPE (current_function_decl));
/* APPLE LOCAL end radar 5732232 - blocks */
if (TREE_THIS_VOLATILE (current_function_decl))
warning (0, "function declared %<noreturn%> has a %<return%> statement");
@ -7027,7 +7474,15 @@ c_finish_return (tree retval)
&& !DECL_EXTERNAL (inner)
&& !TREE_STATIC (inner)
&& DECL_CONTEXT (inner) == current_function_decl)
warning (0, "function returns address of local variable");
/* APPLE LOCAL begin radar 5732232 - blocks (C++ cn) */
{
if (TREE_CODE (valtype) == BLOCK_POINTER_TYPE)
/* APPLE LOCAL radar 6048570 */
error ("returning block that lives on the local stack");
else
warning (0, "function returns address of local variable");
}
/* APPLE LOCAL end radar 5732232 - blocks (C++ cn) */
break;
default:
@ -7295,6 +7750,11 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
then we just build a jump back to the top. */
exit = build_and_jump (&LABEL_EXPR_LABEL (top));
/* APPLE LOCAL begin for-fsf-4_4 3274130 5295549 */ \
/* Add the attributes to the 'top' label. */
decl_attributes (&LABEL_EXPR_LABEL (top), attrs, 0);
/* APPLE LOCAL end for-fsf-4_4 3274130 5295549 */ \
if (cond && !integer_nonzerop (cond))
{
/* Canonicalize the loop condition to the end. This means
@ -7840,7 +8300,7 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
return error_mark_node;
}
objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE);
objc_ok = objc_compare_types (type0, type1, -3, NULL_TREE, "comparison");
switch (code)
{
@ -7941,8 +8401,12 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
case TRUTH_OR_EXPR:
case TRUTH_XOR_EXPR:
if ((code0 == INTEGER_TYPE || code0 == POINTER_TYPE
/* APPLE LOCAL radar 5928316 */
|| code0 == BLOCK_POINTER_TYPE
|| code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
&& (code1 == INTEGER_TYPE || code1 == POINTER_TYPE
/* APPLE LOCAL radar 5928316 */
|| code1 == BLOCK_POINTER_TYPE
|| code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
{
/* Result of these operations is always an int,
@ -8023,7 +8487,10 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|| code1 == COMPLEX_TYPE))
short_compare = 1;
else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
/* APPLE LOCAL begin blocks 6065211 */
else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE)
&& (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
/* APPLE LOCAL end blocks 6065211 */
{
tree tt0 = TREE_TYPE (type0);
tree tt1 = TREE_TYPE (type1);
@ -8032,6 +8499,12 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
and both must be object or both incomplete. */
if (comp_target_types (type0, type1))
result_type = common_pointer_type (type0, type1);
/* APPLE LOCAL begin blocks 6065211 */
else if (code1 == BLOCK_POINTER_TYPE && VOID_TYPE_P (tt0))
;
else if (code0 == BLOCK_POINTER_TYPE && VOID_TYPE_P (tt1))
;
/* APPLE LOCAL end blocks 6065211 */
else if (VOID_TYPE_P (tt0))
{
/* op0 != orig_op0 detects the case of something
@ -8051,7 +8524,14 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
else
/* Avoid warning about the volatile ObjC EH puts on decls. */
if (!objc_ok)
pedwarn ("comparison of distinct pointer types lacks a cast");
/* APPLE LOCAL begin blocks 6065211 */
{
if (code0 == BLOCK_POINTER_TYPE || code1 == BLOCK_POINTER_TYPE)
pedwarn ("comparison of distinct block types lacks a cast");
else
pedwarn ("comparison of distinct pointer types lacks a cast");
}
/* APPLE LOCAL end blocks 6065211 */
if (result_type == NULL_TREE)
result_type = ptr_type_node;
@ -8088,6 +8568,12 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
result_type = type1;
pedwarn ("comparison between pointer and integer");
}
/* APPLE LOCAL begin radar 5732232 - blocks (C++ cl) */
else if (code0 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op1))
result_type = type0;
else if (code1 == BLOCK_POINTER_TYPE && null_pointer_constant_p (orig_op0))
result_type = type1;
/* APPLE LOCAL end radar 5732232 - blocks (C++ cl) */
break;
case LE_EXPR:

View File

@ -610,6 +610,12 @@ C++ ObjC++ Joined
fnew-abi
C++ ObjC++
; APPLE LOCAL begin nested functions 4258406 4357979
fnested-functions
C ObjC Var(flag_nested_functions)
Allow nested functions.
; APPLE LOCAL end nested functions 4258406 4357979
fnext-runtime
ObjC ObjC++
Generate code for NeXT (Apple Mac OS X) runtime environment
@ -644,6 +650,12 @@ fobjc-gc
ObjC ObjC++ Var(flag_objc_gc)
Enable garbage collection (GC) in Objective-C/Objective-C++ programs
; APPLE LOCAL begin radar 5811887 - blocks
fblocks
C ObjC C++ ObjC++ Var(flag_blocks) Init(-1)
Program supports c/objc extension blocks
; APPLE LOCAL end radar 5811887 - blocks
; Nonzero means that we generate NeXT setjmp based exceptions.
fobjc-sjlj-exceptions
ObjC ObjC++ Var(flag_objc_sjlj_exceptions) Init(-1)

View File

@ -2051,7 +2051,8 @@ expand_call (tree exp, rtx target, int ignore)
/* Operand 0 is a pointer-to-function; get the type of the function. */
funtype = TREE_TYPE (addr);
gcc_assert (POINTER_TYPE_P (funtype));
/* APPLE LOCAL blocks */
gcc_assert (POINTER_TYPE_P (funtype) || TREE_CODE (funtype) == BLOCK_POINTER_TYPE);
funtype = TREE_TYPE (funtype);
/* Munge the tree to split complex arguments into their imaginary

View File

@ -302,6 +302,8 @@ struct cgraph_node *cgraph_master_clone (struct cgraph_node *);
void cgraph_add_new_function (tree);
/* In cgraphunit.c */
/* APPLE LOCAL radar 6305545 */
void lower_if_nested_functions (tree);
bool cgraph_assemble_pending_functions (void);
bool cgraph_varpool_assemble_pending_decls (void);
void cgraph_finalize_function (tree, bool);

View File

@ -458,6 +458,19 @@ cgraph_lower_function (struct cgraph_node *node)
node->lowered = true;
}
/* APPLE LOCAL begin radar 6305545 */
/** lower_if_nested_functions - This routine is called from cplus side only.
Its purpose is to lower block helper (or any other nested function)
which may have been nested in a constructor or destructor. We have to
do this because structors are cloned and are not lowered themselves (which
is the only way to lower the nested functions). */
void
lower_if_nested_functions (tree decl)
{
lower_nested_functions (decl, true);
}
/* APPLE LOCAL end radar 6305545 */
/* DECL has been parsed. Take it, queue it, compile it at the whim of the
logic in effect. If NESTED is true, then our caller cannot stand to have
the garbage collector run at the moment. We would need to either create
@ -476,7 +489,8 @@ cgraph_finalize_function (tree decl, bool nested)
node->local.finalized = true;
node->lowered = DECL_STRUCT_FUNCTION (decl)->cfg != NULL;
if (node->nested)
lower_nested_functions (decl);
/* APPLE LOCAL radar 6305545 */
lower_nested_functions (decl, false);
gcc_assert (!node->nested);
/* If not unit at a time, then we need to create the call graph

View File

@ -64,17 +64,66 @@ convert_to_pointer (tree type, tree expr)
case BOOLEAN_TYPE:
if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
expr = fold_build1 (NOP_EXPR,
lang_hooks.types.type_for_size (POINTER_SIZE, 0),
lang_hooks.types.type_for_size (POINTER_SIZE, 0),
expr);
return fold_build1 (CONVERT_EXPR, type, expr);
default:
error ("cannot convert to a pointer type");
return convert_to_pointer (type, integer_zero_node);
/* APPLE LOCAL begin blocks (C++ ck) */
case BLOCK_POINTER_TYPE:
/* APPLE LOCAL begin radar 5809099 */
if (objc_is_id (type)
|| (TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type))))
/* APPLE LOCAL end radar 5809099 */
return fold_build1 (NOP_EXPR, type, expr);
/* APPLE LOCAL end blocks (C++ ck) */
default:
error ("cannot convert to a pointer type");
return convert_to_pointer (type, integer_zero_node);
}
}
/* APPLE LOCAL begin blocks (C++ ck) */
tree
convert_to_block_pointer (tree type, tree expr)
{
if (TREE_TYPE (expr) == type)
return expr;
if (integer_zerop (expr))
{
tree t = build_int_cst (type, 0);
if (TREE_OVERFLOW (expr) || TREE_CONSTANT_OVERFLOW (expr))
t = force_fit_type (t, 0, TREE_OVERFLOW (expr),
TREE_CONSTANT_OVERFLOW (expr));
return t;
}
switch (TREE_CODE (TREE_TYPE (expr)))
{
case BLOCK_POINTER_TYPE:
return fold_build1 (NOP_EXPR, type, expr);
case INTEGER_TYPE:
if (TYPE_PRECISION (TREE_TYPE (expr)) != POINTER_SIZE)
expr = fold_build1 (NOP_EXPR,
lang_hooks.types.type_for_size (POINTER_SIZE, 0),
expr);
return fold_build1 (CONVERT_EXPR, type, expr);
case POINTER_TYPE:
/* APPLE LOCAL radar 5809099 */
if (objc_is_id (TREE_TYPE (expr)) || VOID_TYPE_P (TREE_TYPE (TREE_TYPE (expr))))
return build1 (NOP_EXPR, type, expr);
/* fall thru */
default:
error ("cannot convert to a block pointer type");
return convert_to_block_pointer (type, integer_zero_node);
}
}
/* APPLE LOCAL end blocks (C++ ck) */
/* Avoid any floating point extensions from EXP. */
tree
strip_float_extensions (tree exp)
@ -459,6 +508,8 @@ convert_to_integer (tree type, tree expr)
{
case POINTER_TYPE:
case REFERENCE_TYPE:
/* APPLE LOCAL radar 6035389 */
case BLOCK_POINTER_TYPE:
if (integer_zerop (expr))
return build_int_cst (type, 0);

View File

@ -26,5 +26,7 @@ extern tree convert_to_pointer (tree, tree);
extern tree convert_to_real (tree, tree);
extern tree convert_to_complex (tree, tree);
extern tree convert_to_vector (tree, tree);
/* APPLE LOCAL blocks */
extern tree convert_to_block_pointer (tree, tree);
#endif /* GCC_CONVERT_H */

View File

@ -1,9 +1,661 @@
2008-11-07 Fariborz Jahanian <fjahanian@apple.com>
Radar 5847976
* decl.c (synth_block_byref_id_object_copy_func): Takes new 'flag' argument
and produces the new much simplified API.
(synth_block_byref_id_object_dispose_func): Ditto.
(new_block_byref_decl): Turn off -fobjc-gc so we don't get
bogus warning on field declared as __weak.
(init_byref_decl): Takes a new 'flag' argument and passes
it down to synth_block_byref_id_object_copy_func and
synth_block_byref_id_object_dispose_func.
(cp_finish_decl): Calculates the flag for the block
variable declaration and passes it down to init_byref_decl.
* parser.c (build_block_struct_initlist): Removes call to
copy_in_object (not needed).
(synth_copy_helper_block_func): Produce the new, simplified
API.
(synth_destroy_helper_block_func): Ditto.
(build_block_byref_decl): Copy over COPYABLE_WEAK_BLOCK flag.
2008-10-31 Fariborz Jahanian <fjahanian@apple.com>
Radar 6175959
* parser.c (synth_copy_helper_block_func): Use the new API
_Block_object_assign for ObjC object copying.
(block_object_dispose): New
(synth_destroy_helper_block_func): Call block_object_dispose
to use new _Block_object_dispose API for ObjC object release.
2008-10-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 6231433
* typeck.c (objc_compare_types, objc_have_common_type):
Take an extra argument for better diagnostics.
* call.c: Ditto
2010-03-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 7760213
* semantics.c (get_final_block_variable): Diagnose
access of __block array.
2010-03-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 7735196
* cp/parser.c (build_block_struct_initlist):
Set BLOCK_USE_STRET flag in block descriptor for
blocks which return their aggregate value in memory.
2010-03-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 7721728
* semantics.c (get_final_block_variable): Diagnose
importation of copied-in variables.
2009-02-11 Fariborz Jahanian <fjahanian@apple.com>
Radar 6573923
* decl.c (synth_block_byref_id_object_copy_func,
synth_block_byref_id_object_dispose_func): Set BLOCK_BYREF_CALLER
flag in call to copy/dispose helper functions.
2009-02-11 Fariborz Jahanian <fjahanian@apple.com>
Radar 6545782
* semantics.c (get_final_block_variable): New
(finish_id_expression): Call get_final_block_variable.
2008-10-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 6302949
* parser.c (objc_cp_parser_at_property): Warn on missing
',' separator for property attribute list.
2008-10-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 6305545
* semantics.c (expand_or_defer_fn): Lower nested function
of the structors.
2008-10-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 5847213 (minor tweak)
* parser.c (build_block_descriptor_type):
Make descriptor_ptr_type and descriptor_ptr_type_with_copydispose
visible to pch.
2008-10-17 Fariborz Jahanian <fjahanian@apple.com>
Radar 6289031
* decl.c: Removed all code related to
radar 6083129 (byref escapes).
2008-10-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 6271728
* parser.c (cp_parser_objc_method_definition_list): Method
definition always start with '{', or it is error.
2008-10-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 6275956
* semantics.c (finish_this_expr): Reference to "this" in a block
must be looked up.
2008-10-10 Fariborz Jahanian <fjahanian@apple.com>
Radar 5847213 - New Block ABI
* typeck.c (build_block_call): New code gen for block call.
* parser.c (build_descriptor_block_decl) New
(build_block_struct_type): New block literal type.
(build_block_struct_initlist): New block literal initializers.
(build_block_literal_tmp): New block literal variable initialization.
(synth_copy_helper_block_func): Fixed a minor bug (unrelated to this radar).
(build_block_internal_types): Removed.
(build_block_descriptor_type): New routine to build build descriptor type.
(make_block_pointer_declarator): Unnecessary code is removed.
2008-10-02 Fariborz Jahanian <fjahanian@apple.com>
Radar 6246527
* parser.c (cp_parser_block_literal_expr): Call to do the delta
on printf attribute.
2008-09-30 Fariborz Jahanian <fjahanian@apple.com>
Radar 6230297
* c-parser.c (build_block_struct_initlist): 'trivial'
block temporary can be static as well.
(build_block_literal_tmp): Accomodate 'trivial' block
literal temporary variable as static.
2008-09-30 Fariborz Jahanian <fjahanian@apple.com>
Radar 6230297
* parser.c (build_block_struct_initlist): 'trivial'
block temporary can be static as well.
(build_block_literal_tmp): Accomodate 'trivial' block
literal temporary variable as static.
2008-09-30 Fariborz Jahanian <fjahanian@apple.com>
Radar 6225809
* parser.c (build_block_byref_decl): Add __block vaiables
to intervening blocks.
2008-09-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 6154598
tree.c (maybe_dummy_object): Build expression for
copied in "this" in the block.
2008-09-26 Fariborz Jahanian <fjahanian@apple.com>
Radar 6243400
* parser.c (build_block_struct_type): Mostly rewritten
to use C++'s API for building block's main struct so structors
for those data members requiring them are synthesized and
used.
2008-09-25 Fariborz Jahanian <fjahanian@apple.com>
Radar 6244520
* decl.c (new_block_byref_decl): New field added to
struct __Block_byref_x.
(init_byref_decl): Above field initialized to NULL.
2008-09-25 Fariborz Jahanian <fjahanian@apple.com>
Radar 6237713
* parser.c (cp_parser_block_literal_expr): Parse
and set attribute on block literals.
2008-09-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 6214617
* parser.c (cp_block_requires_copying): New
(build_block_struct_type): Set BlockImportsCxxObjects flag.
(build_block_struct_initlist): Set BLOCK_HAS_CXX_OBJ if need be.
(synth_copy_helper_block_func): Call copy ctor if copied in object has one.
(synth_destroy_helper_block_func): Call dtor on cxx object.
2008-09-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 6212722 (tweak)
* parser.c (build_block_ref_decl): Use decay_conversion.
2008-09-09 Fariborz Jahanian <fjahanian@apple.com>
Radar 6169580
* decl.c (synth_block_byref_id_object_copy_func): Pass new flag
to finish_function.
(synth_block_byref_id_object_): Ditto.
(finish_function): Don't pop the nested class when synthesizing
block helpers.
* semantics.c (finish_id_expression): Added logic to attach
copied-in "this" to stand-alone field reference in a block.
* parser.c (synth_copy_helper_block_func, synth_destroy_helper_block_func):
Pass new flag to finish_function.
(cp_parser_block_literal_expr): When block is in non-static member
function, need to import "this" as a read-only copied in variable.
2008-09-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 6169527
* parser.c (build_block_struct_type): Set CLASSTYPE_AS_BASE.
(build_block_internal_types): Ditto.
(build_block_struct_initlist): Rewritten.
(build_block_literal_tmp): Rewritten.
(build_block_ref_decl): Just add copied-in variable to
the scope.
(declare_block_prologue_local_vars): Rewritten.
(declare_block_prologue_local_byref_vars): New
(block_build_prologue): Call declare_block_prologue_local_byref_vars
for byref variables.
2008-09-03 Fariborz Jahanian <fjahanian@apple.com>
Radar 6185344
* typeck.c (check_return_expr): Added extra check
for return type checking.
* parser.c (cp_parser_direct_declarator): Added
extra check for type used as block return type.
(cp_parser_block_literal_expr): Parse and handle
user provided block return type syntax.
2008-08-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 6160536
* parser.c (cp_parser_block_literal_expr): Call build_block_helper_name
to get pretty name for block helper function.
2008-08-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 6180456
* decl.c (synth_block_byref_id_object_copy_func): Use different
API when copying __block object in c language.
(synth_block_byref_id_object_dispose_func): Use different
API when releasing a __block object in c.
* parser.c (synth_copy_helper_block_func): Refactored to
call build_block_byref_assign_copy_decl().
2008-08-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 6087117
* typeck.c (convert_arguments): Takes an extra argument
for distiguinsing block call to function calls.
(build_function_call): Tell convert_arguments if we
are calling a block.
2008-08-24 Caroline Tice <ctice@apple.com.
Radar 6144664
* parser.c (build_block_byref_decl): Assign the
source location for each byref decl to the source
location of the helper function decl.
(build_block_ref_decl): Ditto for ref decls.
2008-07-21 Fariborz Jahanian <fjahanian@apple.com>
Radar 6029624
* call.c (objcp_reference_related_p): New
* cp-tree.h (objcp_reference_related_p): New decl.
2008-06-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 5982990
* parser.c (cp_parser_compound_statement): Take a new
argument which is used to call objc_mark_locals_volatile.
(cp_parser_primary_expression, cp_parser_statement,
etc.): add extra argument in calling cp_parser_compound_statement.
(cp_parser_objc_synchronized_statement): Passes
flag_objc_sjlj_exceptions as last argument in calling
cp_parser_compound_statement.
2008-03-20 Fariborz Jahanian <fjahanian@apple.com>
Radar 5802025
* typeck.c (finish_class_member_access_expr): Generate getter call
from an OBJC_PROPERTY_REFERENCE_EXPR.
2008-03-19 Fariborz Jahanian <fjahanian@apple.com>
Radar 5733674
* decl.c (expand_static_init): Generate write barrier for
static initialization in objective-c++ mode.
2008-02-20 Fariborz Jahanian <fjahanian@apple.com>
Radar 5732232 - code gen part 2.
* cp-lang.c (c_finish_return): Defined these
templates to get a clean compile.
2007-08-22 Fariborz Jahanian <fjahanian@apple.com>
Radar 4947311
* parser.c (cp_parser_objc_protocol_declaration): Takes attribute list
as extra argument and passes it down to
objc_declare_protocols/objc_start_protocol.
(cp_parser_objc_class_interface): Now receives attribute list as input.
(cp_parser_objc_declaration): Parses attribute list and passes it down
to cp_parser_objc_class_interface/cp_parser_objc_protocol_declaration.
2007-07-24 Fariborz Jahanian <fjahanian@apple.com>
Radar 5355344
* cp-tree.h (cp_objc_protocol_id_list): New declaration
* cp-lang.c (cp_objc_protocol_id_list): New stub
* parser.c (cp_parser_type_name): Added code to disambiguate
conditional from a protocol type.
(cp_parser_objc_tentative_protocol_refs_opt): New
2007-07-13 Fariborz Jahanian <fjahanian@apple.com>
Radar 5277239
* parser.c (cp_parser_objc_reference_expression): New routine to
build a property reference expression.
(cp_objc_property_reference_prefix): New routine to recognize a
property dot syntax.
(cp_parser_primary_expression): Build a property reference expression
when a property dot-syntax is recognized.
(cp_parser_type_name): Exclude property dot-syntax from being recognized
as a type name.
(cp_parser_class_name): Exclude property dot-syntax from being recognized
as a class name.
2007-07-10 Fariborz Jahanian <fjahanian@apple.com>
Radar 5285911
* typeck.c (finish_class_member_access_expr): Call
objc_build_property_reference_expr instead of objc_build_getter_call.
2007-06-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 5276085
* typeck.c (build_modify_expr): Call objc_weak_reference_expr
instead of objc_remove_weak_read.
* parser.c (cp_parser_cast_expression): Call
objc_build_weak_reference_tree instead of objc_generate_weak_read.
(cp_parser_cast_expression): Ditto.
2007-05-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 5202926
* mangle.c (write_mangled_name): Removed suppression in last patch.
2007-04-20 Fariborz Jahanian <fjahanian@apple.com>
Radar 5130983
* c-common.h (enum lvalue_use): New enumerator lv_foreach
added.
* c-common.c (lvalue_error): Diagnose on lv_foreach.
2007-04-20 Fariborz Jahanian <fjahanian@apple.com>
Radar 5130983
* parser.c (cp_parser_parse_foreach_stmt): Parse selector expression
as an expression.
(objc_foreach_stmt): Issue diagnostic on non-lavlue selector
expression.
2007-03-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 4947014 - objc atomic property
* lex.c (RID_NONATOMIC): Add
* parser.c (objc_cp_parser_at_property): Recognize 'nonatomic' as
new property attribute.
2007-03-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 4564694
* lex.c (RID_AT_PACKAGE): Add
* parser.c (cp_lexer_get_preprocessor_token): Parse @package.
2006-12-14 Fariborz Jahanian <fjahania@apple.com>
Radar 4854605
* parser.c (objc_foreach_stmt): Set iterator
to nil.
2006-09-01 Fariborz Jahanian <fjahania@apple.com>
Radar 4712269
* typeck.c (build_unary_op): Call objc_build_incr_decr_setter_call
for potential ince/decr pre/post expressions involving properties.
2006-07-21 Fariborz Jahanian <fjahanian@apple.com>
Radar 4631818
* parser.c (cp_parser_parse_foreach_stmt): New.
(cp_parser_iteration_statement): Remove old code.
Replace it with call to cp_parser_parse_foreach_stmt.
(cp_parser_simple_declaration): Remove old code.
(cp_parser_init_declarator): Remove old code.
2006-08-31 Fariborz Jahanian <fjahanian@apple.com>
Radar 4697411
* typeck.c (build_class_member_access_expr): Call
objc_volatilize_component_ref.
2006-07-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 4592503
* class.c (layout_class_type): Check on illegal use of __weak
on struct fields.
* decl.c (start_decl): Check on illegal use of __weak on
variable declarations.
2006-07-14 Fariborz Jahanian <fjahanian@apple.com>
Radar 4621020
* lex.c (reswords): Added entry for 'weak' attribute keyword.
* parser.c (objc_cp_parser_at_property): Recorgnize 'weak'attribute.
2006-06-26 Fariborz Jahanian <fjahanian@apple.com>
Radar 4591909
* lex.c (reswords): New entry for 'dynamic' attribute.
* parser.c (objc_cp_parser_at_property): Change to parse new
attribute syntax.
2006-05-18 Fariborz Jahanian <fjahanian@apple.com>
Radar 4548636 (objc attributes on class)
* parser.c (objc_attr_follwed_by_at_keyword): New routine to disambiguate
attribute before a type and attribute before an @interface declaration..
(cp_parser_declaration): Handle case of attribute list which can be
followed by an @interface.
(cp_parser_objc_class_interface): Parse possible attribute list before
parsing @interface.
(cp_parser_objc_declaration): Recognize 'attribute' as a valid token which
can start an @interface declaration.
2006-05-16 Fariborz Jahanian <fjahanian@apple.com>
Radar 4547045
* parser.c (objc_foreach_stmt): Fix a thinko.
2006-04-12 Fariborz Jahanian <fjahanian@apple.com>
Radar 4507230
* parser.c (objc_foreach_stmt): Check for valid objc
objects in foreach header.
2006-04-06 Fariborz Jahanian <fjahanian@apple.com>
Radar 4436866
(Missing copies attribute)
* lex.c (reswords): New keyword 'copies' added.
* parser.c (objc_cp_parser_at_property): Parse 'copies'
attribute.
2006-02-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4445586
* semantics.c (begin_do_stmt): DO_STMT nodes take an
extra argument to build.
2005-11-08 Fariborz Jahanian <fjahanian@apple.com>
Radar 4330422
* typeck.c (comp_ptr_ttypes_real): Remove the hack. un-volatize the
artificially 'volatized' type before doing pointer comparison.
2005-08-15 Ziemowit Laski <zlaski@apple.com>
Radar 4093475
* parser.c (cp_parser_objc_interstitial_code): Catch stray
'{' and '}' tokens and issue appropriate errors.
(cp_parser_objc_method_prototype_list,
cp_parser_objc_method_definition_list): Bail out if end-of-file
is seen; issue error if trailing '@end' is not seen.
2008-08-06 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305 - work in progress.
* parser.c (clean_and_exit): Clean up if inside
a function.
(cp_parser_block_literal_expr): Set DECL_NO_STATIC_CHAIN
if inside a function.
2008-08-05 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305 - work in progress.
* decl.c (init_byref_decl): Generate c-style helper
functions for compose/dispose helpers.
2008-08-04 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305 - work in progress.
* decl.c (synth_block_byref_id_object_copy_func,
synth_block_byref_id_object_dispose_func,
block_start_struct, block_finish_struct,
new_block_byref_decl, init_byref_decl): New routines.
(cp_finish_decl): Build the APIed version of
a __byref local vriable.
* semantics.c (finish_id_expression): Add a __byref
variable to the list of such variables for current
block.
* parser.c (build_component_ref): Fix to make it work.
(cp_parser_block_literal_expr): Push/pop language-c,
set context of the helper function.
(declare_block_prologue_local_vars): Mend tree for
the built-in local variables in the helper prologue.
2008-07-30 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305
* call.c (standard_conversion): Allow conversion of 'id'
type to a block pointer.
2008-07-30 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305
* typeck.c (build_block_call): New
(build_function_call): Call build_block_call
for block calls.
* call.c (standard_conversion): Remove "void *" to
block pointer conversion.
2008-07-29 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305
* call.c (standard_conversion): Allow assignment of
"void *" to block pointer object.
2008-07-28 Fariborz Jahanian <fjahanian@apple.com>
Radar 6040305
* typeck.c (comptypes): block-pointer types'
return type get special treatment.
2008-07-16 Eugene Marinelli <marinelli@apple.com>
Radar 5559195
* decl.c (cxx_maybe_build_cleanup): When considering whether to
build a cleanup for a class type, use
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY and
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE instead of
TYPE_HAS_NONTRIVIAL_DESTRUCTOR to determine whether it must be
output.
2008-07-15 Eugene Marinelli <marinelli@apple.com>
Radar 5559195
* cp-tree.h (struct lang_type_class): Add destructor_triviality_final
flag to mark when has_nontrivial_destructor_body and
destructor_nontrivial_because_of_base are final. Add accessor for
this flag.
* parser.c (cp_parser_statement_seq_opt): Use
CLASSTYPE_DESTRUCTOR_TRIVIALITY_FINAL to determine if
destructor should be checked for being empty, and set it if
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY is changed.
2008-07-10 Eugene Marinelli <marinelli@apple.com>
Radar 5559195
* init.c (push_base_cleanups): Check flags indicating whether
destructor of base class has a nontrivial body, has a base destructor
that must be called, or is private to determine whether it should be
called by the derived class. Set
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE to 1 if it has
members that must be deleted.
* class.c (check_bases, finish_struct_bits,
add_implicitly_declared_members): Set
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE and
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY based on base classes.
(check_methods): Set CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY to 1
whenever a user-declared destructor is seen as a conservative
assumption.
* cp-tree.h (struct lang_type_class): Add
has_nontrivial_destructor_body and
destructor_nontrivial_because_of_base flags. Decrement remaining
dummy bits. Add accessors for these flags.
* parser.c (cp_parser_statement_seq_opt): Unmark
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY and then set it again only if
a statement is parsed.
2007-05-07 Fariborz Jahanian <fjahanian@apple.com>
Radar 4157812
* parser.c (cp_parser_objc_method_keyword_params): Recognize optional
method argument attribute.
2007-03-21 Fariborz Jahanian <fjahanian@apple.com>
Radar 2848255
* except.c (do_begin_catch): Take a new argument to decide
to call objc_begin_catch for objc exceptions.
(objcp_build_eh_type_type): New.
(do_end_catch): Call objc_end_catch for objc type
exceptions.
(expand_start_catch_block): Add new argument to do_begin_catch call.
(build_throw): Call objc_throw_exception for throwing objc type objects.
* cp-tree.h (objc2_valid_objc_catch_type, objcp_build_eh_type_type):
New extern decl.
* parser.c (cp_parser_objc_try_catch_finally_stateme): Add syntax for
@catch(...).
2006-04-26 Fariborz Jahanian <fjahanian@apple.com>
Radar 3803157 (method attributes)
* parser.c (cp_parser_objc_maybe_attributes): New.
(cp_parser_objc_method_keyword_params): Parse attributes at end
of method declaration.
(cp_parser_objc_method_tail_params_opt): Parse attributes after
'...'.
(cp_parser_objc_method_signature): Retreive method attribute for
the caller.
(cp_parser_objc_method_prototype_list): Pass new arg. to
cp_parser_objc_method_signature and pass attributes to
objc_add_method_declaration.
(cp_parser_objc_method_definition_list): Pass new arg. to
cp_parser_objc_method_signature and pass attributes to
objc_start_method_definition.
2006-03-27 Fariborz Jahanian <fjahanian@apple.com>
Radar 4133425
* lex.c (unqualified_name_lookup_error): Issue diagnostic
for private 'ivar' access.
2006-02-02 Fariborz Jahanian <fjahanian@apple.com>
Radar 4426814
* typeck.c (build_modify_expr): Undo call to objc_read_weak
on LHS of the assignment.
* parser.c (cp_parser_cast_expression): Central place to add
objc_read_weak call on expressions of __weak objects.
2005-12-15 Fariborz Jahanian <fjahanian@apple.com>
Radar 4229905
* typeck.c (composite_pointer_type): Call objc_have_common_type
when comparing two objective-c pointer types.
2005-10-17 Fariborz Jahanian <fjahanian@apple.com>
Radar 4290840
* parser.c (cp_parser_objc_method_keyword_params): Check for valid
method parameters and issue error.
(cp_parser_objc_method_definition_list): Check for invalid tokens
which cannot start a function definition.
2005-08-02 Ziemowit Laski <zlaski@apple.com>
Radar 4185810
* parser.c (cp_parser_compound_statement): Continue
parsing even if the initial '{' is missing; an error
message is already being produced.
(cp_parser_statement_seq_opt): In addition to '}' and
end-of-file, a statement sequence may also be terminated
by a stray 'else' or '@end'.
# APPLE LOCAL begin for-fsf-4_4 3274130 5295549
2007-08-03 Geoffrey Keating <geoffk@apple.com>

View File

@ -281,7 +281,8 @@ build_call (tree function, tree parms)
function = build_addr_func (function);
gcc_assert (TYPE_PTR_P (TREE_TYPE (function)));
/* APPLE LOCAL blocks 6040305 */
gcc_assert (TYPE_PTR_P (TREE_TYPE (function)) || TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE);
fntype = TREE_TYPE (TREE_TYPE (function));
gcc_assert (TREE_CODE (fntype) == FUNCTION_TYPE
|| TREE_CODE (fntype) == METHOD_TYPE);
@ -657,7 +658,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
if (same_type_p (from, to))
return conv;
if ((tcode == POINTER_TYPE || TYPE_PTR_TO_MEMBER_P (to))
/* APPLE LOCAL blocks 6040305 (ck) */
if ((tcode == POINTER_TYPE || tcode == BLOCK_POINTER_TYPE || TYPE_PTR_TO_MEMBER_P (to))
&& expr && null_ptr_cst_p (expr))
conv = build_conv (ck_std, to, conv);
else if ((tcode == INTEGER_TYPE && fcode == POINTER_TYPE)
@ -810,6 +812,8 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
if (ARITHMETIC_TYPE_P (from)
|| fcode == ENUMERAL_TYPE
|| fcode == POINTER_TYPE
/* APPLE LOCAL blocks 6040305 (cl) */
|| fcode == BLOCK_POINTER_TYPE
|| TYPE_PTR_TO_MEMBER_P (from))
{
conv = build_conv (ck_std, to, conv);
@ -877,6 +881,15 @@ reference_related_p (tree t1, tree t2)
&& DERIVED_FROM_P (t1, t2)));
}
/* APPLE LOCAL begin radar 6029624 */
/* Used in objective-c++, same as reference_related_p */
bool
objcp_reference_related_p (tree t1, tree t2)
{
return reference_related_p (t1, t2);
}
/* APPLE LOCAL end radar 6029624 */
/* Returns nonzero if T1 is reference-compatible with T2. */
static bool
@ -3520,10 +3533,19 @@ build_conditional_expr (tree arg1, tree arg2, tree arg3)
cv-qualification of either the second or the third operand.
The result is of the common type. */
else if ((null_ptr_cst_p (arg2)
&& (TYPE_PTR_P (arg3_type) || TYPE_PTR_TO_MEMBER_P (arg3_type)))
/* APPLE LOCAL begin blocks 6040305 (co) */
&& (TYPE_PTR_P (arg3_type) || TYPE_PTR_TO_MEMBER_P (arg3_type)
|| TREE_CODE (arg3_type) == BLOCK_POINTER_TYPE))
/* APPLE LOCAL end blocks 6040305 (co) */
|| (null_ptr_cst_p (arg3)
&& (TYPE_PTR_P (arg2_type) || TYPE_PTR_TO_MEMBER_P (arg2_type)))
|| (TYPE_PTR_P (arg2_type) && TYPE_PTR_P (arg3_type))
/* APPLE LOCAL begin blocks 6040305 (co) */
&& (TYPE_PTR_P (arg2_type) || TYPE_PTR_TO_MEMBER_P (arg2_type)
|| TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE))
|| ((TYPE_PTR_P (arg2_type)
|| TREE_CODE (arg2_type) == BLOCK_POINTER_TYPE)
&& (TYPE_PTR_P (arg3_type)
|| TREE_CODE (arg3_type) == BLOCK_POINTER_TYPE))
/* APPLE LOCAL end blocks 6040305 (co) */
|| (TYPE_PTRMEM_P (arg2_type) && TYPE_PTRMEM_P (arg3_type))
|| (TYPE_PTRMEMFUNC_P (arg2_type) && TYPE_PTRMEMFUNC_P (arg3_type)))
{

View File

@ -1282,6 +1282,12 @@ check_bases (tree t,
TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (basetype);
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
|= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype);
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
if (CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (basetype)
|| CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (basetype))
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (t) = 1;
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
TYPE_HAS_COMPLEX_ASSIGN_REF (t)
|= TYPE_HAS_COMPLEX_ASSIGN_REF (basetype);
TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (basetype);
@ -1440,6 +1446,13 @@ finish_struct_bits (tree t)
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (variants)
= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t);
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (variants) =
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (t);
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (variants) =
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (t);
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
TYPE_POLYMORPHIC_P (variants) = TYPE_POLYMORPHIC_P (t);
TYPE_BINFO (variants) = TYPE_BINFO (t);
@ -2540,6 +2553,13 @@ add_implicitly_declared_members (tree t,
{
bool lazy_p = true;
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
/* Since this is an empty destructor, it can only be nontrivial
because one of its base classes has a destructor that must be
called. */
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (t) = 1;
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
if (TYPE_FOR_JAVA (t))
/* If this a Java class, any non-trivial destructor is
invalid, even if compiler-generated. Therefore, if the
@ -3729,7 +3749,16 @@ check_methods (tree t)
}
/* All user-declared destructors are non-trivial. */
if (DECL_DESTRUCTOR_P (x))
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1;
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
{
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1;
/* Conservatively assume that destructor body is nontrivial. Will
be unmarked during parsing of function body if it happens to be
trivial. */
CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (t) = 1;
}
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
}
}

View File

@ -200,8 +200,20 @@ gimplify_cp_loop (tree cond, tree body, tree incr, tree attrs,
stmt_list = NULL_TREE;
entry = NULL_TREE;
break_block = begin_bc_block (bc_break);
cont_block = begin_bc_block (bc_continue);
/* APPLE LOCAL begin C* language */
/* Order of label addition to stack is important for objc's foreach-stmt. */
/* APPLE LOCAL radar 4667060 */
if (inner_foreach == integer_zero_node)
{
cont_block = begin_bc_block (bc_continue);
break_block = begin_bc_block (bc_break);
}
else
{
break_block = begin_bc_block (bc_break);
cont_block = begin_bc_block (bc_continue);
}
/* APPLE LOCAL end C* language */
/* If condition is zero don't generate a loop construct. */
if (cond && integer_zerop (cond))
@ -252,10 +264,19 @@ gimplify_cp_loop (tree cond, tree body, tree incr, tree attrs,
}
}
/* APPLE LOCAL begin radar 4547045 */
/* Pop foreach's inner loop break label so outer loop's
break label becomes target of inner loop body's break statements.
*/
t = NULL_TREE;
gimplify_stmt (&body);
gimplify_stmt (&incr);
body = finish_bc_block (bc_continue, cont_block, body);
/* APPLE LOCAL begin radar 4547045 */
/* Push back inner loop's own 'break' label so rest
of code works seemlessly. */
/* APPLE LOCAL radar 4667060 */
append_to_statement_list (top, &stmt_list);
append_to_statement_list (body, &stmt_list);

View File

@ -259,5 +259,37 @@ init_shadowed_var_for_decl (void)
tree_map_eq, 0);
}
/* APPLE LOCAL begin radar 5741070 */
/* Given an IDENTIFIER tree for a class interface, find (if possible) and
return the record type for the class interface. */
tree
c_return_interface_record_type (tree typename)
{
enum tree_code_class class;
enum tree_code code;
tree retval = NULL;
if (typename == NULL)
return retval;
code = TREE_CODE (typename);
class = TREE_CODE_CLASS (code);
if (code != IDENTIFIER_NODE
|| class != tcc_exceptional)
return retval;
if (TREE_TYPE (typename)
&& TREE_CODE (TREE_TYPE (typename)) == RECORD_TYPE)
retval = TREE_TYPE (typename);
if (retval
&& TREE_CODE (retval) != RECORD_TYPE)
retval = NULL;
return retval;
}
/* APPLE LOCAL end radar 5741070 */
#include "gt-cp-cp-objcp-common.h"

View File

@ -166,4 +166,10 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE cxx_omp_privatize_by_reference
/* APPLE LOCAL begin radar 6353006 */
#undef LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE
#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
c_build_generic_block_struct_type
/* APPLE LOCAL end radar 6353006 */
#endif /* GCC_CP_OBJCP_COMMON */

View File

@ -1052,6 +1052,13 @@ struct lang_type_class GTY(())
unsigned has_complex_assign_ref : 1;
unsigned non_aggregate : 1;
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
unsigned has_nontrivial_destructor_body : 1;
unsigned destructor_nontrivial_because_of_base : 1;
unsigned destructor_triviality_final : 1;
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
/* When adding a flag here, consider whether or not it ought to
apply to a template instance if it applies to the template. If
so, make sure to copy it in instantiate_class_template! */
@ -1059,7 +1066,9 @@ struct lang_type_class GTY(())
/* There are some bits left to fill out a 32-bit word. Keep track
of this by updating the size of this bitfield whenever you add or
remove a flag. */
unsigned dummy : 12;
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
unsigned dummy : 10;
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
tree primary_base;
VEC(tree_pair_s,gc) *vcall_indices;
@ -2439,6 +2448,8 @@ extern void decl_shadowed_for_var_insert (tree, tree);
|| TREE_CODE (TYPE) == ENUMERAL_TYPE \
|| ARITHMETIC_TYPE_P (TYPE) \
|| TYPE_PTR_P (TYPE) \
/* APPLE LOCAL blocks 6040305 */ \
|| TREE_CODE (TYPE) == BLOCK_POINTER_TYPE \
|| TYPE_PTRMEMFUNC_P (TYPE))
/* [dcl.init.aggr]
@ -2520,6 +2531,20 @@ extern void decl_shadowed_for_var_insert (tree, tree);
#define TYPE_HAS_NONTRIVIAL_DESTRUCTOR(NODE) \
(TYPE_LANG_FLAG_4 (NODE))
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
/* One if the body of the destructor of class type NODE has been shown to do
nothing, else zero. */
#define CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->has_nontrivial_destructor_body)
/* One if destructor of this type must be called by its base classes because
one of its base classes' destructors must be called. */
#define CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->destructor_nontrivial_because_of_base)
/* One if the values of CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE
and CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY are final. */
#define CLASSTYPE_DESTRUCTOR_TRIVIALITY_FINAL(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->destructor_triviality_final)
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
/* Nonzero for class type means that copy initialization of this type can use
a bitwise copy. */
#define TYPE_HAS_TRIVIAL_INIT_REF(NODE) \
@ -3704,6 +3729,8 @@ typedef enum cp_declarator_kind {
cdk_pointer,
cdk_reference,
cdk_ptrmem,
/* APPLE LOCAL blocks 6040305 (ch) */
cdk_block_pointer,
cdk_error
} cp_declarator_kind;
@ -3772,6 +3799,13 @@ struct cp_declarator {
/* For cdk_ptrmem, the class type containing the member. */
tree class_type;
} pointer;
/* APPLE LOCAL begin blocks 6040305 (ch) */
/* For cdk_block_pointer. */
struct {
/* The cv-qualifiers for the pointer. */
cp_cv_quals qualifiers;
} block_pointer;
/* APPLE LOCAL end blocks 6040305 (ch) */
} u;
};
@ -3922,6 +3956,8 @@ extern tree push_throw_library_fn (tree, tree);
extern tree check_tag_decl (cp_decl_specifier_seq *);
extern tree shadow_tag (cp_decl_specifier_seq *);
extern tree groktypename (cp_decl_specifier_seq *, const cp_declarator *);
/* APPLE LOCAL 6339747 */
extern tree grokblockdecl (cp_decl_specifier_seq *, const cp_declarator *);
extern tree start_decl (const cp_declarator *, cp_decl_specifier_seq *, int, tree, tree, tree *);
extern void start_decl_1 (tree, bool);
extern void cp_finish_decl (tree, tree, bool, tree, int);
@ -4600,5 +4636,11 @@ extern void cp_genericize (tree);
extern void cp_cpp_error (cpp_reader *, int,
const char *, va_list *)
ATTRIBUTE_GCC_CXXDIAG(3,0);
/* APPLE LOCAL radar 5741070 */
extern tree c_return_interface_record_type (tree);
/* APPLE LOCAL begin blocks 6040305 (cg) */
extern cp_declarator* make_block_pointer_declarator (tree, cp_cv_quals,
cp_declarator *);
/* APPLE LOCAL end blocks 6040305 (cg) */
#endif /* ! GCC_CP_TREE_H */

View File

@ -52,7 +52,8 @@ Boston, MA 02110-1301, USA. */
#include "timevar.h"
#include "tree-flow.h"
static tree grokparms (cp_parameter_declarator *, tree *);
/* APPLE LOCAL blocks 6040305 (ce) */
tree grokparms (cp_parameter_declarator *, tree *);
static const char *redeclaration_error_message (tree, tree);
static int decl_jump_unsafe (tree);
@ -3800,7 +3801,26 @@ shadow_tag (cp_decl_specifier_seq *declspecs)
return t;
}
/* APPLE LOCAL begin blocks 6339747 */
/* Decode a block literal type, such as "int **", returning a ...FUNCTION_DECL node. */
tree
grokblockdecl (cp_decl_specifier_seq *type_specifiers,
const cp_declarator *declarator)
{
tree decl;
tree attrs = type_specifiers->attributes;
type_specifiers->attributes = NULL_TREE;
decl = grokdeclarator (declarator, type_specifiers, BLOCKDEF, 0, &attrs);
if (attrs)
cplus_decl_attributes (&decl, attrs, 0);
return decl;
}
/* APPLE LOCAL end blocks 6339747 */
/* Decode a "typename", such as "int **", returning a ..._TYPE node. */
tree
@ -5002,10 +5022,15 @@ make_rtl_for_nonlocal_decl (tree decl, tree init, const char* asmspec)
if (DECL_LANG_SPECIFIC (decl) && DECL_IN_AGGR_P (decl))
{
gcc_assert (TREE_STATIC (decl));
/* APPLE LOCAL begin templated static data 6298605 */
/* An in-class declaration of a static data member should be
external; it is only a declaration, and not a definition. */
if (init == NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
external if the decl is accessible from outside this
translation unit (eg something not in an anonymous
namespace); it is only a declaration, and not a
definition. */
if (init == NULL_TREE && TREE_PUBLIC (decl))
gcc_assert (DECL_EXTERNAL (decl));
/* APPLE LOCAL end templated static data 6298605 */
}
/* We don't create any RTL for local variables. */
@ -5160,6 +5185,367 @@ value_dependent_init_p (tree init)
return false;
}
/* APPLE LOCAL begin blocks 6040305 (cr) */
#define BLOCK_ALIGN_MAX 18
static tree block_byref_id_object_copy[BLOCK_BYREF_CURRENT_MAX*(BLOCK_ALIGN_MAX+1)];
static tree block_byref_id_object_dispose[BLOCK_BYREF_CURRENT_MAX*(BLOCK_ALIGN_MAX+1)];
/**
This routine builds:
void __Block_byref_id_object_copy(struct Block_byref_id_object *dst,
struct Block_byref_id_object *src) {
_Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
_Block_object_assign(&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // blocks
} */
static void
synth_block_byref_id_object_copy_func (int flag, int kind)
{
tree stmt;
tree dst_arg, src_arg;
tree dst_obj, src_obj;
tree call_exp;
gcc_assert (block_byref_id_object_copy[kind]);
/* Set up: (void* _dest, void*_src) parameters. */
dst_arg = build_decl (PARM_DECL, get_identifier ("_dst"),
ptr_type_node);
TREE_USED (dst_arg) = 1;
DECL_ARG_TYPE (dst_arg) = ptr_type_node;
src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
ptr_type_node);
TREE_USED (src_arg) = 1;
DECL_ARG_TYPE (src_arg) = ptr_type_node;
/* arg_info = xcalloc (1, sizeof (struct c_arg_info)); */
TREE_CHAIN (dst_arg) = src_arg;
/* arg_info->parms = dst_arg; */
/* arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE,
ptr_type_node,
NULL_TREE)); */
DECL_ARGUMENTS (block_byref_id_object_copy[kind]) = dst_arg;
/* function header synthesis. */
push_function_context ();
/* start_block_helper_function (block_byref_id_object_copy[kind], true); */
/* store_parm_decls_from (arg_info); */
start_preparsed_function (block_byref_id_object_copy[kind],
/*attrs*/NULL_TREE,
SF_PRE_PARSED);
/* Body of the function. */
stmt = begin_compound_stmt (BCS_FN_BODY);
/* Build dst->object */
dst_obj = build_indirect_object_id_exp (dst_arg);
/* src_obj is: _src->object. */
src_obj = build_indirect_object_id_exp (src_arg);
/* APPLE LOCAL begin radar 6180456 */
/* _Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_OBJECT) or:
_Block_object_assign (&_dest->object, _src->object, BLOCK_FIELD_IS_BLOCK) */
/* APPLE LOCAL begin radar 6573923 */
/* Also add the new flag when calling _Block_object_dispose
from byref dispose helper. */
flag |= BLOCK_BYREF_CALLER;
/* APPLE LOCAL end radar 6573923 */
call_exp = build_block_object_assign_call_exp (build_fold_addr_expr (dst_obj), src_obj, flag);
add_stmt (call_exp);
/* APPLE LOCAL end radar 6180456 */
finish_compound_stmt (stmt);
/* APPLE LOCAL radar 6169580 */
finish_function (4);
pop_function_context ();
}
/**
This routine builds:
void __Block_byref_id_object_dispose(struct Block_byref_id_object *_src) {
_Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT[|BLOCK_FIELD_IS_WEAK]) // objects
_Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK[|BLOCK_FIELD_IS_WEAK]) // blocks
} */
static void synth_block_byref_id_object_dispose_func (int flag, int kind)
{
tree stmt;
tree src_arg, src_obj, rel_exp;
gcc_assert (block_byref_id_object_dispose[kind]);
/* Set up: (void *_src) parameter. */
src_arg = build_decl (PARM_DECL, get_identifier ("_src"),
ptr_type_node);
TREE_USED (src_arg) = 1;
DECL_ARG_TYPE (src_arg) = ptr_type_node;
/* arg_info = xcalloc (1, sizeof (struct c_arg_info));
arg_info->parms = src_arg;
arg_info->types = tree_cons (NULL_TREE, ptr_type_node,
NULL_TREE); */
DECL_ARGUMENTS (block_byref_id_object_dispose[kind]) = src_arg;
/* function header synthesis. */
push_function_context ();
/* start_block_helper_function (block_byref_id_object_dispose[kind], true); */
/* store_parm_decls_from (arg_info); */
start_preparsed_function (block_byref_id_object_dispose[kind],
/*attrs*/NULL_TREE,
SF_PRE_PARSED);
/* Body of the function. */
stmt = begin_compound_stmt (BCS_FN_BODY);
src_obj = build_indirect_object_id_exp (src_arg);
/* APPLE LOCAL begin radar 6180456 */
/* _Block_object_dispose(_src->object, BLOCK_FIELD_IS_OBJECT) or:
_Block_object_dispose(_src->object, BLOCK_FIELD_IS_BLOCK) */
/* APPLE LOCAL begin radar 6573923 */
/* Also add the new flag when calling _Block_object_dispose
from byref dispose helper. */
flag |= BLOCK_BYREF_CALLER;
/* APPLE LOCAL end radar 6573923 */
rel_exp = build_block_object_dispose_call_exp (src_obj, flag);
/* APPLE LOCAL end radar 6180456 */
add_stmt (rel_exp);
finish_compound_stmt (stmt);
/* APPLE LOCAL radar 6169580 */
finish_function (4);
pop_function_context ();
}
static tree
block_start_struct (tree name)
{
tree s;
/* The idea here is to mimic the actions that the C++ parser takes when
constructing 'extern "C" struct NAME {'. */
push_lang_context (lang_name_c);
s = xref_tag (record_type, name, ts_global, 0);
CLASSTYPE_DECLARED_CLASS (s) = 0; /* this is a 'struct', not a 'class'. */
xref_basetypes (s, NULL_TREE); /* no base classes here! */
return begin_class_definition (s, NULL_TREE);
}
static tree
block_finish_struct (tree t, tree fieldlist)
{
tree field, next_field;
for (field = fieldlist; field; field = next_field)
{
next_field = TREE_CHAIN (field); /* insert one field at a time; */
TREE_CHAIN (field) = NULL_TREE; /* otherwise, grokfield croaks. */
finish_member_declaration (field);
}
t = finish_struct (t, NULL);
pop_lang_context ();
return t;
}
/* new_block_byref_decl - This routine changes a 'typex x' declared variable into:
struct __Block_byref_x {
// APPLE LOCAL radar 6244520
void *__isa; // NULL for everything except __weak pointers
struct Block_byref_x *__forwarding;
int32_t __flags;
int32_t __size;
void *__ByrefKeepFuncPtr; // Only if variable is __block ObjC object
void *__ByrefDestroyFuncPtr; // Only if variable is __block ObjC object
typex x;
} x;
*/
static tree
new_block_byref_decl (tree decl)
{
static int unique_count;
/* APPLE LOCAL radar 5847976 */
int save_flag_objc_gc;
tree Block_byref_type;
tree fields = NULL_TREE, field;
const char *prefix = "__Block_byref_";
char *string = (char*)alloca (strlen (IDENTIFIER_POINTER (DECL_NAME (decl))) +
strlen (prefix) + 8 /* to hold the count */);
sprintf (string, "%s%d_%s", prefix, ++unique_count,
IDENTIFIER_POINTER (DECL_NAME (decl)));
push_to_top_level ();
/* Block_byref_type = start_struct (RECORD_TYPE, get_identifier (string)); */
Block_byref_type = block_start_struct (get_identifier (string));
/* APPLE LOCAL begin radar 6244520 */
/* void *__isa; */
field = build_decl (FIELD_DECL, get_identifier ("__isa"), ptr_type_node);
fields = field;
/* APPLE LOCAL end radar 6244520 */
/* struct Block_byref_x *__forwarding; */
field = build_decl (FIELD_DECL, get_identifier ("__forwarding"),
build_pointer_type (Block_byref_type));
/* APPLE LOCAL radar 6244520 */
chainon (fields, field);
/* int32_t __flags; */
field = build_decl (FIELD_DECL, get_identifier ("__flags"),
unsigned_type_node);
chainon (fields, field);
/* int32_t __size; */
field = build_decl (FIELD_DECL, get_identifier ("__size"),
unsigned_type_node);
chainon (fields, field);
if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
{
/* void *__ByrefKeepFuncPtr; */
field = build_decl (FIELD_DECL, get_identifier ("__ByrefKeepFuncPtr"),
ptr_type_node);
chainon (fields, field);
/* void *__ByrefDestroyFuncPtr; */
field = build_decl (FIELD_DECL, get_identifier ("__ByrefDestroyFuncPtr"),
ptr_type_node);
chainon (fields, field);
}
/* typex x; */
field = build_decl (FIELD_DECL, DECL_NAME (decl), TREE_TYPE (decl));
chainon (fields, field);
/* APPLE LOCAL begin radar 5847976 */
/* Hack so we don't issue warning on a field_decl having __weak attribute */
save_flag_objc_gc = flag_objc_gc;
flag_objc_gc = 0;
/* finish_struct (Block_byref_type, field_decl_chain, NULL_TREE); */
block_finish_struct (Block_byref_type, fields);
flag_objc_gc = save_flag_objc_gc;
/* APPLE LOCAL end radar 5847976 */
pop_from_top_level ();
TREE_TYPE (decl) = Block_byref_type;
/* Force layout_decl to recompute these fields. */
DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = 0;
layout_decl (decl, 0);
return decl;
}
/* init_byref_decl - This routine builds the initializer for the __Block_byref_x
type in the form of:
{ NULL, &x, 0, sizeof(struct __Block_byref_x), initializer-expr};
or:
{ NULL, &x, 0, sizeof(struct __Block_byref_x)};
when INIT is NULL_TREE
For __block ObjC objects, it also adds "byref_keep" and "byref_destroy"
Funtion pointers. So the most general initializers would be:
{ NULL, &x, 0, sizeof(struct __Block_byref_x), &byref_keep, &byref_destroy,
&initializer-expr};
*/
static tree
init_byref_decl (tree decl, tree init, int flag)
{
tree initlist;
tree block_byref_type = TREE_TYPE (decl);
int size = TREE_INT_CST_LOW (TYPE_SIZE_UNIT (block_byref_type));
unsigned flags = 0;
tree fields;
if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
flags = BLOCK_HAS_COPY_DISPOSE;
fields = TYPE_FIELDS (block_byref_type);
/* APPLE LOCAL begin radar 6244520 */
initlist = tree_cons (fields, fold_convert (ptr_type_node, ((flag & BLOCK_FIELD_IS_WEAK) != 0) ? integer_one_node
: integer_zero_node),
0);
fields = TREE_CHAIN (fields);
initlist = tree_cons (fields,
build_unary_op (ADDR_EXPR, decl, 0), initlist);
/* APPLE LOCAL end radar 6244520 */
fields = TREE_CHAIN (fields);
initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), flags),
initlist);
fields = TREE_CHAIN (fields);
initlist = tree_cons (fields, build_int_cst (TREE_TYPE (fields), size),
initlist);
fields = TREE_CHAIN (fields);
if (COPYABLE_BYREF_LOCAL_NONPOD (decl))
{
char name[64];
int align = exact_log2 ((DECL_ALIGN (decl)+TYPE_ALIGN (ptr_type_node)-1) / TYPE_ALIGN (ptr_type_node));
int kind;
if (align == -1 || align > BLOCK_ALIGN_MAX) {
error ("invalid alignment for __block variable");
kind = 0;
} else
kind = align*BLOCK_BYREF_CURRENT_MAX + flag;
/* Add &__Block_byref_id_object_copy, &__Block_byref_id_object_dispose
initializers. */
if (!block_byref_id_object_copy[kind])
{
tree func_type;
push_lang_context (lang_name_c);
/* Build a void __Block_byref_id_object_copy(void*, void*) type. */
func_type =
build_function_type (void_type_node,
tree_cons (NULL_TREE, ptr_type_node,
tree_cons (NULL_TREE, ptr_type_node,
void_list_node)));
sprintf (name, "__Block_byref_id_object_copy%d", kind);
block_byref_id_object_copy[kind] = build_helper_func_decl (get_identifier (name),
func_type);
DECL_CONTEXT (block_byref_id_object_copy[kind]) = current_function_decl;
/* Synthesize function definition. */
synth_block_byref_id_object_copy_func (flag, kind);
pop_lang_context ();
}
initlist = tree_cons (fields,
build_fold_addr_expr (block_byref_id_object_copy[kind]),
initlist);
fields = TREE_CHAIN (fields);
if (!block_byref_id_object_dispose[kind])
{
tree func_type;
push_lang_context (lang_name_c);
/* Synthesize void __Block_byref_id_object_dispose (void*) and
build &__Block_byref_id_object_dispose. */
func_type =
build_function_type (void_type_node,
tree_cons (NULL_TREE, ptr_type_node, void_list_node));
sprintf (name, "__Block_byref_id_object_dispose%d", kind);
block_byref_id_object_dispose[kind] = build_helper_func_decl (get_identifier (name),
func_type);
DECL_CONTEXT (block_byref_id_object_dispose[kind]) = current_function_decl;
/* Synthesize function definition. */
synth_block_byref_id_object_dispose_func (flag, kind);
pop_lang_context ();
}
initlist = tree_cons (fields,
build_fold_addr_expr (block_byref_id_object_dispose[kind]),
initlist);
fields = TREE_CHAIN (fields);
}
if (init)
{
init = digest_init (TREE_TYPE (fields), init);
initlist = tree_cons (fields, init, initlist);
}
init = build_constructor_from_list (block_byref_type, nreverse (initlist));
return init;
}
/* APPLE LOCAL end blocks 6040305 (cr) */
/* Finish processing of a declaration;
install its line number and initial value.
If the length of an array type is not known before,
@ -5295,6 +5681,17 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
if (DECL_THREAD_LOCAL_P (decl) && !pod_type_p (TREE_TYPE (decl)))
error ("%qD cannot be thread-local because it has non-POD type %qT",
decl, TREE_TYPE (decl));
/* APPLE LOCAL begin blocks 6040305 (cq) */
if (COPYABLE_BYREF_LOCAL_VAR (decl)) {
if (DECL_EXTERNAL (decl) || TREE_STATIC (decl))
{
error ("__block attribute on %q+D not allowed, only allowed on local variables", decl);
COPYABLE_BYREF_LOCAL_VAR (decl) = 0;
COPYABLE_BYREF_LOCAL_NONPOD (decl) = 0;
}
}
/* APPLE LOCAL end blocks 6040305 (cq) */
/* If this is a local variable that will need a mangled name,
register it now. We must do this before processing the
initializer for the variable, since the initialization might
@ -5760,6 +6157,16 @@ expand_static_init (tree decl, tree init)
&& TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
return;
/* APPLE LOCAL begin radar 5733674 */
if (c_dialect_objc () && flag_objc_gc && init && TREE_CODE (init) == INIT_EXPR)
{
tree result = objc_generate_write_barrier (TREE_OPERAND (init, 0),
INIT_EXPR, TREE_OPERAND (init, 1));
if (result)
init = result;
}
/* APPLE LOCAL end radar 5733674 */
if (DECL_FUNCTION_SCOPE_P (decl))
{
/* Emit code to perform this initialization but once. */
@ -7235,6 +7642,8 @@ grokdeclarator (const cp_declarator *declarator,
case cdk_pointer:
case cdk_reference:
case cdk_ptrmem:
/* APPLE LOCAL blocks 6040305 */
case cdk_block_pointer:
break;
case cdk_error:
@ -7930,6 +8339,33 @@ grokdeclarator (const cp_declarator *declarator,
ctype = NULL_TREE;
break;
/* APPLE LOCAL begin blocks 6040305 (cj) */
case cdk_block_pointer:
if (TREE_CODE (type) != FUNCTION_TYPE)
{
error ("block pointer to non-function type is invalid");
type = error_mark_node;
}
else
{
/* We now know that the TYPE_QUALS don't apply to the decl,
but to the target of the pointer. */
type_quals = TYPE_UNQUALIFIED;
type = build_block_pointer_type (type);
if (declarator->u.pointer.qualifiers)
{
type
= cp_build_qualified_type (type,
declarator->u.pointer.qualifiers);
type_quals = cp_type_quals (type);
}
}
ctype = NULL_TREE;
break;
/* APPLE LOCAL end blocks 6040305 (cj) */
case cdk_error:
break;
@ -8121,6 +8557,38 @@ grokdeclarator (const cp_declarator *declarator,
}
}
/* APPLE LOCAL begin blocks 6339747 */
if (decl_context == BLOCKDEF)
{
tree decl;
if (type == error_mark_node)
return error_mark_node;
if (TREE_CODE (type) != FUNCTION_TYPE)
{
tree t = make_node (FUNCTION_TYPE);
if (TREE_CODE (type) == ARRAY_TYPE)
{
error ("block declared as returning an array");
return error_mark_node;
}
TYPE_ARG_TYPES (t) = void_list_node;
TREE_TYPE (t) = type;
type = t;
parms = NULL_TREE;
}
if (raises)
type = build_exception_variant (type, raises);
decl = build_lang_decl (FUNCTION_DECL, NULL_TREE, type);
DECL_ARGUMENTS (decl) = parms;
return decl;
}
/* APPLE LOCAL end blocks 6339747 */
/* If this is declaring a typedef name, return a TYPE_DECL. */
if (declspecs->specs[(int)ds_typedef] && decl_context != TYPENAME)
{
@ -8973,7 +9441,8 @@ check_default_argument (tree decl, tree arg)
*PARMS is set to the chain of PARM_DECLs created. */
static tree
/* APPLE LOCAL blocks 6040305 (ce) */
tree
grokparms (cp_parameter_declarator *first_parm, tree *parms)
{
tree result = NULL_TREE;
@ -10909,6 +11378,82 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
}
/* APPLE LOCAL begin warn missing prototype 6261539 */
static bool
fn_previously_found (tree decl, tree olddecl)
{
int types_match;
if (olddecl == 0)
return false;
if (TREE_CODE (olddecl) == OVERLOAD)
{
if (OVL_CHAIN (olddecl) == NULL_TREE)
olddecl = OVL_CURRENT (olddecl);
else
{
tree match;
for (match = olddecl; match; match = OVL_NEXT (match))
{
if (fn_previously_found (decl, OVL_CURRENT (match)))
return true;
}
return false;
}
}
/* Don't warn about previously erroneous things that have the same
name. */
if (TREE_TYPE (olddecl) == error_mark_node)
return true;
/* Internally defined things still need a prototype to escape the
warning. */
if (DECL_ARTIFICIAL (olddecl))
return false;
if (TREE_CODE (olddecl) != FUNCTION_DECL)
return false;
/* These will match or error, don't also spew prototype warnings. */
if (DECL_EXTERN_C_P (olddecl)
&& DECL_EXTERN_C_P (decl))
return true;
/* These will match or error, don't also spew prototype warnings. */
if (compparms (TYPE_ARG_TYPES (TREE_TYPE (decl)),
TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
return true;
types_match = decls_match (decl, olddecl);
if (types_match)
return true;
return false;
}
inline static void
check_missing_prototype (tree decl)
{
if (warn_missing_prototypes
&& namespace_bindings_p ()
&& TREE_PUBLIC (decl)
&& !DECL_MAIN_P (decl)
&& DECL_NON_THUNK_FUNCTION_P (decl)
&& ! DECL_FUNCTION_MEMBER_P (decl)
&& DECL_NAMESPACE_SCOPE_P (decl)
&& ! decl_anon_ns_mem_p (decl)
&& ! DECL_DECLARED_INLINE_P (decl))
{
tree olddecl = namespace_binding (DECL_NAME (decl), DECL_CONTEXT (decl));
if (!fn_previously_found (decl, olddecl))
warning (OPT_Wmissing_prototypes, "no previous prototype for %q+D", decl);
}
}
/* APPLE LOCAL end warn missing prototype 6261539 */
/* Like start_preparsed_function, except that instead of a
FUNCTION_DECL, this function takes DECLSPECS and DECLARATOR.
@ -11253,6 +11798,8 @@ finish_function (int flags)
tree fndecl = current_function_decl;
tree fntype, ctype = NULL_TREE;
int inclass_inline = (flags & 2) != 0;
/* APPLE LOCAL radar 6169580 */
int in_blocks_helper_function = (flags & 4) != 0;
int nested;
/* When we get some parse errors, we can end up without a
@ -11446,7 +11993,8 @@ finish_function (int flags)
maybe_end_member_template_processing ();
/* Leave the scope of the class. */
if (ctype)
/* APPLE LOCAL radar 6169580 */
if (ctype && !in_blocks_helper_function)
pop_nested_class ();
--function_depth;
@ -11672,13 +12220,32 @@ cxx_maybe_build_cleanup (tree decl)
{
tree type = TREE_TYPE (decl);
if (type != error_mark_node && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
tree dtor = NULL_TREE;
bool build_cleanup = false;
if (TREE_CODE (type) == RECORD_TYPE)
dtor = CLASSTYPE_DESTRUCTORS (type);
if (type != error_mark_node)
{
if (TREE_CODE (type) == RECORD_TYPE)
/* For RECORD_TYPEs, we can refer to more precise flags than
TYPE_HAS_NONTRIVIAL_DESTRUCTOR. */
build_cleanup = (dtor && TREE_PRIVATE (dtor))
|| CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (type)
|| CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (type);
else
build_cleanup = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type);
}
if (build_cleanup)
{
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
tree rval;
bool has_vbases = (TREE_CODE (type) == RECORD_TYPE
&& CLASSTYPE_VBASECLASSES (type));
if (TREE_CODE (type) == ARRAY_TYPE)
rval = decl;
else

View File

@ -27,6 +27,8 @@ enum decl_context
FIELD, /* Declaration inside struct or union */
BITFIELD, /* Likewise but with specified width */
TYPENAME, /* Typename (inside cast or sizeof) */
/* APPLE LOCAL blocks 6339747 */
BLOCKDEF, /* Declaratin of block literal */
MEMFUNCDEF /* Member function definition */
};
@ -34,3 +36,7 @@ enum decl_context
extern tree grokdeclarator (const cp_declarator *,
const cp_decl_specifier_seq *,
enum decl_context, int, tree*);
/* APPLE LOCAL radar 4721858 */
extern void emit_instantiate_pending_templates (location_t *);
/* APPLE LOCAL blocks 6040305 (ce) */
extern tree grokparms (cp_parameter_declarator *first_parm, tree *parms);

View File

@ -1904,6 +1904,27 @@ constrain_class_visibility (tree type)
}
}
/* APPLE LOCAL begin weak types 5954418 */
static bool
typeinfo_comdat (tree type)
{
tree binfo, base_binfo;
int j;
if (lookup_attribute ("weak", TYPE_ATTRIBUTES (type)))
return true;
for (binfo = TYPE_BINFO (type), j = 0;
BINFO_BASE_ITERATE (binfo, j, base_binfo); ++j)
{
if (typeinfo_comdat (BINFO_TYPE (base_binfo)))
return true;
}
return false;
}
/* APPLE LOCAL end weak types 5954418 */
/* DECL is a FUNCTION_DECL or VAR_DECL. If the object file linkage
for DECL has not already been determined, do so now by setting
DECL_EXTERNAL, DECL_COMDAT and other related flags. Until this
@ -2100,7 +2121,10 @@ import_export_decl (tree decl)
{
comdat_p = (targetm.cxx.class_data_always_comdat ()
|| (CLASSTYPE_KEY_METHOD (type)
&& DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (type))));
/* APPLE LOCAL begin weak types 5954418 */
&& DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (type)))
|| typeinfo_comdat (type));
/* APPLE LOCAL end weak types 5954418 */
mark_needed (decl);
if (!flag_weak)
{
@ -3043,6 +3067,10 @@ build_java_method_aliases (void)
}
}
/* APPLE LOCAL begin radar 4721858 */
static void emit_deferred (location_t *);
/* APPLE LOCAL end radar 4721858 */
/* This routine is called from the last rule in yyparse ().
Its job is to create all the code needed to initialize and
destroy the global aggregates. We do the destruction
@ -3051,14 +3079,10 @@ build_java_method_aliases (void)
void
cp_finish_file (void)
{
tree vars;
bool reconsider;
size_t i;
/* APPLE LOCAL begin radar 4721858 */
location_t locus;
unsigned ssdf_count = 0;
int retries = 0;
tree decl;
/* APPLE LOCAL end radar 4721858 */
locus = input_location;
at_eof = 1;
@ -3066,8 +3090,8 @@ cp_finish_file (void)
if (! global_bindings_p () || current_class_type || decl_namespace_list)
return;
if (pch_file)
c_common_write_pch ();
/* APPLE LOCAL radar 4874613 */
/* dump of pch file moved to c_parse_file (). */
#ifdef USE_MAPPED_LOCATION
/* FIXME - huh? */
@ -3097,6 +3121,29 @@ cp_finish_file (void)
emit_support_tinfos ();
/* APPLE LOCAL begin radar 4721858 */
emit_instantiate_pending_templates (&locus);
emit_deferred (&locus);
}
/* This routine emits pending functions and instatiates pending templates
as more opportunities arises. */
void
emit_instantiate_pending_templates (location_t *locusp)
{
tree vars;
bool reconsider;
size_t i;
unsigned ssdf_count = 0;
int retries = 0;
/* APPLE LOCAL radar 4874626 */
/* initialization removed. */
at_eof = 1;
/* APPLE LOCAL end radar 4721858 */
do
{
tree t;
@ -3174,7 +3221,8 @@ cp_finish_file (void)
/* Set the line and file, so that it is obviously not from
the source file. */
input_location = locus;
/* APPLE LOCAL radar 4721858 */
input_location = *locusp;
ssdf_body = start_static_storage_duration_function (ssdf_count);
/* Make sure the back end knows about all the variables. */
@ -3200,7 +3248,8 @@ cp_finish_file (void)
/* Finish up the static storage duration function for this
round. */
input_location = locus;
/* APPLE LOCAL radar 4721858 */
input_location = *locusp;
finish_static_storage_duration_function (ssdf_body);
/* All those initializations and finalizations might cause
@ -3211,7 +3260,8 @@ cp_finish_file (void)
#ifdef USE_MAPPED_LOCATION
/* ??? */
#else
locus.line++;
/* APPLE LOCAL radar 4721858 */
locusp->line++;
#endif
}
@ -3309,27 +3359,36 @@ cp_finish_file (void)
retries++;
}
while (reconsider);
/* APPLE LOCAL begin radar 4721858 */
}
static void
emit_deferred (location_t *locusp)
{
size_t i;
tree decl;
bool reconsider = false;
/* APPLE LOCAL end radar 4721858 */
/* All used inline functions must have a definition at this point. */
for (i = 0; VEC_iterate (tree, deferred_fns, i, decl); ++i)
{
if (/* Check online inline functions that were actually used. */
TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
/* If the definition actually was available here, then the
fact that the function was not defined merely represents
that for some reason (use of a template repository,
#pragma interface, etc.) we decided not to emit the
definition here. */
&& !DECL_INITIAL (decl)
/* An explicit instantiation can be used to specify
that the body is in another unit. It will have
already verified there was a definition. */
&& !DECL_EXPLICIT_INSTANTIATION (decl))
{
warning (0, "inline function %q+D used but never defined", decl);
/* Avoid a duplicate warning from check_global_declaration_1. */
TREE_NO_WARNING (decl) = 1;
}
TREE_USED (decl) && DECL_DECLARED_INLINE_P (decl)
/* If the definition actually was available here, then the
fact that the function was not defined merely represents
that for some reason (use of a template repository,
#pragma interface, etc.) we decided not to emit the
definition here. */
&& !DECL_INITIAL (decl)
/* An explicit instantiation can be used to specify
that the body is in another unit. It will have
already verified there was a definition. */
&& !DECL_EXPLICIT_INSTANTIATION (decl))
{
warning (0, "inline function %q+D used but never defined", decl);
/* Avoid a duplicate warning from check_global_declaration_1. */
TREE_NO_WARNING (decl) = 1;
}
}
/* We give C linkage to static constructors and destructors. */
@ -3340,17 +3399,20 @@ cp_finish_file (void)
if (priority_info_map)
splay_tree_foreach (priority_info_map,
generate_ctor_and_dtor_functions_for_priority,
/*data=*/&locus);
/* APPLE LOCAL radar 4721858 */
/*data=*/locusp);
else
{
/* If we have a ctor or this is obj-c++ and we need a static init,
call generate_ctor_or_dtor_function. */
if (static_ctors || (c_dialect_objc () && objc_static_init_needed_p ()))
generate_ctor_or_dtor_function (/*constructor_p=*/true,
DEFAULT_INIT_PRIORITY, &locus);
/* APPLE LOCAL radar 4721858 */
DEFAULT_INIT_PRIORITY, locusp);
if (static_dtors)
generate_ctor_or_dtor_function (/*constructor_p=*/false,
DEFAULT_INIT_PRIORITY, &locus);
/* APPLE LOCAL radar 4721858 */
DEFAULT_INIT_PRIORITY, locusp);
}
/* We're done with the splay-tree now. */
@ -3403,7 +3465,8 @@ cp_finish_file (void)
dump_tree_statistics ();
dump_time_statistics ();
}
input_location = locus;
/* APPLE LOCAL radar 4721858 */
input_location = *locusp;
#ifdef ENABLE_CHECKING
validate_conversion_obstack ();

View File

@ -342,6 +342,8 @@ dump_type (tree t, int flags)
reduces code size. */
case ARRAY_TYPE:
case POINTER_TYPE:
/* APPLE LOCAL blocks 6040305 */
case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
offset_type:
@ -497,6 +499,8 @@ dump_type_prefix (tree t, int flags)
switch (TREE_CODE (t))
{
case POINTER_TYPE:
/* APPLE LOCAL blocks 6040305 */
case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
{
tree sub = TREE_TYPE (t);
@ -507,7 +511,10 @@ dump_type_prefix (tree t, int flags)
pp_cxx_whitespace (cxx_pp);
pp_cxx_left_paren (cxx_pp);
}
pp_character (cxx_pp, "&*"[TREE_CODE (t) == POINTER_TYPE]);
/* APPLE LOCAL begin blocks 6040305 */
pp_character (cxx_pp, "&*^"[(TREE_CODE (t) == POINTER_TYPE)
+ (TREE_CODE (t) == BLOCK_POINTER_TYPE)*2]);
/* APPLE LOCAL end blocks 6040305 */
pp_base (cxx_pp)->padding = pp_before;
pp_cxx_cv_qualifier_seq (cxx_pp, t);
}
@ -593,6 +600,8 @@ dump_type_suffix (tree t, int flags)
switch (TREE_CODE (t))
{
case POINTER_TYPE:
/* APPLE LOCAL blocks 6040305 */
case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)

View File

@ -2905,7 +2905,13 @@ push_base_cleanups (void)
for (binfo = TYPE_BINFO (current_class_type), i = 0;
BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
if (TYPE_HAS_TRIVIAL_DESTRUCTOR (BINFO_TYPE (base_binfo))
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
tree dtor = CLASSTYPE_DESTRUCTORS (BINFO_TYPE (base_binfo));
if ((!CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (BINFO_TYPE (base_binfo))
&& !CLASSTYPE_HAS_NONTRIVIAL_DESTRUCTOR_BODY (BINFO_TYPE (base_binfo))
&& !(dtor && (TREE_PRIVATE (dtor))))
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
|| BINFO_VIRTUAL_P (base_binfo))
continue;
@ -2935,6 +2941,12 @@ push_base_cleanups (void)
LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_NORMAL,
0);
finish_decl_cleanup (NULL_TREE, expr);
/* APPLE LOCAL begin omit calls to empty destructors 5559195 */
/* Even if body of current class's destructor was found to be empty,
it must now be called because it must delete its members. */
CLASSTYPE_DESTRUCTOR_NONTRIVIAL_BECAUSE_OF_BASE (current_class_type) = 1;
/* APPLE LOCAL end omit calls to empty destructors 5559195 */
}
}
}

View File

@ -1634,6 +1634,13 @@ write_type (tree type)
write_type (TREE_TYPE (type));
break;
/* APPLE LOCAL begin blocks 6040305 */
case BLOCK_POINTER_TYPE:
write_string ("U13block_pointer");
write_type (TREE_TYPE (type));
break;
/* APPLE LOCAL end blocks 6040305 */
case REFERENCE_TYPE:
write_char ('R');
write_type (TREE_TYPE (type));

View File

@ -364,6 +364,8 @@ push_binding (tree id, tree decl, cxx_scope* level)
{
binding = cxx_binding_make (decl, NULL_TREE);
binding->scope = level;
/* APPLE LOCAL blocks 6040305 (ch) */
binding->declared_in_block = cur_block != 0;
}
else
binding = new_class_binding (id, decl, /*type=*/NULL_TREE, level);
@ -1822,6 +1824,8 @@ binding_for_name (cxx_scope *scope, tree name)
result->scope = scope;
result->is_local = false;
result->value_is_inherited = false;
/* APPLE LOCAL blocks 6040305 (ch) */
result->declared_in_block = 0;
IDENTIFIER_NAMESPACE_BINDINGS (name) = result;
return result;
}
@ -4581,6 +4585,8 @@ arg_assoc_type (struct arg_lookup *k, tree type)
return arg_assoc_type (k, TYPE_PTRMEMFUNC_FN_TYPE (type));
return arg_assoc_class (k, type);
case POINTER_TYPE:
/* APPLE LOCAL blocks 6040305 */
case BLOCK_POINTER_TYPE:
case REFERENCE_TYPE:
case ARRAY_TYPE:
return arg_assoc_type (k, TREE_TYPE (type));

View File

@ -76,6 +76,8 @@ struct cxx_binding GTY(())
cxx_scope *scope;
unsigned value_is_inherited : 1;
unsigned is_local : 1;
/* APPLE LOCAL blocks 6040305 (ch) */
unsigned declared_in_block : 1;
};
/* Datatype used to temporarily save C++ bindings (for implicit

File diff suppressed because it is too large Load Diff

View File

@ -7835,6 +7835,11 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
complain);
}
/* APPLE LOCAL begin blocks 6204446 */
case BLOCK_POINTER_TYPE:
return t;
/* APPLE LOCAL end blocks 6204446 */
default:
sorry ("use of %qs in template",
tree_code_name [(int) TREE_CODE (t)]);

View File

@ -1943,6 +1943,18 @@ finish_this_expr (void)
error ("%<this%> is unavailable for static member functions");
result = error_mark_node;
}
/* APPLE LOCAL begin radar 6275956 */
else if (cur_block && current_function_decl
&& BLOCK_SYNTHESIZED_FUNC (current_function_decl))
{
result = lookup_name (this_identifier);
if (!result)
{
error ("invalid use of %<this%> in a block");
result = error_mark_node;
}
}
/* APPLE LOCAL end radar 6275956 */
else
{
if (current_function_decl)
@ -2470,6 +2482,82 @@ baselink_for_fns (tree fns)
return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE);
}
/* APPLE LOCAL begin blocks 6040305 */
static bool
block_var_ok_for_context (tree context)
{
/* FIXME - local classes inside blocks, templates, etc */
struct block_sema_info *b = cur_block;
tree decl = current_function_decl;
/* If in a block helper, only variables from the context of the helper
are ok. */
while (b && b->helper_func_decl == decl)
{
if (context == DECL_CONTEXT (decl))
return true;
decl = DECL_CONTEXT (decl);
b = b->prev_block_info;
}
return false;
}
/* APPLE LOCAL begin radar 6545782 */
/** This routine does all the work on use of variables in a block. */
static tree get_final_block_variable (tree name, tree var) {
tree decl = var;
if (cur_block
&& (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL)
&& !lookup_name_in_block (name, &decl))
{
bool gdecl;
/* We are referencing a variable inside a block whose
declaration is outside. */
gcc_assert (decl &&
(TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL));
gdecl = (TREE_CODE (decl) == VAR_DECL &&
(DECL_EXTERNAL (decl) || TREE_STATIC (decl)));
/* Treat all 'global' variables as 'byref' by default. */
if (gdecl
|| (TREE_CODE (decl) == VAR_DECL && COPYABLE_BYREF_LOCAL_VAR (decl)))
{
/* byref globals are directly accessed. */
/* APPLE LOCAL begin radar 7760213 */
if (!gdecl) {
if (HasByrefArray(TREE_TYPE (decl)))
error ("cannot access __block variable of array type inside block");
/* build a decl for the byref variable. */
decl = build_block_byref_decl (name, decl, decl);
}
/* APPLE LOCAL end radar 7760213 */
else
add_block_global_byref_list (decl);
}
else
{
/* 'byref' globals are never copied-in. So, do not add
them to the copied-in list. */
if (!in_block_global_byref_list (decl)) {
/* APPLE LOCAL begin radar 7721728 */
if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
error ("cannot access copied-in variable of array type inside block");
/* APPLE LOCAL end radar 7721728 */
/* build a new decl node. set its type to 'const' type
of the old decl. */
decl = build_block_ref_decl (name, decl);
}
}
}
return decl;
}
/* APPLE LOCAL end radar 6545782 */
/* APPLE LOCAL end blocks 6040305 */
/* ID_EXPRESSION is a representation of parsed, but unprocessed,
id-expression. (See cp_parser_id_expression for details.) SCOPE,
if non-NULL, is the type or namespace used to explicitly qualify
@ -2536,6 +2624,7 @@ finish_id_expression (tree id_expression,
if (decl == error_mark_node)
{
/* Name lookup failed. */
if (scope
&& (!TYPE_P (scope)
|| (!dependent_type_p (scope)
@ -2576,7 +2665,10 @@ finish_id_expression (tree id_expression,
{
tree context = decl_function_context (decl);
if (context != NULL_TREE && context != current_function_decl
&& ! TREE_STATIC (decl))
/* APPLE LOCAL begin blocks 6040305 */
&& ! TREE_STATIC (decl)
&& !block_var_ok_for_context (context))
/* APPLE LOCAL end blocks 6040305 */
{
error (TREE_CODE (decl) == VAR_DECL
? "use of %<auto%> variable from containing function"
@ -2852,8 +2944,21 @@ finish_id_expression (tree id_expression,
Access checking has been performed during name lookup
already. Turn off checking to avoid duplicate errors. */
push_deferring_access_checks (dk_no_check);
decl = finish_non_static_data_member (decl, current_class_ref,
/*qualifying_scope=*/NULL_TREE);
/* APPLE LOCAL begin radar 6169580 */
if (cur_block)
{
tree exp;
tree this_copiedin_var = lookup_name (this_identifier);
gcc_assert (!current_class_ref);
gcc_assert (this_copiedin_var);
exp = build_x_arrow (this_copiedin_var);
decl = build_class_member_access_expr (exp, decl, TREE_TYPE (exp),
/*preserve_reference=*/false);
}
else
decl = finish_non_static_data_member (decl, current_class_ref,
/*qualifying_scope=*/NULL_TREE);
/* APPLE LOCAL end radar 6169580 */
pop_deferring_access_checks ();
}
else if (is_overloaded_fn (decl))
@ -2894,7 +2999,8 @@ finish_id_expression (tree id_expression,
path = currently_open_derived_class (DECL_CONTEXT (decl));
perform_or_defer_access_check (TYPE_BINFO (path), decl, decl);
}
/* APPLE LOCAL radar 6545782 */
decl = get_final_block_variable (id_expression, decl);
decl = convert_from_reference (decl);
}
}
@ -2902,6 +3008,30 @@ finish_id_expression (tree id_expression,
if (TREE_DEPRECATED (decl))
warn_deprecated_use (decl);
/* APPLE LOCAL begin blocks 6040305 (cd) */
if (TREE_CODE (decl) == VAR_DECL)
{
if (BLOCK_DECL_BYREF (decl))
{
tree orig_decl = decl;
decl = build_indirect_ref (decl, "unary *");
if (COPYABLE_BYREF_LOCAL_VAR (orig_decl))
{
/* What we have is an expression which is of type
struct __Block_byref_X. Must get to the value of the variable
embedded in this structure. It is at:
__Block_byref_X.__forwarding->x */
decl = build_byref_local_var_access (decl,
DECL_NAME (orig_decl));
}
}
else
if (COPYABLE_BYREF_LOCAL_VAR (decl))
decl = build_byref_local_var_access (decl,
DECL_NAME (decl));
}
/* APPLE LOCAL end blocks 6040305 (cd) */
return decl;
}
@ -3173,6 +3303,11 @@ expand_or_defer_fn (tree fn)
it. */
if (maybe_clone_body (fn))
{
/* APPLE LOCAL begin radar 6305545 */
/* Must lower the nested functions which could be, among other
things, block helper functions. */
lower_if_nested_functions (fn);
/* APPLE LOCAL end radar 6305545 */
/* We don't want to process FN again, so pretend we've written
it out, even though we haven't. */
TREE_ASM_WRITTEN (fn) = 1;
@ -3965,6 +4100,42 @@ cxx_omp_predetermined_sharing (tree decl)
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
/* APPLE LOCAL begin blocks 6040305 (ch) */
tree
begin_block (void)
{
struct block_sema_info *csi;
tree block;
/* push_scope (); */
current_stmt_tree ()->stmts_are_full_exprs_p = 1;
#if 0
block = do_pushlevel (sk_block);
#else
block = NULL_TREE;
#endif
csi = (struct block_sema_info*)xcalloc (1, sizeof (struct block_sema_info));
csi->prev_block_info = cur_block;
cur_block = csi;
return block;
}
struct block_sema_info *
finish_block (tree block)
{
struct block_sema_info *csi = cur_block;
cur_block = cur_block->prev_block_info;
/* pop_scope (); */
#if 0
if (block)
do_poplevel (block);
#else
block = 0;
#endif
return csi;
}
/* APPLE LOCAL end blocks 6040305 (ch) */
void
init_cp_semantics (void)

View File

@ -1717,6 +1717,15 @@ maybe_dummy_object (tree type, tree* binfop)
&& same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)),
current_class_type))
decl = current_class_ref;
/* APPLE LOCAL begin radar 6154598 */
else if (cur_block)
{
tree this_copiedin_var = lookup_name (this_identifier);
gcc_assert (!current_class_ref);
gcc_assert (this_copiedin_var);
decl = build_x_arrow (this_copiedin_var);
}
/* APPLE LOCAL end radar 6154598 */
else
decl = build_dummy_object (context);

View File

@ -57,7 +57,8 @@ static void casts_away_constness_r (tree *, tree *);
static bool casts_away_constness (tree, tree);
static void maybe_warn_about_returning_address_of_local (tree);
static tree lookup_destructor (tree, tree, tree);
static tree convert_arguments (tree, tree, tree, int);
/* APPLE LOCAL radar 6087117 */
static tree convert_arguments (tree, tree, tree, int, int);
/* Do `exp = require_complete_type (exp);' to make sure exp
does not have an incomplete type. (That includes void types.)
@ -406,7 +407,8 @@ composite_pointer_type_r (tree t1, tree t2, const char* location)
tree attributes;
/* Determine the types pointed to by T1 and T2. */
if (TREE_CODE (t1) == POINTER_TYPE)
/* APPLE LOCAL blocks 6040305 */
if (TREE_CODE (t1) == POINTER_TYPE || TREE_CODE (t1) == BLOCK_POINTER_TYPE)
{
pointee1 = TREE_TYPE (t1);
pointee2 = TREE_TYPE (t2);
@ -453,8 +455,13 @@ composite_pointer_type_r (tree t1, tree t2, const char* location)
result_type = build_ptrmem_type (TYPE_PTRMEM_CLASS_TYPE (t1),
result_type);
}
/* APPLE LOCAL begin blocks 6065211 */
else if (TREE_CODE (t1) == BLOCK_POINTER_TYPE
&& result_type != void_type_node)
result_type = build_block_pointer_type (result_type);
else
result_type = build_pointer_type (result_type);
/* APPLE LOCAL end blocks 6065211 */
/* Merge the attributes. */
attributes = (*targetm.merge_type_attributes) (t1, t2);
@ -524,8 +531,10 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
if (c_dialect_objc () && TREE_CODE (t1) == POINTER_TYPE
&& TREE_CODE (t2) == POINTER_TYPE)
{
if (objc_compare_types (t1, t2, -3, NULL_TREE))
return t1;
/* APPLE LOCAL radar 4229905 - radar 6231433 */
if (objc_have_common_type (t1, t2, -3, NULL_TREE, location))
/* APPLE LOCAL 4154928 */
return objc_common_type (t1, t2);
}
/* [expr.eq] permits the application of a pointer conversion to
@ -572,6 +581,14 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2,
return error_mark_node;
}
}
/* APPLE LOCAL begin blocks 6065211 */
else if (TREE_CODE (t1) != TREE_CODE (t2))
{
error ("%s between distinct pointer types %qT and %qT "
"lacks a cast", location, t1, t2);
return error_mark_node;
}
/* APPLE LOCAL end blocks 6065211 */
return composite_pointer_type_r (t1, t2, location);
}
@ -1039,6 +1056,21 @@ comptypes (tree t1, tree t2, int strict)
return false;
break;
/* APPLE LOCAL begin blocks 6040305 */
case BLOCK_POINTER_TYPE:
if (TREE_CODE (t2) == BLOCK_POINTER_TYPE)
{
tree pt1 = TREE_TYPE (t1);
tree pt2 = TREE_TYPE (t2);
if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (pt1),
TREE_TYPE (pt2)))
return false;
if (!compparms (TYPE_ARG_TYPES (pt1), TYPE_ARG_TYPES (pt2)))
return false;
break;
}
/* APPLE LOCAL end blocks 6040305 */
case POINTER_TYPE:
case REFERENCE_TYPE:
if (TYPE_MODE (t1) != TYPE_MODE (t2)
@ -2662,6 +2694,53 @@ get_member_function_from_ptrfunc (tree *instance_ptrptr, tree function)
return function;
}
/* APPLE LOCAL begin blocks 6040305 (cm) */
/* APPLE LOCAL begin radar 5847213 - radar 6329245 */
/**
build_block_call - Routine to build a block call; as in:
((double(*)(void *, int))(BLOCK_PTR_EXP->__FuncPtr))(I, 42);
FNTYPE is the original function type derived from the syntax.
BLOCK_PTR_EXP is the block pointer variable.
PARAMS is the parameter list.
*/
static tree
build_block_call (tree fntype, tree block_ptr_exp, tree params)
{
tree function_ptr_exp;
tree typelist;
tree result;
/* APPLE LOCAL radar 6396238 */
bool block_ptr_exp_side_effect = TREE_SIDE_EFFECTS (block_ptr_exp);
/* First convert it to 'void *'. */
block_ptr_exp = convert (ptr_type_node, block_ptr_exp);
gcc_assert (generic_block_literal_struct_type);
block_ptr_exp = convert (build_pointer_type (generic_block_literal_struct_type),
block_ptr_exp);
if (block_ptr_exp_side_effect)
block_ptr_exp = save_expr (block_ptr_exp);
/* BLOCK_PTR_VAR->__FuncPtr */
function_ptr_exp =
finish_class_member_access_expr (build_indirect_ref (block_ptr_exp, "->"),
get_identifier ("__FuncPtr"), false);
gcc_assert (function_ptr_exp);
/* Build: result_type(*)(void *, function-arg-type-list) */
typelist = TYPE_ARG_TYPES (fntype);
typelist = tree_cons (NULL_TREE, ptr_type_node, typelist);
fntype = build_function_type (TREE_TYPE (fntype), typelist);
function_ptr_exp = convert (build_pointer_type (fntype), function_ptr_exp);
params = tree_cons (NULL_TREE, block_ptr_exp, params);
result = build3 (CALL_EXPR, TREE_TYPE (fntype),
function_ptr_exp, params, NULL_TREE);
/* FIXME: should do more from build_cxx_call */
result = convert_from_reference (result);
return result;
}
/* APPLE LOCAL end radar 5847213 - radar 6329245 */
/* APPLE LOCAL end blocks 6040305 (cm) */
tree
build_function_call (tree function, tree params)
{
@ -2724,7 +2803,8 @@ build_function_call (tree function, tree params)
is_method = (TREE_CODE (fntype) == POINTER_TYPE
&& TREE_CODE (TREE_TYPE (fntype)) == METHOD_TYPE);
if (!((TREE_CODE (fntype) == POINTER_TYPE
/* APPLE LOCAL blocks 6040305 */
if (!(((TREE_CODE (fntype) == POINTER_TYPE || TREE_CODE (fntype) == BLOCK_POINTER_TYPE)
&& TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE)
|| is_method
|| TREE_CODE (function) == TEMPLATE_ID_EXPR))
@ -2739,8 +2819,11 @@ build_function_call (tree function, tree params)
/* Convert the parameters to the types declared in the
function prototype, or apply default promotions. */
/* APPLE LOCAL begin radar 6087117 */
coerced_params = convert_arguments (TYPE_ARG_TYPES (fntype),
params, fndecl, LOOKUP_NORMAL);
params, fndecl, LOOKUP_NORMAL,
(TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE));
/* APPLE LOCAL end radar 6087117 */
if (coerced_params == error_mark_node)
return error_mark_node;
@ -2749,10 +2832,14 @@ build_function_call (tree function, tree params)
check_function_arguments (TYPE_ATTRIBUTES (fntype), coerced_params,
TYPE_ARG_TYPES (fntype));
/* APPLE LOCAL begin blocks 6040305 */
if (TREE_CODE (TREE_TYPE (function)) == BLOCK_POINTER_TYPE)
return build_block_call (fntype, function, coerced_params);
/* APPLE LOCAL end blocks 6040305 */
return build_cxx_call (function, coerced_params);
}
/* Convert the actual parameter expressions in the list VALUES
to the types in the list TYPELIST.
If parmdecls is exhausted, or when an element has NULL as its type,
@ -2771,7 +2858,8 @@ build_function_call (tree function, tree params)
default arguments, if such were specified. Do so here. */
static tree
convert_arguments (tree typelist, tree values, tree fndecl, int flags)
/* APPLE LOCAL radar 6087117 */
convert_arguments (tree typelist, tree values, tree fndecl, int flags, int block_call)
{
tree typetail, valtail;
tree result = NULL_TREE;
@ -2813,7 +2901,8 @@ convert_arguments (tree typelist, tree values, tree fndecl, int flags)
error ("at this point in file");
}
else
error ("too many arguments to function");
/* APPLE LOCAL radar 6087117 */
error ("too many arguments to %s", (block_call ? "block call" : "function"));
/* In case anybody wants to know if this argument
list is valid. */
if (result)
@ -2915,7 +3004,8 @@ convert_arguments (tree typelist, tree values, tree fndecl, int flags)
error ("at this point in file");
}
else
error ("too few arguments to function");
/* APPLE LOCAL radar 6087117 */
error ("too few arguments to %s", (block_call ? "block call" : "function"));
return error_mark_node;
}
}
@ -3314,22 +3404,29 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1,
&& (code1 == INTEGER_TYPE || code1 == REAL_TYPE
|| code1 == COMPLEX_TYPE))
short_compare = 1;
else if ((code0 == POINTER_TYPE && code1 == POINTER_TYPE)
/* APPLE LOCAL begin blocks 6040305 */
else if (((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE)
&& (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
|| (TYPE_PTRMEM_P (type0) && TYPE_PTRMEM_P (type1)))
/* APPLE LOCAL end blocks 6040305 */
result_type = composite_pointer_type (type0, type1, op0, op1,
"comparison");
else if ((code0 == POINTER_TYPE || TYPE_PTRMEM_P (type0))
/* APPLE LOCAL blocks 6040305 (cl) */
else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE || TYPE_PTRMEM_P (type0))
&& null_ptr_cst_p (op1))
result_type = type0;
else if ((code1 == POINTER_TYPE || TYPE_PTRMEM_P (type1))
/* APPLE LOCAL blocks 6040305 (cl) */
else if ((code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE || TYPE_PTRMEM_P (type1))
&& null_ptr_cst_p (op0))
result_type = type1;
else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
/* APPLE LOCAL blocks 6040305 (cl) */
else if ((code0 == POINTER_TYPE || code0 == BLOCK_POINTER_TYPE) && code1 == INTEGER_TYPE)
{
result_type = type0;
error ("ISO C++ forbids comparison between pointer and integer");
}
else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
/* APPLE LOCAL blocks 6040305 (cl) */
else if (code0 == INTEGER_TYPE && (code1 == POINTER_TYPE || code1 == BLOCK_POINTER_TYPE))
{
result_type = type1;
error ("ISO C++ forbids comparison between pointer and integer");
@ -5247,6 +5344,30 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
else if (TYPE_PTR_P (type) && INTEGRAL_OR_ENUMERATION_TYPE_P (intype))
/* OK */
;
/* APPLE LOCAL begin blocks 6040305 (ck) */
else if (TREE_CODE (type) == INTEGER_TYPE && TREE_CODE (intype) == BLOCK_POINTER_TYPE)
{
if (TYPE_PRECISION (type) < TYPE_PRECISION (intype))
pedwarn ("cast from %qT to %qT loses precision",
intype, type);
}
else if (TREE_CODE (type) == BLOCK_POINTER_TYPE && TREE_CODE (intype) == INTEGER_TYPE)
/* OK */
;
else if (TREE_CODE (type) == BLOCK_POINTER_TYPE && TREE_CODE (intype) == BLOCK_POINTER_TYPE)
/* OK */
;
else if (TREE_CODE (intype) == BLOCK_POINTER_TYPE
&& (objc_is_id (type)
|| (TREE_CODE (type) == POINTER_TYPE && VOID_TYPE_P (TREE_TYPE (type)))))
/* OK */
;
else if (TREE_CODE (type) == BLOCK_POINTER_TYPE
&& TREE_CODE (intype) == POINTER_TYPE
&& (objc_is_id (intype) || VOID_TYPE_P (TREE_TYPE (intype))))
/* OK */
;
/* APPLE LOCAL end blocks 6040305 (ck) */
else if ((TYPE_PTRFN_P (type) && TYPE_PTRFN_P (intype))
|| (TYPE_PTRMEMFUNC_P (type) && TYPE_PTRMEMFUNC_P (intype)))
return fold_if_not_in_template (build_nop (type, expr));
@ -5300,6 +5421,14 @@ build_reinterpret_cast_1 (tree type, tree expr, bool c_cast_p,
return error_mark_node;
}
/* APPLE LOCAL begin don't sign-extend pointers cast to integers */
if (TREE_CODE (type) == INTEGER_TYPE
&& TREE_CODE (intype) == POINTER_TYPE
&& TYPE_PRECISION (type) > TYPE_PRECISION (intype)
&& TYPE_UNSIGNED (type))
expr = cp_convert (c_common_type_for_size (POINTER_SIZE, 1), expr);
/* APPLE LOCAL end don't sign-extend pointers cast to integers */
return cp_convert (type, expr);
}
@ -5713,6 +5842,19 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
if (modifycode == NOP_EXPR)
{
/* `operator=' is not an inheritable operator. */
if (! IS_AGGR_TYPE (lhstype))
/* Do the default thing. */;
else
{
result = build_new_op (MODIFY_EXPR, LOOKUP_NORMAL,
lhs, rhs, make_node (NOP_EXPR),
/*overloaded_p=*/NULL);
if (result == NULL_TREE)
return error_mark_node;
return result;
}
/* APPLE LOCAL end C* property (Radar 4436866) */
/* `operator=' is not an inheritable operator. */
if (! IS_AGGR_TYPE (lhstype))
/* Do the default thing. */;
@ -5745,6 +5887,7 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
/* Now it looks like a plain assignment. */
modifycode = NOP_EXPR;
lhstype = olhstype;
}
gcc_assert (TREE_CODE (lhstype) != REFERENCE_TYPE);
gcc_assert (TREE_CODE (TREE_TYPE (newrhs)) != REFERENCE_TYPE);
@ -5898,10 +6041,47 @@ build_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
tree
build_x_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
{
/* APPLE LOCAL __block assign sequence point 6639533 */
bool insert_sequence_point = false;
if (processing_template_decl)
return build_min_nt (MODOP_EXPR, lhs,
build_min_nt (modifycode, NULL_TREE, NULL_TREE), rhs);
/* APPLE LOCAL begin __block assign sequence point 6639533 */
/* For byref = x;, we have to transform this into ({ typeof(x) x' =
x; byref = x`; )} to ensure there is a sequence point before the
evaluation of the byref, inorder to ensure that the access
expression for byref doesn't start running before x is evaluated,
as it will access the __forwarding pointer and that must be done
after x is evaluated. */
/* First we check to see if lhs is a byref... byrefs look like:
__Block_byref_X.__forwarding->x */
if (TREE_CODE (lhs) == COMPONENT_REF)
{
tree inner = TREE_OPERAND (lhs, 0);
/* now check for -> */
if (TREE_CODE (inner) == INDIRECT_REF)
{
inner = TREE_OPERAND (inner, 0);
if (TREE_CODE (inner) == COMPONENT_REF)
{
inner = TREE_OPERAND (inner, 0);
if (TREE_CODE (inner) == VAR_DECL
&& COPYABLE_BYREF_LOCAL_VAR (inner))
{
tree old_rhs = rhs;
/* then we save the rhs. */
rhs = save_expr (rhs);
if (rhs != old_rhs)
/* And arrange for the sequence point to be inserted. */
insert_sequence_point = true;
}
}
}
}
/* APPLE LOCAL end __block assign sequence point 6639533 */
if (modifycode != NOP_EXPR)
{
tree rval = build_new_op (MODIFY_EXPR, LOOKUP_NORMAL, lhs, rhs,
@ -5909,11 +6089,20 @@ build_x_modify_expr (tree lhs, enum tree_code modifycode, tree rhs)
/*overloaded_p=*/NULL);
if (rval)
{
/* APPLE LOCAL begin __block assign sequence point 6639533 */
if (insert_sequence_point)
rval = build2 (COMPOUND_EXPR, TREE_TYPE (rval), rhs, rval);
/* APPLE LOCAL end __block assign sequence point 6639533 */
TREE_NO_WARNING (rval) = 1;
return rval;
}
}
return build_modify_expr (lhs, modifycode, rhs);
lhs = build_modify_expr (lhs, modifycode, rhs);
/* APPLE LOCAL begin __block assign sequence point 6639533 */
if (insert_sequence_point)
lhs = build2 (COMPOUND_EXPR, TREE_TYPE (lhs), rhs, lhs);
/* APPLE LOCAL end __block assign sequence point 6639533 */
return lhs;
}
@ -6220,6 +6409,8 @@ convert_for_assignment (tree type, tree rhs,
{
tree rhstype;
enum tree_code coder;
/* APPLE LOCAL radar 4874632 */
tree new_rhs = NULL_TREE;
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
@ -6270,8 +6461,10 @@ convert_for_assignment (tree type, tree rhs,
}
}
if (objc_compare_types (type, rhstype, parmno, rname))
return convert (type, rhs);
/* APPLE LOCAL file radar 6231433 */
if (objc_compare_types (type, rhstype, parmno, rname, "comparison"))
/* APPLE LOCAL radar 4874632 */
new_rhs = convert (type, rhs);
}
/* [expr.ass]
@ -6477,6 +6670,10 @@ maybe_warn_about_returning_address_of_local (tree retval)
if (TREE_CODE (valtype) == REFERENCE_TYPE)
warning (0, "reference to local variable %q+D returned",
whats_returned);
/* APPLE LOCAL begin blocks 6040305 (cn) */
else if (TREE_CODE (valtype) == BLOCK_POINTER_TYPE)
error ("returning block that lives on the local stack");
/* APPLE LOCAL end blocks 6040305 (cn) */
else
warning (0, "address of local variable %q+D returned",
whats_returned);
@ -6484,6 +6681,14 @@ maybe_warn_about_returning_address_of_local (tree retval)
}
}
/* APPLE LOCAL begin blocks 6040305 (cm) */
static bool
types_are_block_compatible (tree t1, tree t2)
{
return comptypes (t1, t2, COMPARE_STRICT);
}
/* APPLE LOCAL end blocks 6040305 (cm) */
/* Check that returning RETVAL from the current function is valid.
Return an expression explicitly showing all conversions required to
change RETVAL into the function return type, and to assign it to
@ -6527,6 +6732,64 @@ check_return_expr (tree retval, bool *no_warning)
return NULL_TREE;
}
/* APPLE LOCAL begin blocks 6040305 (cm) */
/* APPLE LOCAL radar 6185344 */
if (cur_block && !cur_block->block_has_return_type)
{
/* If this is the first return we've seen in the block, infer the type of
the block from it. */
if (cur_block->return_type == NULL_TREE)
{
if (retval)
{
tree restype;
retval = decay_conversion (retval);
restype = TYPE_MAIN_VARIANT (TREE_TYPE (retval));
TREE_TYPE (current_function_decl)
= build_function_type (restype,
TYPE_ARG_TYPES (TREE_TYPE (current_function_decl)));
TREE_TYPE (DECL_RESULT (current_function_decl)) = restype;
relayout_decl (DECL_RESULT (current_function_decl));
cur_block->return_type = restype;
}
else
cur_block->return_type = void_type_node;
}
/* Verify that this result type matches the previous one. We
are pickier with blocks than for normal functions because
this is a new feature and we set the rules. */
if (TREE_CODE (cur_block->return_type) == VOID_TYPE)
{
if (retval)
{
error ("void block should not return a value");
return error_mark_node;
}
}
else if (!retval)
{
error ("non-void block should return a value");
return error_mark_node;
}
if (retval)
{
/* We have a non-void block with an expression, continue checking. */
valtype = TREE_TYPE (retval);
/* For now, restrict multiple return statements in a block to have
strict compatible types only. */
if (!types_are_block_compatible (cur_block->return_type, valtype))
{
error ("incompatible type returning %qT, expected %qT",
valtype, cur_block->return_type);
return error_mark_node;
}
}
}
/* APPLE LOCAL end blocks 6040305 (cm) */
if (processing_template_decl)
{
current_function_returns_value = 1;

View File

@ -1825,6 +1825,8 @@ dbxout_type (tree type, int full)
{
case VOID_TYPE:
case LANG_TYPE:
/* APPLE LOCAL blocks 6034272 */
case BLOCK_POINTER_TYPE:
/* For a void type, just define it as itself; i.e., "5=5".
This makes us consider it defined
without saying what it is. The debugger will make it

View File

@ -85,6 +85,8 @@ extensions, accepted by GCC in C89 mode and in C++.
* Unnamed Fields:: Unnamed struct/union fields within structs/unions.
* Thread-Local:: Per-thread variables.
* Binary constants:: Binary constants using the @samp{0b} prefix.
@c APPLE LOCAL blocks 7205047 5811887
* Blocks:: Anonymous functions (closures).
@end menu
@node Statement Exprs
@ -378,9 +380,14 @@ allows the data to be read-only.
@cindex thunks
A @dfn{nested function} is a function defined inside another function.
(Nested functions are not supported for GNU C++.) The nested function's
name is local to the block where it is defined. For example, here we
define a nested function named @code{square}, and call it twice:
@c APPLE LOCAL begin nested functions 4357979
Nested functions are not supported for GNU C++ and are disable by
default on FreeBSD. The @option{-fnested-functions} and
@option{-fno-nested-functions} options can be used to enable and
disable nested function suppport. The nested function's name is local
to the block where it is defined. For example, here we define a
nested function named @code{square}, and call it twice:
@c APPLE LOCAL end nested functions 4357979
@smallexample
@group
@ -3786,6 +3793,22 @@ and caught in another, the class must have default visibility.
Otherwise the two shared objects will be unable to use the same
typeinfo node and exception handling will break.
@c APPLE LOCAL begin weak types 5954418
@item weak
In C++, attribute weak can be applied to a class to ensure that all
non-hidden instances of the type are treated as the same type across
shared library boundaries on platforms (such as darwin and arm aapcs)
that can emit vtables and the type info meta data as non-comdat
symbols. This is useful when the class has a key method and the
translation unit that contains the key method is used in more than one
shared library or in a shared library and the application. Doing this
results in more expensive startup times. This attribute is inherited
by subclasses, so it is only necessary to mark a base type. The
typical use would be to mark any types used for throwing across shared
library boundaries or those used in dynamic_cast operations across a
shared library boundary.
@c APPLE LOCAL end weak types 5954418
@subsection ARM Type Attributes
On those ARM targets that support @code{dllimport} (such as Symbian
@ -10534,6 +10557,18 @@ Non-@code{static} members shall not be @code{__thread}.
@end quotation
@end itemize
@c APPLE LOCAL begin blocks 7205047 5811887
@node Blocks
@section Blocks
@cindex Blocks
@cindex __block
Blocks is a language feature that allows one to create anonymous
functions. The feature is also known as lambdas or closures in other
languages. The feature is controlled by @option{-fblocks}.
See @uref{http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Blocks/Articles/00_Introduction.html} for additional details.
@c APPLE LOCAL end blocks 7205047 5811887
@node Binary constants
@section Binary constants using the @samp{0b} prefix
@cindex Binary constants using the @samp{0b} prefix

View File

@ -164,10 +164,13 @@ in the following sections.
@xref{C Dialect Options,,Options Controlling C Dialect}.
@gccoptlist{-ansi -std=@var{standard} -fgnu89-inline @gol
-aux-info @var{filename} @gol
-fno-asm -fno-builtin -fno-builtin-@var{function} @gol
@c APPLE LOCAL blocks 7205047 5811887
-fno-asm -fno-blocks -fno-builtin -fno-builtin-@var{function} @gol
-fhosted -ffreestanding -fopenmp -fms-extensions @gol
-trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
-fallow-single-precision -fcond-mismatch -flax-vector-conversions @gol
@c APPLE LOCAL nested functions 4357979 */
-fno-nested-functions @gol
-fsigned-bitfields -fsigned-char @gol
@c APPLE LOCAL -Wnewline-eof 2001-08-23 --sts **
-Wnewline-eof (Apple compatible) @gol
@ -1230,6 +1233,16 @@ effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
switch only affects the @code{asm} and @code{typeof} keywords, since
@code{inline} is a standard keyword in ISO C99.
@c APPLE LOCAL begin blocks 7205047 5811887
@item -fno-blocks
@opindex fno-blocks
Disable the use of blocks. In @option{-std=c99} mode, blocks are
turned off by default. @option{-fblocks} can be used to re-enable the
feature, if off. Runtime support for blocks first appeared in Mac OS
X 10.6. When targeting 10.6 (see @option{-mmacosx-version-min}) and
later, the extension is on by default.
@c APPLE LOCAL end blocks 7205047 5811887
@item -fno-builtin
@itemx -fno-builtin-@var{function}
@opindex fno-builtin
@ -1336,6 +1349,13 @@ C compiler. They are now only supported with the @option{-E} switch.
The preprocessor continues to support a pre-standard mode. See the GNU
CPP manual for details.
@c APPLE LOCAL begin nested functions 4357979
@item -fno-nested-functions
@opindex fno-nested-functions
Disable nested functions. This option is not supported for C++ or
Objective-C++. On FreeBSD, nested functions are disabled by default.
@c APPLE LOCAL end nested functions 4357979
@item -fcond-mismatch
@opindex fcond-mismatch
Allow conditional expressions with mismatched types in the second and

View File

@ -376,7 +376,14 @@ enum dwarf_attribute
/* PGI (STMicroelectronics) extensions. */
DW_AT_PGI_lbase = 0x3a00,
DW_AT_PGI_soffset = 0x3a01,
DW_AT_PGI_lstride = 0x3a02
/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */
DW_AT_PGI_lstride = 0x3a02,
/* APPLE LOCAL begin radar 6386976 */
DW_AT_APPLE_block = 0x3fe4,
/* APPLE LOCAL end radar 5811943 - Fix type of pointers to blocks */
DW_AT_APPLE_major_runtime_vers = 0x3fe5,
DW_AT_APPLE_runtime_class = 0x3fe6
/* APPLE LOCAL end radar 6386976 */
};
#define DW_AT_lo_user 0x2000 /* Implementation-defined range start. */

View File

@ -4731,6 +4731,11 @@ dwarf_attr_name (unsigned int attr)
case DW_AT_VMS_rtnbeg_pd_address:
return "DW_AT_VMS_rtnbeg_pd_address";
/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks */
case DW_AT_APPLE_block:
return "DW_AT_APPLE_block";
/* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
default:
return "DW_AT_<unknown>";
}
@ -8298,6 +8303,8 @@ root_type (tree type)
case ERROR_MARK:
return error_mark_node;
/* APPLE LOCAL radar 5732232 - blocks */
case BLOCK_POINTER_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
return type_main_variant (root_type (TREE_TYPE (type)));
@ -8330,6 +8337,8 @@ is_base_type (tree type)
case ENUMERAL_TYPE:
case FUNCTION_TYPE:
case METHOD_TYPE:
/* APPLE LOCAL radar 5732232 - blocks */
case BLOCK_POINTER_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
@ -8517,7 +8526,8 @@ modified_type_die (tree type, int is_const_type, int is_volatile_type,
mod_type_die = new_die (DW_TAG_volatile_type, comp_unit_die, type);
sub_die = modified_type_die (type, 0, 0, context_die);
}
else if (code == POINTER_TYPE)
/* APPLE LOCAL radar 5732232 - blocks */
else if (code == POINTER_TYPE || code == BLOCK_POINTER_TYPE)
{
mod_type_die = new_die (DW_TAG_pointer_type, comp_unit_die, type);
add_AT_unsigned (mod_type_die, DW_AT_byte_size,
@ -11170,6 +11180,19 @@ add_type_attribute (dw_die_ref object_die, tree type, int decl_const,
enum tree_code code = TREE_CODE (type);
dw_die_ref type_die = NULL;
/* APPLE LOCAL begin radar 5847213 */
/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */
/* APPLE LOCAL - radar 6113240 */
/* APPLE LOCAL begin radar 6300081 */
if (code == BLOCK_POINTER_TYPE && generic_block_literal_struct_type)
{
type = build_pointer_type (generic_block_literal_struct_type);
code = TREE_CODE (type);
}
/* APPLE LOCAL end radar 6300081 */
/* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
/* APPLE LOCAL end radar 5847213 */
/* ??? If this type is an unnamed subrange type of an integral or
floating-point type, use the inner type. This is because we have no
support for unnamed types in base_type_die. This can happen if this is
@ -12555,7 +12578,11 @@ gen_struct_or_union_type_die (tree type, dw_die_ref context_die,
add_AT_specification (type_die, old_die);
else
add_name_attribute (type_die, type_tag (type));
}
/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks */
if (TYPE_BLOCK_IMPL_STRUCT (type))
add_AT_flag (type_die, DW_AT_APPLE_block, 1);
/* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
}
else
remove_AT (type_die, DW_AT_declaration);
@ -12704,7 +12731,8 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
{
case ERROR_MARK:
break;
/* APPLE LOCAL radar 5732232 - blocks */
case BLOCK_POINTER_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
/* We must set TREE_ASM_WRITTEN in case this is a recursive type. This

View File

@ -2616,16 +2616,12 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t,
do_alg_addsub_t_m2:
for (w = 1; (w & t) != 0; w <<= 1)
;
/* If T was -1, then W will be zero after the loop. This is another
case where T ends with ...111. Handling this with (T + 1) and
subtract 1 produces slightly better code and results in algorithm
selection much faster than treating it like the ...0111 case
below. */
if (w == 0
|| (w > 2
/* APPLE LOCAL begin 7744816 DImode multiply by 0xffffffffULL */
if (w > 2
/* Reject the case where t is 3.
Thus we prefer addition in that case. */
&& t != 3))
&& t != 3)
/* APPLE LOCAL end 7744816 DImode multiply by 0xffffffffULL */
{
/* T ends with ...111. Multiply by (T + 1) and subtract 1. */

View File

@ -4770,6 +4770,8 @@ count_type_elements (tree type, bool allow_flexarr)
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
case POINTER_TYPE:
/* APPLE LOCAL radar 5732232 - blocks */
case BLOCK_POINTER_TYPE:
case OFFSET_TYPE:
case REFERENCE_TYPE:
return 1;

View File

@ -2150,6 +2150,8 @@ fold_convert (tree type, tree arg)
{
case INTEGER_TYPE: case ENUMERAL_TYPE: case BOOLEAN_TYPE:
case POINTER_TYPE: case REFERENCE_TYPE:
/* APPLE LOCAL blocks 5862465 */
case BLOCK_POINTER_TYPE:
case OFFSET_TYPE:
if (TREE_CODE (arg) == INTEGER_CST)
{

View File

@ -116,6 +116,10 @@ int current_function_uses_only_leaf_regs;
post-instantiation libcalls. */
int virtuals_instantiated;
/* APPLE LOCAL begin radar 5732232 - blocks */
struct block_sema_info *cur_block;
/* APPLE LOCAL end radar 5732232 - blocks */
/* Assign unique numbers to labels generated for profiling, debugging, etc. */
static GTY(()) int funcdef_no;
@ -214,6 +218,8 @@ static void prepare_function_start (tree);
static void do_clobber_return_reg (rtx, void *);
static void do_use_return_reg (rtx, void *);
static void set_insn_locators (rtx, int) ATTRIBUTE_UNUSED;
/* APPLE LOCAL radar 6163705, Blocks prologues */
static rtx find_block_prologue_insns (void);
/* Pointer to chain of `struct function' for containing functions. */
struct function *outer_function_chain;
@ -3813,17 +3819,23 @@ allocate_struct_function (tree fndecl)
DECL_STRUCT_FUNCTION (fndecl) = cfun;
cfun->decl = fndecl;
result = DECL_RESULT (fndecl);
if (aggregate_value_p (result, fndecl))
/* APPLE LOCAL begin radar 5732232 - blocks */
/* We cannot support blocks which return aggregates because at this
point we do not have info on the return type. */
if (!cur_block)
{
result = DECL_RESULT (fndecl);
if (aggregate_value_p (result, fndecl))
{
#ifdef PCC_STATIC_STRUCT_RETURN
current_function_returns_pcc_struct = 1;
#endif
current_function_returns_struct = 1;
}
current_function_returns_pointer = POINTER_TYPE_P (TREE_TYPE (result));
/* This code is not used anywhere ! */
current_function_returns_pointer = POINTER_TYPE_P (TREE_TYPE (result));
}
/* APPLE LOCAL end radar 5732232 - blocks */
current_function_stdarg
= (fntype
&& TYPE_ARG_TYPES (fntype) != 0
@ -5060,6 +5072,140 @@ emit_equiv_load (struct epi_info *p)
}
#endif
/* APPLE LOCAL begin radar 6163705, Blocks prologues */
/* The function should only be called for Blocks functions.
On being called, the main instruction list for the Blocks function
may contain instructions for setting up the ref_decl and byref_decl
variables in the Block. Those isns really need to go before the
function prologue note rather than after. If such instructions are
present, they are identifiable by their source line number, which
will be one line preceding the declaration of the function. If
they are present, there will also be a source line note instruction
for that line.
This function does a set of things:
- It finds the first such prologue insn.
- It finds the last such prologue insn.
- It changes the insn locator of all such prologue insns to
the prologue locator.
- It finds the source line note for the bogus location and
removes it.
- It decides if it is safe to place the prolgoue end note
after the last prologue insn it finds, and if so, returns
the last prologue insn (otherwise it returns NULL).
This function makes the following checks to determine if it is
safe to move the prologue end note to just below the last
prologue insn it finds. If ALL of the checks succeed then it
is safe. If any check fails, this function returns NULL. The
checks it makes are:
- There were no INSN_P instructions that occurred before the
first prologue insn.
- If there are any non-prologue insns between the first & last
prologue insn, the non-prologue insns do not outnumber the
prologue insns.
- The first prologue insn & the last prologue insn are in the
same basic block.
*/
static rtx
find_block_prologue_insns (void)
{
rtx first_prologue_insn = NULL;
rtx last_prologue_insn = NULL;
rtx line_number_note = NULL;
rtx tmp_insn;
int num_prologue_insns = 0;
int total_insns = 0;
int prologue_line = DECL_SOURCE_LINE (cfun->decl) - 1;
bool other_insns_before_prologue = false;
bool start_of_fnbody_found = false;
/* Go through all the insns and find the first prologue insn, the
last prologue insn, the source line location note, and whether or
not there are any "real" insns that occur before the first
prologue insn. Re-set the insn locator for prologue insns to the
prologue locator. */
for (tmp_insn = get_insns(); tmp_insn; tmp_insn = NEXT_INSN (tmp_insn))
{
if (INSN_P (tmp_insn))
{
if (insn_line (tmp_insn) == prologue_line)
{
if (!first_prologue_insn)
first_prologue_insn = tmp_insn;
num_prologue_insns++;
last_prologue_insn = tmp_insn;
INSN_LOCATOR (tmp_insn) = prologue_locator;
}
else if (!first_prologue_insn
&& start_of_fnbody_found)
other_insns_before_prologue = true;
}
else if (NOTE_P (tmp_insn)
&& NOTE_LINE_NUMBER (tmp_insn) == NOTE_INSN_FUNCTION_BEG)
start_of_fnbody_found = true;
else if (NOTE_P (tmp_insn)
&& (XINT (tmp_insn, 5) == prologue_line))
line_number_note = tmp_insn;
}
/* If there were no prologue insns, return now. */
if (!first_prologue_insn)
return NULL;
/* If the source location note for the line before the beginning of the
function was found, remove it. */
if (line_number_note)
remove_insn (line_number_note);
/* If other real insns got moved above the prologue insns, we can't
pull out the prologue insns, so return now. */
if (other_insns_before_prologue && (optimize > 0))
return NULL;
/* Count the number of insns between the first prologue insn and the
last prologue insn; also count the number of non-prologue insns
between the first prologue insn and the last prologue insn. */
tmp_insn = first_prologue_insn;
while (tmp_insn != last_prologue_insn)
{
total_insns++;
tmp_insn = NEXT_INSN (tmp_insn);
}
total_insns++;
/* If more than half of the insns between the first & last prologue
insns are not prologue insns, then there is too much code that
got moved in between prologue insns (by optimizations), so we
will not try to pull it out. */
if ((num_prologue_insns * 2) <= total_insns)
return NULL;
/* Make sure all the prologue insns are within one basic block.
If the insns cross a basic block boundary, then there is a chance
that moving them will cause incorrect code, so don't do it. */
gcc_assert (first_prologue_insn != NULL);
gcc_assert (last_prologue_insn != NULL);
if (BLOCK_FOR_INSN (first_prologue_insn) !=
BLOCK_FOR_INSN (last_prologue_insn))
return NULL;
return last_prologue_insn;
}
/* APPLE LOCAL end radar 6163705, Blocks prologues */
/* Generate the prologue and epilogue RTL if the machine supports it. Thread
this into place with notes indicating where the prologue ends and where
the epilogue begins. Update the basic block information when possible. */
@ -5083,13 +5229,23 @@ thread_prologue_and_epilogue_insns (rtx f ATTRIBUTE_UNUSED)
#ifdef HAVE_prologue
if (HAVE_prologue)
{
/* APPLE LOCAL begin radar 6163705, Blocks prologues */
rtx last_prologue_insn = NULL;
if (BLOCK_SYNTHESIZED_FUNC (cfun->decl))
last_prologue_insn = find_block_prologue_insns();
/* APPLE LOCAL end radar 6163705, Blocks prologues */
start_sequence ();
seq = gen_prologue ();
emit_insn (seq);
/* Retain a map of the prologue insns. */
record_insns (seq, &prologue);
prologue_end = emit_note (NOTE_INSN_PROLOGUE_END);
/* APPLE LOCAL begin radar 6163705, Blocks prologues */
if (!last_prologue_insn)
prologue_end = emit_note (NOTE_INSN_PROLOGUE_END);
/* APPLE LOCAL end radar 6163705, Blocks prologues */
#ifndef PROFILE_BEFORE_PROLOGUE
/* Ensure that instructions are not moved into the prologue when
@ -5110,7 +5266,11 @@ thread_prologue_and_epilogue_insns (rtx f ATTRIBUTE_UNUSED)
insert_insn_on_edge (seq, single_succ_edge (ENTRY_BLOCK_PTR));
inserted = 1;
}
/* APPLE LOCAL begin radar 6163705, Blocks prologues */
if (last_prologue_insn)
emit_note_after (NOTE_INSN_PROLOGUE_END, last_prologue_insn);
/* APPLE LOCAL end radar 6163705, Blocks prologues */ }
#endif
/* If the exit block has no non-fake predecessors, we don't need

View File

@ -264,6 +264,12 @@ struct function GTY(())
needed by inner routines. */
rtx x_arg_pointer_save_area;
/* APPLE LOCAL begin radar 6411649 */
/* Holds a unique number for this function. It is used to
generate block number for block names. */
int unqiue_block_number;
/* APPLE LOCAL end radar 6411649 */
/* Offset to end of allocated area of stack frame.
If stack grows down, this is the address of the last stack slot allocated.
If stack grows up, this is the address for the next slot. */
@ -579,4 +585,6 @@ extern bool reference_callee_copied (CUMULATIVE_ARGS *, enum machine_mode,
extern void used_types_insert (tree);
/* APPLE LOCAL radar 5732232 - blocks */
extern struct block_sema_info *cur_block;
#endif /* GCC_FUNCTION_H */

View File

@ -716,10 +716,12 @@ ggc_min_expand_heuristic (void)
min_expand = ggc_rlimit_bound (min_expand);
/* The heuristic is a percentage equal to 30% + 70%*(RAM/1GB), yielding
a lower bound of 30% and an upper bound of 100% (when RAM >= 1GB). */
APPLE LOCAL retune gc params 6124839
a lower bound of 30% and an upper bound of 150% (when RAM >= 1.7GB). */
min_expand /= 1024*1024*1024;
min_expand *= 70;
min_expand = MIN (min_expand, 70);
/* APPLE LOCAL retune gc params 6124839 */
min_expand = MIN (min_expand, 120);
min_expand += 30;
return min_expand;
@ -727,7 +729,8 @@ ggc_min_expand_heuristic (void)
/* Heuristic to set a default for GGC_MIN_HEAPSIZE. */
int
ggc_min_heapsize_heuristic (void)
/* APPLE LOCAL retune gc params 6124839 */
ggc_min_heapsize_heuristic (bool optimize)
{
double phys_kbytes = physmem_total();
double limit_kbytes = ggc_rlimit_bound (phys_kbytes * 2);
@ -739,6 +742,13 @@ ggc_min_heapsize_heuristic (void)
bound of 128M (when RAM >= 1GB). */
phys_kbytes /= 8;
/* APPLE LOCAL begin retune gc params 6124839 */
/* Additionally, on a multicore machine, we assume that we share the
memory with others reasonably equally. */
phys_kbytes /= (double)ncpu_available() / (2 - optimize);
/* APPLE LOCAL end retune gc params 6124839 */
#if defined(HAVE_GETRLIMIT) && defined (RLIMIT_RSS)
/* Try not to overrun the RSS limit while doing garbage collection.
The RSS limit is only advisory, so no margin is subtracted. */
@ -765,11 +775,13 @@ ggc_min_heapsize_heuristic (void)
}
void
init_ggc_heuristics (void)
/* APPLE LOCAL retune gc params 6124839 */
init_ggc_heuristics (bool optimize ATTRIBUTE_UNUSED)
{
#if !defined ENABLE_GC_CHECKING && !defined ENABLE_GC_ALWAYS_COLLECT
set_param_value ("ggc-min-expand", ggc_min_expand_heuristic());
set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic());
/* APPLE LOCAL retune gc params 6124839 */
set_param_value ("ggc-min-heapsize", ggc_min_heapsize_heuristic(optimize));
#endif
}

View File

@ -290,8 +290,10 @@ extern void stringpool_statistics (void);
/* Heuristics. */
extern int ggc_min_expand_heuristic (void);
extern int ggc_min_heapsize_heuristic (void);
extern void init_ggc_heuristics (void);
/* APPLE LOCAL begin retune gc params 6124839 */
extern int ggc_min_heapsize_heuristic (bool);
extern void init_ggc_heuristics (bool);
/* APPLE LOCAL end retune gc params 6124839 */
/* Zone collection. */
#if defined (GGC_ZONE) && !defined (GENERATOR_FILE)

View File

@ -95,6 +95,13 @@ struct gimplify_omp_ctx;
extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
tree);
/* APPLE LOCAL begin 6353006 */
extern tree lhd_build_generic_block_struct_type (void);
/* APPLE LOCAL end 6353006 */
/* APPLE LOCAL radar 6386976 */
extern bool lhd_is_runtime_specific_type (tree);
#define LANG_HOOKS_NAME "GNU unknown"
#define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct lang_identifier)
#define LANG_HOOKS_INIT hook_bool_void_false
@ -141,6 +148,11 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
#define LANG_HOOKS_FUNCTION_LEAVE_NESTED lhd_do_nothing_f
#define LANG_HOOKS_FUNCTION_MISSING_NORETURN_OK_P hook_bool_tree_true
/* APPLE LOCAL begin radar 6353006 */
#define LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE \
lhd_build_generic_block_struct_type
/* APPLE LOCAL end radar 6353006 */
/* Attribute hooks. */
#define LANG_HOOKS_ATTRIBUTE_TABLE NULL
#define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE NULL
@ -223,6 +235,8 @@ extern tree lhd_make_node (enum tree_code);
#define LANG_HOOKS_TYPE_MAX_SIZE lhd_return_null_tree
#define LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES \
lhd_omp_firstprivatize_type_sizes
/* APPLE LOCAL radar 6386976 */
#define LANG_HOOKS_IS_RUNTIME_SPECIFIC_TYPE lhd_is_runtime_specific_type
#define LANG_HOOKS_HASH_TYPES true
#define LANG_HOOKS_FOR_TYPES_INITIALIZER { \
@ -238,6 +252,8 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_INCOMPLETE_TYPE_ERROR, \
LANG_HOOKS_TYPE_MAX_SIZE, \
LANG_HOOKS_OMP_FIRSTPRIVATIZE_TYPE_SIZES, \
/* APPLE LOCAL radar 6386976 */ \
LANG_HOOKS_IS_RUNTIME_SPECIFIC_TYPE, \
LANG_HOOKS_HASH_TYPES \
}
@ -333,6 +349,8 @@ extern tree lhd_make_node (enum tree_code);
LANG_HOOKS_BUILTIN_FUNCTION, \
LANG_HOOKS_INIT_TS, \
LANG_HOOKS_EXPR_TO_DECL, \
/* APPLE LOCAL radar 6353006 */ \
LANG_HOOKS_BUILD_GENERIC_BLOCK_STRUCT_TYPE, \
}
#endif /* GCC_LANG_HOOKS_DEF_H */

View File

@ -588,3 +588,19 @@ lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *c ATTRIBUTE_UNUSED,
tree t ATTRIBUTE_UNUSED)
{
}
/* APPLE LOCAL begin radar 6353006 */
tree
lhd_build_generic_block_struct_type (void)
{
return NULL_TREE;
}
/* APPLE LOCAL end radar 6353006 */
/* APPLE LOCAL begin radar 6386976 */
bool
lhd_is_runtime_specific_type (tree type ATTRIBUTE_UNUSED)
{
return false;
}
/* APPLE LOCAL end radar 6386976 */

View File

@ -152,6 +152,12 @@ struct lang_hooks_for_types
firstprivate variables. */
void (*omp_firstprivatize_type_sizes) (struct gimplify_omp_ctx *, tree);
/* APPLE LOCAL begin radar 6386976 */
/* Determine whether the type-tree passed in is specific to the
language/runtime definitions, e.g. is an Objective-C class... */
bool (*is_runtime_specific_type) (tree);
/* APPLE LOCAL end radar 6386976 */
/* Nonzero if types that are identical are to be hashed so that only
one copy is kept. If a language requires unique types for each
user-specified type, such as Ada, this should be set to TRUE. */
@ -468,6 +474,12 @@ struct lang_hooks
TREE_SIDE_EFFECTS need updating. */
tree (*expr_to_decl) (tree expr, bool *tc, bool *ti, bool *se);
/* APPLE LOCAL begin radar 6353006 */
/* For c-based languages, builds a generic type for Blocks pointers (for
emitting debug information. For other languages, returns NULL. */
tree (*build_generic_block_struct_type) (void);
/* APPLE LOCAL end radar 6353006 */
/* Whenever you add entries here, make sure you adjust langhooks-def.h
and langhooks.c accordingly. */
};

View File

@ -1684,6 +1684,8 @@ layout_type (tree type)
case POINTER_TYPE:
case REFERENCE_TYPE:
/* APPLE LOCAL blocks */
case BLOCK_POINTER_TYPE:
{
enum machine_mode mode = ((TREE_CODE (type) == REFERENCE_TYPE

View File

@ -45,6 +45,13 @@ objc_is_object_ptr (tree ARG_UNUSED (arg))
return 0;
}
/* APPLE LOCAL begin radar 4133425 */
bool objc_diagnose_private_ivar (tree ARG_UNUSED (arg))
{
return false;
}
/* APPLE LOCAL end radar 4133425 */
tree
objc_lookup_ivar (tree other, tree ARG_UNUSED (arg))
{
@ -56,6 +63,28 @@ void
objc_check_decl (tree ARG_UNUSED (decl))
{
}
/* APPLE LOCAL begin radar 4281748 */
void
objc_check_global_decl (tree ARG_UNUSED (decl))
{
}
/* APPLE LOCAL end radar 4281748 */
/* APPLE LOCAL begin radar 4330422 */
tree
objc_non_volatilized_type (tree type)
{
return type;
}
/* APPLE LOCAL end radar 4330422 */
/* APPLE LOCAL begin radar 4697411 */
void
objc_volatilize_component_ref (tree ARG_UNUSED (cref), tree ARG_UNUSED (type))
{
}
/* APPLE LOCAL end radar 4697411 */
int
objc_is_reserved_word (tree ARG_UNUSED (ident))
@ -63,12 +92,33 @@ objc_is_reserved_word (tree ARG_UNUSED (ident))
return 0;
}
bool
objc_compare_types (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
int ARG_UNUSED (argno), tree ARG_UNUSED (callee))
/* APPLE LOCAL begin 4154928 */
tree
objc_common_type (tree ARG_UNUSED (type1), tree ARG_UNUSED (type2))
{
return false;
}
/* APPLE LOCAL end 4154928 */
bool
objc_compare_types (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
/* APPLE LOCAL begin radar 6231433 */
int ARG_UNUSED (argno), tree ARG_UNUSED (callee),
const char * ARG_UNUSED (message))
/* APPLE LOCAL end radar 6231433 */
{
return false;
}
/* APPLE LOCAL begin radar 4229905 - radar 6231433 */
bool
objc_have_common_type (tree ARG_UNUSED (ltyp), tree ARG_UNUSED (rtyp),
int ARG_UNUSED (argno), tree ARG_UNUSED (callee),
const char * ARG_UNUSED (message))
{
return false;
}
/* APPLE LOCAL end radar 4229905 - radar 6231433 */
void
objc_volatilize_decl (tree ARG_UNUSED (decl))
@ -104,20 +154,26 @@ objc_declare_class (tree ARG_UNUSED (list))
}
void
objc_declare_protocols (tree ARG_UNUSED (list))
/* APPLE LOCAL begin radar 4947311 - protocol attributes */
objc_declare_protocols (tree ARG_UNUSED (list), tree ARG_UNUSED (attributes))
{
}
void
objc_start_protocol (tree ARG_UNUSED (proto),
tree ARG_UNUSED (protorefs))
tree ARG_UNUSED (protorefs),
tree ARG_UNUSED (attributes))
{
}
/* APPLE LOCAL end radar 4947311 - protocol attributes */
void
objc_start_class_interface (tree ARG_UNUSED (name),
tree ARG_UNUSED (super),
tree ARG_UNUSED (protos))
/* APPLE LOCAL begin radar 4548636 */
tree ARG_UNUSED (protos),
tree ARG_UNUSED (attributes))
/* APPLE LOCAL end radar 4548636 */
{
}
@ -181,12 +237,18 @@ objc_finish_implementation (void)
}
void
objc_add_method_declaration (tree ARG_UNUSED (signature))
/* APPLE LOCAL begin radar 3803157 - objc attribute */
objc_add_method_declaration (tree ARG_UNUSED (signature),
tree ARG_UNUSED (attribute))
/* APPLE LOCAL end radar 3803157 - objc attribute */
{
}
void
objc_start_method_definition (tree ARG_UNUSED (signature))
/* APPLE LOCAL begin radar 3803157 - objc attribute */
objc_start_method_definition (tree ARG_UNUSED (signature),
tree ARG_UNUSED (attribute))
/* APPLE LOCAL end radar 3803157 - objc attribute */
{
}
@ -198,7 +260,10 @@ objc_finish_method_definition (tree ARG_UNUSED (fndecl))
tree
objc_build_keyword_decl (tree ARG_UNUSED (selector),
tree ARG_UNUSED (typename),
tree ARG_UNUSED (identifier))
/* APPLE LOCAL begin radar 4157812 */
tree ARG_UNUSED (identifier),
tree ARG_UNUSED (attribute))
/* APPLE LOCAL end radar 4157812 */
{
return 0;
}
@ -248,6 +313,18 @@ objc_get_class_reference (tree ARG_UNUSED (name))
return 0;
}
/* APPLE LOCAL begin radar 4291785 */
tree
objc_get_interface_ivars (tree ARG_UNUSED (fieldlist))
{
return 0;
}
void
objc_detect_field_duplicates (tree ARG_UNUSED (fieldlist))
{
}
/* APPLE LOCAL end radar 4291785 */
tree
objc_get_protocol_qualified_type (tree ARG_UNUSED (name),
tree ARG_UNUSED (protos))
@ -273,6 +350,49 @@ objc_is_public (tree ARG_UNUSED (expr), tree ARG_UNUSED (identifier))
return 1;
}
/* APPLE LOCAL begin C* language */
void
objc_set_method_opt (int ARG_UNUSED (opt))
{
}
tree
objc_build_component_ref (tree ARG_UNUSED (datum), tree ARG_UNUSED (component))
{
return 0;
}
tree
objc_build_foreach_components (tree ARG_UNUSED (receiver),
tree *ARG_UNUSED (enumState_decl),
tree *ARG_UNUSED (items_decl),
tree *ARG_UNUSED (limit_decl),
tree *ARG_UNUSED (startMutations_decl),
tree *ARG_UNUSED (counter_decl),
tree *ARG_UNUSED (countByEnumeratingWithState))
{
return 0;
}
/* APPLE LOCAL end C* language */
/* APPLE LOCAL begin C* property (Radar 4436866) */
void
objc_set_property_attr (int ARG_UNUSED (code), tree ARG_UNUSED (identifier))
{
}
void
objc_add_property_variable (tree ARG_UNUSED (prop))
{
}
/* APPLE LOCAL radar 5285911 */
/* Stub for objc_build_getter_call is removed. */
tree
objc_build_setter_call (tree ARG_UNUSED (lhs), tree ARG_UNUSED (rhs))
{
return 0;
}
/* APPLE LOCAL end C* property (Radar 4436866) */
tree
objc_get_class_ivars (tree ARG_UNUSED (name))
{
@ -326,3 +446,143 @@ objc_generate_write_barrier (tree ARG_UNUSED (lhs),
{
return 0;
}
/* APPLE LOCAL begin radar 5276085 */
void objc_weak_reference_expr (tree* ARG_UNUSED (expr))
{
}
tree
objc_build_weak_reference_tree (tree expr)
{
return expr;
}
/* APPLE LOCAL end radar 5276085 */
/* APPLE LOCAL begin C* warnings to easy porting to new abi */
void
diagnose_selector_cast (tree ARG_UNUSED (cast_type), tree ARG_UNUSED (sel_exp))
{
}
/* APPLE LOCAL end C* warnings to easy porting to new abi */
/* APPLE LOCAL begin radar 4441049 */
tree
objc_v2_component_ref_field_offset (tree ARG_UNUSED (exp))
{
return 0;
}
tree
objc_v2_bitfield_ivar_bitpos (tree ARG_UNUSED (exp))
{
return 0;
}
/* APPLE LOCAL end radar 4441049 */
/* APPLE LOCAL begin radar 4507230 */
bool
objc_type_valid_for_messaging (tree ARG_UNUSED (exp))
{
return false;
}
/* APPLE LOCAL end radar 4507230 */
/* APPLE LOCAL begin radar 3803157 - objc attribute */
bool
objc_method_decl (enum tree_code ARG_UNUSED (opcode))
{
return false;
}
/* APPLE LOCAL end radar 3803157 - objc attribute */
/* APPLE LOCAL begin radar 4708210 (for_objc_collection in 4.2) */
void
objc_finish_foreach_loop (location_t ARG_UNUSED (location), tree ARG_UNUSED (cond),
tree ARG_UNUSED (for_body), tree ARG_UNUSED (blab),
tree ARG_UNUSED (clab))
{
return;
}
/* APPLE LOCAL end radar 4708210 (for_objc_collection in 4.2) */
/* APPLE LOCAL begin radar 5847976 */
int
objc_is_gcable_type (tree ARG_UNUSED (type))
{
return 0;
}
/* APPLE LOCAL end radar 5847976 */
/* APPLE LOCAL begin radar 4592503 */
void
objc_checkon_weak_attribute (tree ARG_UNUSED (decl))
{
return;
}
/* APPLE LOCAL end radar 4592503 */
/* APPLE LOCAL begin radar 4712269 */
tree
objc_build_incr_decr_setter_call (enum tree_code ARG_UNUSED (code),
tree ARG_UNUSED (lhs),
tree ARG_UNUSED (inc))
{
return NULL_TREE;
}
/* APPLE LOCAL end radar 4712269 */
/* APPLE LOCAL begin objc new property */
void objc_declare_property_impl (int ARG_UNUSED (code),
tree ARG_UNUSED (tree_list))
{
}
/* APPLE LOCAL begin radar 5285911 */
tree
objc_build_property_reference_expr (tree ARG_UNUSED (datum),
tree ARG_UNUSED (component))
{
return 0;
}
bool
objc_property_reference_expr (tree ARG_UNUSED (exp))
{
return false;
}
/* APPLE LOCAL end radar 5285911 */
/* APPLE LOCAL end objc new property */
/* APPLE LOCAL begin radar 4985544 */
bool
objc_check_format_nsstring (tree ARG_UNUSED (argument),
unsigned HOST_WIDE_INT ARG_UNUSED (format_num),
bool * ARG_UNUSED(no_add_attrs))
{
return false;
}
/* APPLE LOCAL end radar 4985544 */
/* APPLE LOCAL begin radar 5202926 */
bool
objc_anonymous_local_objc_name (const char * ARG_UNUSED (name))
{
return false;
}
/* APPLE LOCAL begin radar 5195402 */
bool
objc_check_nsstring_pointer_type (tree ARG_UNUSED (type))
{
return false;
}
/* APPLE LOCAL end radar 5195402 */
/* APPLE LOCAL end radar 5202926 */
/* APPLE LOCAL begin radar 5782740 - blocks */
bool block_requires_copying (tree exp)
{
/* APPLE LOCAL begin radar 6175959 */
tree type = TREE_TYPE (exp);
return TREE_CODE (type) == BLOCK_POINTER_TYPE
|| (POINTER_TYPE_P (type)
&& lookup_attribute ("NSObject", TYPE_ATTRIBUTES (type)));
/* APPLE LOCAL end radar 6175959 */
}
/* APPLE LOCAL end radar 5782740 - blocks */
/* APPLE LOCAL begin radar 5802025 */
tree objc_build_property_getter_func_call (tree object)
{
return object;
}
/* APPLE LOCAL end radar 5802025 */

View File

@ -95,6 +95,18 @@ default_return_in_memory (tree type,
#endif
}
/* APPLE LOCAL begin radar 4781080 */
bool
default_objc_fpreturn_msgcall (tree type, bool no_long_double)
{
#ifndef OBJC_FPRETURN_MSGCALL
return type == NULL_TREE && no_long_double;
#else
return OBJC_FPRETURN_MSGCALL (type, no_long_double);
#endif
}
/* APPLE LOCAL end radar 4781080 */
rtx
default_expand_builtin_saveregs (void)
{

View File

@ -1566,8 +1566,19 @@ general_init (const char *argv0)
/* Register the language-independent parameters. */
add_params (lang_independent_params, LAST_PARAM);
/* This must be done after add_params but before argument processing. */
init_ggc_heuristics();
/* APPLE LOCAL begin retune gc params 6124839 */
{ int i = 0;
bool opt = false;
while (save_argv[++i])
{
if (strncmp (save_argv[i], "-O", 2) == 0
&& strcmp (save_argv[i], "-O0") != 0)
opt = true;
}
/* This must be done after add_params but before argument processing. */
init_ggc_heuristics(opt);
}
/* APPLE LOCAL end retune gc params 6124839 */
init_optimization_passes ();
}

View File

@ -140,7 +140,8 @@ extern void diagnose_omp_structured_block_errors (tree);
extern tree omp_reduction_init (tree, tree);
/* In tree-nested.c. */
extern void lower_nested_functions (tree);
/* APPLE LOCAL radar 6305545 */
extern void lower_nested_functions (tree, bool);
extern void insert_field_into_struct (tree, tree);
/* Convenience routines to walk all statements of a gimple function.

View File

@ -1970,7 +1970,8 @@ static GTY(()) struct nesting_info *root;
subroutines and turn them into something less tightly bound. */
void
lower_nested_functions (tree fndecl)
/* APPLE LOCAL radar 6305545 */
lower_nested_functions (tree fndecl, bool skip_outermost_fndecl)
{
struct cgraph_node *cgn;
@ -1980,6 +1981,13 @@ lower_nested_functions (tree fndecl)
return;
root = create_nesting_tree (cgn);
/* APPLE LOCAL begin radar 6305545 */
/* If skip_outermost_fndecl is true, we are lowering nested functions of
a constructor/destructor which are cloned and thrown away. But we
still have to lower their nested functions, but not the outermost function. */
if (skip_outermost_fndecl)
root = root->inner;
/* APPLE LOCAL end radar 6305545 */
walk_all_functions (convert_nonlocal_reference, root);
walk_all_functions (convert_local_reference, root);
walk_all_functions (convert_nl_goto_reference, root);

View File

@ -69,6 +69,10 @@ const char *const tree_code_class_strings[] =
"expression",
};
/* APPLE LOCAL begin 6353006 */
tree generic_block_literal_struct_type;
/* APPLE LOCAL end 6353006 */
/* obstack.[ch] explicitly declined to prototype this. */
extern int _obstack_allocated_p (struct obstack *h, void *obj);
@ -5016,6 +5020,31 @@ build_pointer_type (tree to_type)
return build_pointer_type_for_mode (to_type, ptr_mode, false);
}
/* APPLE LOCAL begin radar 5732232 - blocks */
tree
build_block_pointer_type (tree to_type)
{
tree t;
/* APPLE LOCAL begin radar 6300081 & 6353006 */
if (!generic_block_literal_struct_type)
generic_block_literal_struct_type =
lang_hooks.build_generic_block_struct_type ();
/* APPLE LOCAL end radar 6300081 & 6353006 */
t = make_node (BLOCK_POINTER_TYPE);
TREE_TYPE (t) = to_type;
TYPE_MODE (t) = ptr_mode;
/* Lay out the type. This function has many callers that are concerned
with expression-construction, and this simplifies them all. */
layout_type (t);
return t;
}
/* APPLE LOCAL end radar 5732232 - blocks */
/* Same as build_pointer_type_for_mode, but for REFERENCE_TYPE. */
tree
@ -7771,4 +7800,5 @@ empty_body_p (tree stmt)
return true;
}
#include "gt-tree.h"

View File

@ -177,6 +177,11 @@ DEFTREECODE (POINTER_TYPE, "pointer_type", tcc_type, 0)
automatically to the value it points to. Used in C++. */
DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0)
/* APPLE LOCAL begin radar 5732232 - blocks */
/* All pointer-to-block types have code BLOCK_POINTER_TYPE.
The TREE_TYPE points to the node for the type pointed to. */
DEFTREECODE (BLOCK_POINTER_TYPE, "block_pointer_type", tcc_type, 0)
/* APPLE LOCAL end radar 5732232 - blocks */
/* The ordering of the following codes is optimized for the checking
macros in tree.h. Changing the order will degrade the speed of the
compiler. COMPLEX_TYPE, VECTOR_TYPE, ARRAY_TYPE. */

View File

@ -869,7 +869,8 @@ extern void omp_clause_range_check_failed (const tree, const char *, int,
#define CST_CHECK(T) TREE_CLASS_CHECK (T, tcc_constant)
#define STMT_CHECK(T) TREE_CLASS_CHECK (T, tcc_statement)
#define FUNC_OR_METHOD_CHECK(T) TREE_CHECK2 (T, FUNCTION_TYPE, METHOD_TYPE)
#define PTR_OR_REF_CHECK(T) TREE_CHECK2 (T, POINTER_TYPE, REFERENCE_TYPE)
/* APPLE LOCAL blocks 5862465 */
#define PTR_OR_REF_CHECK(T) TREE_CHECK3 (T, POINTER_TYPE, REFERENCE_TYPE, BLOCK_POINTER_TYPE)
#define RECORD_OR_UNION_CHECK(T) \
TREE_CHECK3 (T, RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE)
@ -998,8 +999,12 @@ extern void omp_clause_range_check_failed (const tree, const char *, int,
(It should be renamed to INDIRECT_TYPE_P.) Keep these checks in
ascending code order. */
/* APPLE LOCAL begin blocks 5862465 */
#define POINTER_TYPE_P(TYPE) \
(TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)
(TREE_CODE (TYPE) == POINTER_TYPE \
|| TREE_CODE (TYPE) == REFERENCE_TYPE \
|| TREE_CODE (TYPE) == BLOCK_POINTER_TYPE)
/* APPLE LOCAL end blocks 5862465 */
/* Nonzero if this type is a complete type. */
#define COMPLETE_TYPE_P(NODE) (TYPE_SIZE (NODE) != NULL_TREE)
@ -2102,6 +2107,17 @@ struct tree_block GTY(())
#define TYPE_CONTAINS_PLACEHOLDER_INTERNAL(NODE) \
(TYPE_CHECK (NODE)->type.contains_placeholder_bits)
/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */
/* Indicates that the struct type is a block struct, rather than
a 'normal' struct, i.e. one of its fields is a function that can
be called. This uses the existing bit-field lang_flag_2 in the
struct tree_type, rather than creating a new bit field, as
lang_flag_2 is currently unused and we don't want to increase the
size of trees if we can avoid it. */
#define TYPE_BLOCK_IMPL_STRUCT(NODE) \
(TYPE_CHECK (NODE)->type.lang_flag_2)
/* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
struct die_struct;
struct tree_type GTY(())
@ -2126,6 +2142,14 @@ struct tree_type GTY(())
unsigned lang_flag_0 : 1;
unsigned lang_flag_1 : 1;
/* APPLE LOCAL begin radar 5811943 - Fix type of pointers to Blocks */
/* Since it is currently completely unused, and in the interest of
not making trees any bigger than they already are, lang_flag_2
in the tree_type struct will be used to indicate that a struct is a
block struct. The macro used for these purposes is
TYPE_BLOCK_IMPL_STRUCT, rather than TYPE_LANG_FLAG_2, in order to make
its uses in the code more clear. */
/* APPLE LOCAL end radar 5811943 - Fix type of pointers to Blocks */
unsigned lang_flag_2 : 1;
unsigned lang_flag_3 : 1;
unsigned lang_flag_4 : 1;
@ -2595,6 +2619,9 @@ struct tree_decl_common GTY(())
unsigned gimple_reg_flag : 1;
unsigned call_clobbered_flag : 1;
/* APPLE LOCAL duplicate decls in multiple files. */
unsigned duplicate_decl : 1;
unsigned int align : 24;
/* DECL_OFFSET_ALIGN, used only for FIELD_DECLs. */
unsigned int off_align : 8;
@ -2776,6 +2803,9 @@ struct tree_parm_decl GTY(())
so it should not be output now. */
#define DECL_DEFER_OUTPUT(NODE) (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.defer_output)
/* APPLE LOCAL duplicate decls in multiple files. */
#define DECL_DUPLICATE_DECL(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.duplicate_decl)
/* Nonzero for a given ..._DECL node means that no warnings should be
generated just because this node is unused. */
#define DECL_IN_SYSTEM_HEADER(NODE) \
@ -2919,7 +2949,21 @@ struct tree_decl_with_vis GTY(())
/* Belongs to VAR_DECL exclusively. */
ENUM_BITFIELD(tls_model) tls_model : 3;
/* 11 unused bits. */
/* APPLE LOCAL begin radar 5732232 - blocks */
/* Belong to VAR_DECL exclusively. */
unsigned block_decl_byref : 1;
unsigned block_decl_copied : 1;
/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
unsigned copyable_byref_local_var : 1;
unsigned copyable_byref_local_nonpod : 1;
/* APPLE LOCAL radar 6172148 */
unsigned block_synthesized_function : 1;
/* APPLE LOCAL radar 5847976 */
unsigned block_weak : 1;
/* 5 unused bits. */
/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
/* APPLE LOCAL end radar 5732232 - blocks */
};
/* In a VAR_DECL that's static,
@ -2965,6 +3009,19 @@ extern void decl_init_priority_insert (tree, unsigned short);
thread-local storage. */
#define DECL_TLS_MODEL(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.tls_model)
/* APPLE LOCAL begin radar 5732232 - blocks */
#define BLOCK_DECL_BYREF(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_decl_byref)
#define BLOCK_DECL_COPIED(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_decl_copied)
/* APPLE LOCAL end radar 5732232 - blocks */
/* APPLE LOCAL radar 6172148 */
#define BLOCK_SYNTHESIZED_FUNC(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_with_vis.block_synthesized_function)
/* APPLE LOCAL begin radar 5932809 - copyable byref blocks */
#define COPYABLE_BYREF_LOCAL_VAR(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_var)
#define COPYABLE_BYREF_LOCAL_NONPOD(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.copyable_byref_local_nonpod)
/* APPLE LOCAL radar 5847976 */
#define COPYABLE_WEAK_BLOCK(NODE) (VAR_DECL_CHECK (NODE)->decl_with_vis.block_weak)
/* APPLE LOCAL end radar 5932809 - copyable byref blocks */
/* In a VAR_DECL, nonzero if the data should be allocated from
thread-local storage. */
#define DECL_THREAD_LOCAL_P(NODE) \
@ -3615,6 +3672,8 @@ extern void set_sizetype (tree);
extern void fixup_unsigned_type (tree);
extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);
extern tree build_pointer_type (tree);
/* APPLE LOCAL radar 5732232 - blocks */
extern tree build_block_pointer_type (tree);
extern tree build_reference_type_for_mode (tree, enum machine_mode, bool);
extern tree build_reference_type (tree);
extern tree build_vector_type_for_mode (tree, enum machine_mode);
@ -4661,4 +4720,8 @@ extern unsigned HOST_WIDE_INT compute_builtin_object_size (tree, int);
/* In expr.c. */
extern unsigned HOST_WIDE_INT highest_pow2_factor (tree);
/* APPLE LOCAL begin radar 6300081 */
extern GTY(()) tree generic_block_literal_struct_type;
/* APPLE LOCAL end radar 6300081 */
#endif /* GCC_TREE_H */

View File

@ -4071,6 +4071,8 @@ output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align)
case ENUMERAL_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
/* APPLE LOCAL radar 5822844 */
case BLOCK_POINTER_TYPE:
case OFFSET_TYPE:
if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
EXPAND_INITIALIZER),

View File

@ -296,6 +296,10 @@ extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC;
extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC;
/* APPLE LOCAL begin retune gc params 6124839 */
extern unsigned int ncpu_available (void);
/* APPLE LOCAL end retune gc params 6124839 */
/* Physical memory routines. Return values are in BYTES. */
extern double physmem_total (void);
extern double physmem_available (void);

View File

@ -182,6 +182,36 @@ physmem_total (void)
return 0;
}
/* APPLE LOCAL begin retune gc params 6124839 */
unsigned int
ncpu_available (void)
{
#if HAVE_SYSCTL && defined HW_AVAILCPU
{ /* This works on *bsd and darwin. */
unsigned int ncpu;
size_t len = sizeof ncpu;
static int mib[2] = { CTL_HW, HW_AVAILCPU };
if (sysctl (mib, ARRAY_SIZE (mib), &ncpu, &len, NULL, 0) == 0
&& len == sizeof (ncpu))
return ncpu;
}
#endif
#if HAVE_SYSCTL && defined HW_NCPU
{ /* This works on *bsd and darwin. */
unsigned int ncpu;
size_t len = sizeof ncpu;
static int mib[2] = { CTL_HW, HW_NCPU };
if (sysctl (mib, ARRAY_SIZE (mib), &ncpu, &len, NULL, 0) == 0
&& len == sizeof (ncpu))
return ncpu;
}
#endif
return 1;
}
/* APPLE LOCAL end retune gc params 6124839 */
/* Return the amount of physical memory available. */
double
physmem_available (void)