aboutsummaryrefslogtreecommitdiff
path: root/src/share/vm/utilities
diff options
context:
space:
mode:
authorccheung <none@none>2013-06-13 22:02:40 -0700
committerccheung <none@none>2013-06-13 22:02:40 -0700
commiteba421f02c2dd3424e1e3c98206f32b201b02b98 (patch)
tree64d0c45323b3b438ec07fb0be2584274203f8cfb /src/share/vm/utilities
parent84ea44a8f5cbdf0a4a4db87dfbac508be78c535b (diff)
8014431: cleanup warnings indicated by the -Wunused-value compiler option on linux
Reviewed-by: dholmes, coleenp Contributed-by: jeremymanson@google.com, calvin.cheung@oracle.com
Diffstat (limited to 'src/share/vm/utilities')
-rw-r--r--src/share/vm/utilities/exceptions.hpp10
-rw-r--r--src/share/vm/utilities/taskqueue.hpp30
2 files changed, 29 insertions, 11 deletions
diff --git a/src/share/vm/utilities/exceptions.hpp b/src/share/vm/utilities/exceptions.hpp
index 089cd3e08..32c6f35d8 100644
--- a/src/share/vm/utilities/exceptions.hpp
+++ b/src/share/vm/utilities/exceptions.hpp
@@ -194,15 +194,15 @@ class Exceptions {
#define HAS_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->has_pending_exception())
#define CLEAR_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_exception())
-#define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (0
-#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (0
+#define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (void)(0
+#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (void)(0
#define CHECK_0 CHECK_(0)
#define CHECK_NH CHECK_(Handle())
#define CHECK_NULL CHECK_(NULL)
#define CHECK_false CHECK_(false)
-#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (0
-#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (0
+#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (void)(0
+#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0
#define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0)
#define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle())
#define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL)
@@ -282,7 +282,7 @@ class Exceptions {
CLEAR_PENDING_EXCEPTION; \
ex->print(); \
ShouldNotReachHere(); \
- } (0
+ } (void)(0
// ExceptionMark is a stack-allocated helper class for local exception handling.
// It is used with the EXCEPTION_MARK macro.
diff --git a/src/share/vm/utilities/taskqueue.hpp b/src/share/vm/utilities/taskqueue.hpp
index 980b7e973..aea96c858 100644
--- a/src/share/vm/utilities/taskqueue.hpp
+++ b/src/share/vm/utilities/taskqueue.hpp
@@ -340,8 +340,12 @@ bool GenericTaskQueue<E, F, N>::push_slow(E t, uint dirty_n_elems) {
if (dirty_n_elems == N - 1) {
// Actually means 0, so do the push.
uint localBot = _bottom;
- // g++ complains if the volatile result of the assignment is unused.
- const_cast<E&>(_elems[localBot] = t);
+ // g++ complains if the volatile result of the assignment is
+ // unused, so we cast the volatile away. We cannot cast directly
+ // to void, because gcc treats that as not using the result of the
+ // assignment. However, casting to E& means that we trigger an
+ // unused-value warning. So, we cast the E& to void.
+ (void)const_cast<E&>(_elems[localBot] = t);
OrderAccess::release_store(&_bottom, increment_index(localBot));
TASKQUEUE_STATS_ONLY(stats.record_push());
return true;
@@ -397,7 +401,12 @@ bool GenericTaskQueue<E, F, N>::pop_global(E& t) {
return false;
}
- const_cast<E&>(t = _elems[oldAge.top()]);
+ // g++ complains if the volatile result of the assignment is
+ // unused, so we cast the volatile away. We cannot cast directly
+ // to void, because gcc treats that as not using the result of the
+ // assignment. However, casting to E& means that we trigger an
+ // unused-value warning. So, we cast the E& to void.
+ (void) const_cast<E&>(t = _elems[oldAge.top()]);
Age newAge(oldAge);
newAge.increment();
Age resAge = _age.cmpxchg(newAge, oldAge);
@@ -640,8 +649,12 @@ GenericTaskQueue<E, F, N>::push(E t) {
uint dirty_n_elems = dirty_size(localBot, top);
assert(dirty_n_elems < N, "n_elems out of range.");
if (dirty_n_elems < max_elems()) {
- // g++ complains if the volatile result of the assignment is unused.
- const_cast<E&>(_elems[localBot] = t);
+ // g++ complains if the volatile result of the assignment is
+ // unused, so we cast the volatile away. We cannot cast directly
+ // to void, because gcc treats that as not using the result of the
+ // assignment. However, casting to E& means that we trigger an
+ // unused-value warning. So, we cast the E& to void.
+ (void) const_cast<E&>(_elems[localBot] = t);
OrderAccess::release_store(&_bottom, increment_index(localBot));
TASKQUEUE_STATS_ONLY(stats.record_push());
return true;
@@ -665,7 +678,12 @@ GenericTaskQueue<E, F, N>::pop_local(E& t) {
// This is necessary to prevent any read below from being reordered
// before the store just above.
OrderAccess::fence();
- const_cast<E&>(t = _elems[localBot]);
+ // g++ complains if the volatile result of the assignment is
+ // unused, so we cast the volatile away. We cannot cast directly
+ // to void, because gcc treats that as not using the result of the
+ // assignment. However, casting to E& means that we trigger an
+ // unused-value warning. So, we cast the E& to void.
+ (void) const_cast<E&>(t = _elems[localBot]);
// This is a second read of "age"; the "size()" above is the first.
// If there's still at least one element in the queue, based on the
// "_bottom" and "age" we've read, then there can be no interference with