diff options
author | pfg <pfg@FreeBSD.org> | 2014-01-26 19:49:54 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-01-26 19:49:54 +0000 |
commit | fe288f1b72a13316f613e06cd07d4d777cd59b99 (patch) | |
tree | 388002273457e1ebeee9510b9908dc299e3748f1 /contrib/gcc/cp/class.c | |
parent | 5c96f061e7bff64c2387d5fd90ff095b71ce59b2 (diff) | |
download | FreeBSD-src-fe288f1b72a13316f613e06cd07d4d777cd59b99.zip FreeBSD-src-fe288f1b72a13316f613e06cd07d4d777cd59b99.tar.gz |
MFC r260311, r260831:
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 __block is not
actually a keyword, but a macro. There may be workaround for this
issue in the 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.
References:
[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
Diffstat (limited to 'contrib/gcc/cp/class.c')
-rw-r--r-- | contrib/gcc/cp/class.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/contrib/gcc/cp/class.c b/contrib/gcc/cp/class.c index 1f30524..047ce17 100644 --- a/contrib/gcc/cp/class.c +++ b/contrib/gcc/cp/class.c @@ -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 */ } } |