diff options
author | pfg <pfg@FreeBSD.org> | 2014-01-05 00:43:28 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-01-05 00:43:28 +0000 |
commit | 9c8bbe68490d277cf64459b3390cf48e2a09ddf6 (patch) | |
tree | fffd69b9133b091a53ee14b3de5fd5006d53f92a /contrib/gcc/cp/cp-gimplify.c | |
parent | c5e9a8143da358a2c480a64c9782d5eedda3b002 (diff) | |
download | FreeBSD-src-9c8bbe68490d277cf64459b3390cf48e2a09ddf6.zip FreeBSD-src-9c8bbe68490d277cf64459b3390cf48e2a09ddf6.tar.gz |
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
Diffstat (limited to 'contrib/gcc/cp/cp-gimplify.c')
-rw-r--r-- | contrib/gcc/cp/cp-gimplify.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/contrib/gcc/cp/cp-gimplify.c b/contrib/gcc/cp/cp-gimplify.c index 08d4ca0..879356a 100644 --- a/contrib/gcc/cp/cp-gimplify.c +++ b/contrib/gcc/cp/cp-gimplify.c @@ -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); |