Revision: 24344
Author:   svenpa...@chromium.org
Date:     Wed Oct  1 06:32:05 2014 UTC
Log: Changes to ALLOW_UNUSED to match upcoming changes to the Chromium trunk:
* Eliminate usage of ALLOW_UNUSED to define COMPILE_ASSERT and just use
  static_assert() in all cases now that all platforms build with C++11.
* Convert remaining uses of ALLOW_UNUSED to ALLOW_UNUSED_TYPE to match how
Chromium will be splitting this functionality. (In Chromium we'll have both
  ALLOW_UNUSED_TYPE and ALLOW_UNUSED_LOCAL, which have different syntax to
  enable us to use these with MSVC.)

BUG=chromium:81439
TEST=none
LOG=y
R=svenpa...@chromium.org

Review URL: https://codereview.chromium.org/613143004

Patch from Peter Kasting <pkast...@chromium.org>.
https://code.google.com/p/v8/source/detail?r=24344

Modified:
 /branches/bleeding_edge/src/base/compiler-specific.h
 /branches/bleeding_edge/src/base/flags.h
 /branches/bleeding_edge/src/base/macros.h

=======================================
--- /branches/bleeding_edge/src/base/compiler-specific.h Tue Sep 2 07:07:52 2014 UTC +++ /branches/bleeding_edge/src/base/compiler-specific.h Wed Oct 1 06:32:05 2014 UTC
@@ -7,15 +7,13 @@

 #include "include/v8config.h"

-// Annotate a variable indicating it's ok if the variable is not used.
-// (Typically used to silence a compiler warning when the assignment
-// is important for some other reason.)
+// Annotate a typedef or function indicating it's ok if it's not used.
 // Use like:
-//   int x ALLOW_UNUSED = ...;
+//   typedef Foo Bar ALLOW_UNUSED_TYPE;
 #if V8_HAS_ATTRIBUTE_UNUSED
-#define ALLOW_UNUSED __attribute__((unused))
+#define ALLOW_UNUSED_TYPE __attribute__((unused))
 #else
-#define ALLOW_UNUSED
+#define ALLOW_UNUSED_TYPE
 #endif


=======================================
--- /branches/bleeding_edge/src/base/flags.h    Tue Sep  2 11:36:55 2014 UTC
+++ /branches/bleeding_edge/src/base/flags.h    Wed Oct  1 06:32:05 2014 UTC
@@ -64,42 +64,44 @@
 };


-#define DEFINE_OPERATORS_FOR_FLAGS(Type) \ - inline Type operator&(Type::flag_type lhs, \ - Type::flag_type rhs)ALLOW_UNUSED WARN_UNUSED_RESULT; \ - inline Type operator&(Type::flag_type lhs, Type::flag_type rhs) { \ - return Type(lhs) & rhs; \ - } \ - inline Type operator&(Type::flag_type lhs, \ - const Type& rhs)ALLOW_UNUSED WARN_UNUSED_RESULT; \ - inline Type operator&(Type::flag_type lhs, const Type& rhs) { \ - return rhs & lhs; \ - } \ - inline void operator&(Type::flag_type lhs, Type::mask_type rhs)ALLOW_UNUSED; \ - inline void operator&(Type::flag_type lhs, Type::mask_type rhs) {} \ - inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) \ - ALLOW_UNUSED WARN_UNUSED_RESULT; \ - inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) { \ - return Type(lhs) | rhs; \ - } \ - inline Type operator|(Type::flag_type lhs, const Type& rhs) \ - ALLOW_UNUSED WARN_UNUSED_RESULT; \ - inline Type operator|(Type::flag_type lhs, const Type& rhs) { \ - return rhs | lhs; \ - } \ - inline void operator|(Type::flag_type lhs, Type::mask_type rhs) \ - ALLOW_UNUSED; \ - inline void operator|(Type::flag_type lhs, Type::mask_type rhs) {} \ - inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) \ - ALLOW_UNUSED WARN_UNUSED_RESULT; \ - inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) { \ - return Type(lhs) ^ rhs; \ - } inline Type operator^(Type::flag_type lhs, const Type& rhs) \ - ALLOW_UNUSED WARN_UNUSED_RESULT; \ - inline Type operator^(Type::flag_type lhs, const Type& rhs) { \ - return rhs ^ lhs; \ - } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \ - ALLOW_UNUSED; \ +#define DEFINE_OPERATORS_FOR_FLAGS(Type) \ + inline Type operator&( \ + Type::flag_type lhs, \ + Type::flag_type rhs)ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \ + inline Type operator&(Type::flag_type lhs, Type::flag_type rhs) { \ + return Type(lhs) & rhs; \ + } \ + inline Type operator&(Type::flag_type lhs, \ + const Type& rhs)ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \ + inline Type operator&(Type::flag_type lhs, const Type& rhs) { \ + return rhs & lhs; \ + } \ + inline void operator&(Type::flag_type lhs, \ + Type::mask_type rhs)ALLOW_UNUSED_TYPE; \ + inline void operator&(Type::flag_type lhs, Type::mask_type rhs) {} \ + inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) \ + ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \ + inline Type operator|(Type::flag_type lhs, Type::flag_type rhs) { \ + return Type(lhs) | rhs; \ + } \ + inline Type operator|(Type::flag_type lhs, const Type& rhs) \ + ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \ + inline Type operator|(Type::flag_type lhs, const Type& rhs) { \ + return rhs | lhs; \ + } \ + inline void operator|(Type::flag_type lhs, Type::mask_type rhs) \ + ALLOW_UNUSED_TYPE; \ + inline void operator|(Type::flag_type lhs, Type::mask_type rhs) {} \ + inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) \ + ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \ + inline Type operator^(Type::flag_type lhs, Type::flag_type rhs) { \ + return Type(lhs) ^ rhs; \ + } inline Type operator^(Type::flag_type lhs, const Type& rhs) \ + ALLOW_UNUSED_TYPE WARN_UNUSED_RESULT; \ + inline Type operator^(Type::flag_type lhs, const Type& rhs) { \ + return rhs ^ lhs; \ + } inline void operator^(Type::flag_type lhs, Type::mask_type rhs) \ + ALLOW_UNUSED_TYPE; \
   inline void operator^(Type::flag_type lhs, Type::mask_type rhs) {}

 }  // namespace base
=======================================
--- /branches/bleeding_edge/src/base/macros.h   Tue Sep 23 06:30:15 2014 UTC
+++ /branches/bleeding_edge/src/base/macros.h   Wed Oct  1 06:32:05 2014 UTC
@@ -130,7 +130,7 @@

 #define COMPILE_ASSERT(expr, msg)                \
   typedef CompileAssert<static_cast<bool>(expr)> \
-      msg[static_cast<bool>(expr) ? 1 : -1] ALLOW_UNUSED
+      msg[static_cast<bool>(expr) ? 1 : -1] ALLOW_UNUSED_TYPE

 // Implementation details of COMPILE_ASSERT:
 //
@@ -150,23 +150,11 @@
 //     COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is
 //                               // not a compile-time constant.
 //
-// - By using the type CompileAssert<(bool(expr))>, we ensures that
+// - By using the type CompileAssert<static_cast<bool>(expr)>, we ensure that
 //   expr is a compile-time constant.  (Template arguments must be
 //   determined at compile-time.)
 //
-// - The outer parentheses in CompileAssert<(bool(expr))> are necessary
-//   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written
-//
-//     CompileAssert<bool(expr)>
-//
-//   instead, these compilers will refuse to compile
-//
-//     COMPILE_ASSERT(5 > 0, some_message);
-//
-//   (They seem to think the ">" in "5 > 0" marks the end of the
-//   template argument list.)
-//
-// - The array size is (bool(expr) ? 1 : -1), instead of simply
+// - The array size is (static_cast<bool>(expr) ? 1 : -1), instead of simply
 //
 //     ((expr) ? 1 : -1).
 //
@@ -308,10 +296,10 @@
 // actually causes each use to introduce a new defined type with a
 // name depending on the source line.
 template <int> class StaticAssertionHelper { };
-#define STATIC_ASSERT(test) \ - typedef \ - StaticAssertionHelper<sizeof(StaticAssertion<static_cast<bool>((test))>)> \
-    SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) ALLOW_UNUSED
+#define STATIC_ASSERT(test)                               \
+  typedef StaticAssertionHelper<                          \
+      sizeof(StaticAssertion<static_cast<bool>((test))>)> \
+      SEMI_STATIC_JOIN(__StaticAssertTypedef__, __LINE__) ALLOW_UNUSED_TYPE

 #endif

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to