summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/c-pretty-print.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/c-pretty-print.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/c-pretty-print.c')
-rw-r--r--contrib/gcc/c-pretty-print.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/contrib/gcc/c-pretty-print.c b/contrib/gcc/c-pretty-print.c
index 5225ea3..ee60864 100644
--- a/contrib/gcc/c-pretty-print.c
+++ b/contrib/gcc/c-pretty-print.c
@@ -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;
OpenPOWER on IntegriCloud