Bug 1077887: Work around old GCC "enum class" bug, r=mmc

--HG--
extra : rebase_source : ce707672dfc0587760c09701fd6adbe26c874916
This commit is contained in:
Brian Smith 2014-10-04 18:45:31 -07:00
parent 9e344e0256
commit 1fc729071e
2 changed files with 10 additions and 8 deletions

View File

@ -149,10 +149,10 @@ const char* MapResultToName(Result result);
// those comparisons clearer, especially because the shortened name often
// results in less line wrapping.
//
// Visual Studio before VS2013 does not support "enum class," so
// Result::Success will already be visible in this scope, and compilation will
// fail if we try to define a variable with that name here.
#if !defined(_MSC_VER) || (_MSC_VER >= 1700)
// If MOZILLA_PKIX_ENUM_CLASS doesn't expand to "enum class" then
// Result::Success will already be in scope, and compilation would fail if we
// were to try to define a variable named "Success" here.
#ifdef MOZILLA_PKIX_ENUM_CLASS_REALLY_IS_ENUM_CLASS
static const Result Success = Result::Success;
#endif

View File

@ -22,10 +22,6 @@
* limitations under the License.
*/
// Work around missing std::bind, std::ref, std::cref in older compilers. This
// implementation isn't intended to be complete; rather, it is the minimal
// implementation needed to make our use of std::bind work.
#ifndef mozilla_pkix__enumclass_h
#define mozilla_pkix__enumclass_h
@ -35,8 +31,14 @@
// enums results in C4480: nonstandard extension used: specifying underlying
// type for enum.
#define MOZILLA_PKIX_ENUM_CLASS __pragma(warning(suppress: 4480)) enum
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 407)
// GCC before version 4.7 may crash when compiling code that static_casts a
// value of scoped typed enum type. See
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48106.
#define MOZILLA_PKIX_ENUM_CLASS enum
#else
#define MOZILLA_PKIX_ENUM_CLASS enum class
#define MOZILLA_PKIX_ENUM_CLASS_REALLY_IS_ENUM_CLASS
#endif
#endif // mozilla_pkix__enumclass_h