summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cp/call.c
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2014-01-05 00:43:28 +0000
committerpfg <pfg@FreeBSD.org>2014-01-05 00:43:28 +0000
commit9c8bbe68490d277cf64459b3390cf48e2a09ddf6 (patch)
treefffd69b9133b091a53ee14b3de5fd5006d53f92a /contrib/gcc/cp/call.c
parentc5e9a8143da358a2c480a64c9782d5eedda3b002 (diff)
downloadFreeBSD-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/call.c')
-rw-r--r--contrib/gcc/cp/call.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/contrib/gcc/cp/call.c b/contrib/gcc/cp/call.c
index 24b5d1f..1de6a47 100644
--- a/contrib/gcc/cp/call.c
+++ b/contrib/gcc/cp/call.c
@@ -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)))
{
OpenPOWER on IntegriCloud