author | Jeff Walden <jwalden@mit.edu> |
Thu, 10 Nov 2011 14:19:28 -0800 | |
changeset 80164 | c3a965a12bc891e0b898f9e6c7c8cc000e2ffe43 |
parent 80163 | f4183f93f844d145ed0bab21b89edb1179b356d9 |
child 80165 | b7d2f71b4c87b287014e7ae39e1fd9ec6da7e03a |
push id | 21467 |
push user | mak77@bonardo.net |
push date | Fri, 11 Nov 2011 10:10:59 +0000 |
treeherder | mozilla-central@50c1bcb49c76 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | cjones |
bugs | 701183 |
milestone | 11.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
mfbt/RangedPtr.h | file | annotate | diff | comparison | revisions | |
mfbt/RefPtr.h | file | annotate | diff | comparison | revisions | |
mfbt/Types.h | file | annotate | diff | comparison | revisions |
--- a/mfbt/RangedPtr.h +++ b/mfbt/RangedPtr.h @@ -263,18 +263,18 @@ class RangedPtr } size_t operator-(const RangedPtr<T>& other) const { MOZ_ASSERT(ptr >= other.ptr); return PointerRangeSize(other.ptr, ptr); } private: - RangedPtr(); - T* operator&(); - operator T*() const; + RangedPtr() MOZ_DELETE; + T* operator&() MOZ_DELETE; + operator T*() const MOZ_DELETE; }; } /* namespace mozilla */ #endif /* __cplusplus */ #endif /* mozilla_RangedPtr_h_ */
--- a/mfbt/RefPtr.h +++ b/mfbt/RefPtr.h @@ -264,18 +264,18 @@ public: operator T**() { return &tmp; } private: OutParamRef(RefPtr<T>& p) : refPtr(p), tmp(p.get()) {} RefPtr<T>& refPtr; T* tmp; - OutParamRef(); - OutParamRef& operator=(const OutParamRef&); + OutParamRef() MOZ_DELETE; + OutParamRef& operator=(const OutParamRef&) MOZ_DELETE; }; /** * byRef cooperates with OutParamRef to implement COM outparam semantics. */ template<typename T> OutParamRef<T> byRef(RefPtr<T>& ptr)
--- a/mfbt/Types.h +++ b/mfbt/Types.h @@ -88,40 +88,49 @@ #define MOZ_BEGIN_EXTERN_C JS_BEGIN_EXTERN_C #define MOZ_END_EXTERN_C JS_END_EXTERN_C #ifdef __cplusplus /* * MOZ_DELETE, specified immediately prior to the ';' terminating an undefined- * method declaration, attempts to delete that method from the corresponding - * class. An attempt to use the method will produce an error *at link time*, - * not at compile time, in compilers for which this macro can be implemented. - * For example, you can use this macro to produce classes with no implicit copy - * constructor or assignment operator: + * class. An attempt to use the method will always produce an error *at compile + * time* (instead of sometimes as late as link time) when this macro can be + * implemented. For example, you can use MOZ_DELETE to produce classes with no + * implicit copy constructor or assignment operator: * - * struct NonCopyable { + * struct NonCopyable + * { * private: * NonCopyable(const NonCopyable& other) MOZ_DELETE; * void operator=(const NonCopyable& other) MOZ_DELETE; * }; * - * If MOZ_DELETE can't be implemented for the current compiler, it will still - * cause an error, but at link time rather than compile time. + * If MOZ_DELETE can't be implemented for the current compiler, use of the + * annotated method will still cause an error, but the error might occur at link + * time in some cases rather than at compile time. * * MOZ_DELETE relies on C++11 functionality not universally implemented. As a * backstop, method declarations using MOZ_DELETE should be private. */ #if defined(__clang__) && (__clang_major__ >= 3 || (__clang_major__ == 2 && __clang_minor__ >= 9)) # define MOZ_DELETE = delete #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) -/* - * g++ >= 4.4 supports deleted functions, but it requires -std=c++0x or - * -std=gnu++0x, and for various reasons we can't use these yet. - */ -# define MOZ_DELETE /* = delete */ + /* + * g++ >= 4.4 requires -std=c++0x or -std=gnu++0x to support deleted functions + * without warnings. These modes are detectable by the experimental macro used + * below or, more standardly, by checking whether __cplusplus has a C++11 or + * greater value. Current versions of g++ do not correctly set __cplusplus, so + * we check both for forward compatibility. + */ +# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L +# define MOZ_DELETE = delete +# else +# define MOZ_DELETE /* = delete */ +# endif #else # define MOZ_DELETE /* unknown C++11 deleted function support */ #endif #endif /* __cplusplus */ #endif /* mozilla_Types_h_ */