Bug 701183 - Make MOZ_DELETE use deleted function syntax in gcc when it's possible to do so without causing a warning. r=cjones

--HG--
extra : rebase_source : 6f452c9cc9dcdc772991ee1056975bf7b0b4bb5b
This commit is contained in:
Jeff Walden 2011-11-10 14:19:28 -08:00
parent 7a507e08bb
commit d0edb425f5
3 changed files with 26 additions and 17 deletions

View File

@ -268,9 +268,9 @@ class RangedPtr
}
private:
RangedPtr();
T* operator&();
operator T*() const;
RangedPtr() MOZ_DELETE;
T* operator&() MOZ_DELETE;
operator T*() const MOZ_DELETE;
};
} /* namespace mozilla */

View File

@ -269,8 +269,8 @@ private:
RefPtr<T>& refPtr;
T* tmp;
OutParamRef();
OutParamRef& operator=(const OutParamRef&);
OutParamRef() MOZ_DELETE;
OutParamRef& operator=(const OutParamRef&) MOZ_DELETE;
};
/**

View File

@ -93,19 +93,21 @@
/*
* 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.
@ -113,11 +115,18 @@
#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