Thu, 13 Jun 2013 22:02:40 -0700
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
1.1 --- a/make/linux/makefiles/gcc.make Thu Jun 13 11:16:38 2013 -0700 1.2 +++ b/make/linux/makefiles/gcc.make Thu Jun 13 22:02:40 2013 -0700 1.3 @@ -214,7 +214,7 @@ 1.4 WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body 1.5 endif 1.6 1.7 -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function 1.8 +WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value 1.9 1.10 ifeq ($(USE_CLANG),) 1.11 # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
2.1 --- a/src/cpu/x86/vm/stubGenerator_x86_32.cpp Thu Jun 13 11:16:38 2013 -0700 2.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_32.cpp Thu Jun 13 22:02:40 2013 -0700 2.3 @@ -83,7 +83,7 @@ 2.4 private: 2.5 2.6 #ifdef PRODUCT 2.7 -#define inc_counter_np(counter) (0) 2.8 +#define inc_counter_np(counter) ((void)0) 2.9 #else 2.10 void inc_counter_np_(int& counter) { 2.11 __ incrementl(ExternalAddress((address)&counter));
3.1 --- a/src/cpu/x86/vm/stubGenerator_x86_64.cpp Thu Jun 13 11:16:38 2013 -0700 3.2 +++ b/src/cpu/x86/vm/stubGenerator_x86_64.cpp Thu Jun 13 22:02:40 2013 -0700 3.3 @@ -81,7 +81,7 @@ 3.4 private: 3.5 3.6 #ifdef PRODUCT 3.7 -#define inc_counter_np(counter) (0) 3.8 +#define inc_counter_np(counter) ((void)0) 3.9 #else 3.10 void inc_counter_np_(int& counter) { 3.11 // This can destroy rscratch1 if counter is far from the code cache
4.1 --- a/src/share/vm/c1/c1_IR.cpp Thu Jun 13 11:16:38 2013 -0700 4.2 +++ b/src/share/vm/c1/c1_IR.cpp Thu Jun 13 22:02:40 2013 -0700 4.3 @@ -506,7 +506,7 @@ 4.4 _loop_map(0, 0), // initialized later with correct size 4.5 _compilation(c) 4.6 { 4.7 - TRACE_LINEAR_SCAN(2, "***** computing linear-scan block order"); 4.8 + TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order")); 4.9 4.10 init_visited(); 4.11 count_edges(start_block, NULL); 4.12 @@ -683,7 +683,7 @@ 4.13 } 4.14 4.15 void ComputeLinearScanOrder::assign_loop_depth(BlockBegin* start_block) { 4.16 - TRACE_LINEAR_SCAN(3, "----- computing loop-depth and weight"); 4.17 + TRACE_LINEAR_SCAN(3, tty->print_cr("----- computing loop-depth and weight")); 4.18 init_visited(); 4.19 4.20 assert(_work_list.is_empty(), "work list must be empty before processing"); 4.21 @@ -868,7 +868,7 @@ 4.22 } 4.23 4.24 void ComputeLinearScanOrder::compute_order(BlockBegin* start_block) { 4.25 - TRACE_LINEAR_SCAN(3, "----- computing final block order"); 4.26 + TRACE_LINEAR_SCAN(3, tty->print_cr("----- computing final block order")); 4.27 4.28 // the start block is always the first block in the linear scan order 4.29 _linear_scan_order = new BlockList(_num_blocks);
5.1 --- a/src/share/vm/ci/ciUtilities.hpp Thu Jun 13 11:16:38 2013 -0700 5.2 +++ b/src/share/vm/ci/ciUtilities.hpp Thu Jun 13 22:02:40 2013 -0700 5.3 @@ -96,7 +96,7 @@ 5.4 CLEAR_PENDING_EXCEPTION; \ 5.5 return (result); \ 5.6 } \ 5.7 - (0 5.8 + (void)(0 5.9 5.10 #define KILL_COMPILE_ON_ANY \ 5.11 THREAD); \ 5.12 @@ -104,7 +104,7 @@ 5.13 fatal("unhandled ci exception"); \ 5.14 CLEAR_PENDING_EXCEPTION; \ 5.15 } \ 5.16 -(0 5.17 +(void)(0 5.18 5.19 5.20 inline const char* bool_to_str(bool b) {
6.1 --- a/src/share/vm/classfile/genericSignatures.cpp Thu Jun 13 11:16:38 2013 -0700 6.2 +++ b/src/share/vm/classfile/genericSignatures.cpp Thu Jun 13 22:02:40 2013 -0700 6.3 @@ -124,7 +124,7 @@ 6.4 fatal(STREAM->parse_error()); \ 6.5 } \ 6.6 return NULL; \ 6.7 - } 0 6.8 + } (void)0 6.9 6.10 #define READ() STREAM->read(); CHECK_FOR_PARSE_ERROR() 6.11 #define PEEK() STREAM->peek(); CHECK_FOR_PARSE_ERROR() 6.12 @@ -133,7 +133,7 @@ 6.13 #define EXPECTED(c, ch) STREAM->assert_char(c, ch); CHECK_FOR_PARSE_ERROR() 6.14 #define EXPECT_END() STREAM->expect_end(); CHECK_FOR_PARSE_ERROR() 6.15 6.16 -#define CHECK_STREAM STREAM); CHECK_FOR_PARSE_ERROR(); (0 6.17 +#define CHECK_STREAM STREAM); CHECK_FOR_PARSE_ERROR(); ((void)0 6.18 6.19 #ifndef PRODUCT 6.20 void Identifier::print_on(outputStream* str) const {
7.1 --- a/src/share/vm/classfile/verifier.hpp Thu Jun 13 11:16:38 2013 -0700 7.2 +++ b/src/share/vm/classfile/verifier.hpp Thu Jun 13 22:02:40 2013 -0700 7.3 @@ -86,9 +86,9 @@ 7.4 // These macros are used similarly to CHECK macros but also check 7.5 // the status of the verifier and return if that has an error. 7.6 #define CHECK_VERIFY(verifier) \ 7.7 - CHECK); if ((verifier)->has_error()) return; (0 7.8 + CHECK); if ((verifier)->has_error()) return; ((void)0 7.9 #define CHECK_VERIFY_(verifier, result) \ 7.10 - CHECK_(result)); if ((verifier)->has_error()) return (result); (0 7.11 + CHECK_(result)); if ((verifier)->has_error()) return (result); ((void)0 7.12 7.13 class TypeOrigin VALUE_OBJ_CLASS_SPEC { 7.14 private:
8.1 --- a/src/share/vm/code/dependencies.cpp Thu Jun 13 11:16:38 2013 -0700 8.2 +++ b/src/share/vm/code/dependencies.cpp Thu Jun 13 22:02:40 2013 -0700 8.3 @@ -989,7 +989,7 @@ 8.4 assert(changes.involves_context(context_type), "irrelevant dependency"); 8.5 Klass* new_type = changes.new_type(); 8.6 8.7 - count_find_witness_calls(); 8.8 + (void)count_find_witness_calls(); 8.9 NOT_PRODUCT(deps_find_witness_singles++); 8.10 8.11 // Current thread must be in VM (not native mode, as in CI):
9.1 --- a/src/share/vm/code/nmethod.cpp Thu Jun 13 11:16:38 2013 -0700 9.2 +++ b/src/share/vm/code/nmethod.cpp Thu Jun 13 22:02:40 2013 -0700 9.3 @@ -2615,7 +2615,8 @@ 9.4 relocation_begin()-1+ip[1]); 9.5 for (; ip < index_end; ip++) 9.6 tty->print_cr(" (%d ?)", ip[0]); 9.7 - tty->print_cr(" @" INTPTR_FORMAT ": index_size=%d", ip, *ip++); 9.8 + tty->print_cr(" @" INTPTR_FORMAT ": index_size=%d", ip, *ip); 9.9 + ip++; 9.10 tty->print_cr("reloc_end @" INTPTR_FORMAT ":", ip); 9.11 } 9.12 }
10.1 --- a/src/share/vm/memory/cardTableModRefBS.cpp Thu Jun 13 11:16:38 2013 -0700 10.2 +++ b/src/share/vm/memory/cardTableModRefBS.cpp Thu Jun 13 22:02:40 2013 -0700 10.3 @@ -412,7 +412,7 @@ 10.4 } 10.5 // Touch the last card of the covered region to show that it 10.6 // is committed (or SEGV). 10.7 - debug_only(*byte_for(_covered[ind].last());) 10.8 + debug_only((void) (*byte_for(_covered[ind].last()));) 10.9 debug_only(verify_guard();) 10.10 } 10.11
11.1 --- a/src/share/vm/memory/universe.cpp Thu Jun 13 11:16:38 2013 -0700 11.2 +++ b/src/share/vm/memory/universe.cpp Thu Jun 13 22:02:40 2013 -0700 11.3 @@ -529,7 +529,9 @@ 11.4 if (vt) vt->initialize_vtable(false, CHECK); 11.5 if (ko->oop_is_instance()) { 11.6 InstanceKlass* ik = (InstanceKlass*)ko; 11.7 - for (KlassHandle s_h(THREAD, ik->subklass()); s_h() != NULL; s_h = (THREAD, s_h()->next_sibling())) { 11.8 + for (KlassHandle s_h(THREAD, ik->subklass()); 11.9 + s_h() != NULL; 11.10 + s_h = KlassHandle(THREAD, s_h()->next_sibling())) { 11.11 reinitialize_vtable_of(s_h, CHECK); 11.12 } 11.13 }
12.1 --- a/src/share/vm/opto/memnode.cpp Thu Jun 13 11:16:38 2013 -0700 12.2 +++ b/src/share/vm/opto/memnode.cpp Thu Jun 13 22:02:40 2013 -0700 12.3 @@ -4384,7 +4384,7 @@ 12.4 } 12.5 } 12.6 #else // !ASSERT 12.7 -#define verify_memory_slice(m,i,n) (0) // PRODUCT version is no-op 12.8 +#define verify_memory_slice(m,i,n) (void)(0) // PRODUCT version is no-op 12.9 #endif 12.10 12.11
13.1 --- a/src/share/vm/prims/forte.cpp Thu Jun 13 11:16:38 2013 -0700 13.2 +++ b/src/share/vm/prims/forte.cpp Thu Jun 13 22:02:40 2013 -0700 13.3 @@ -619,7 +619,7 @@ 13.4 void* null_argument_3); 13.5 #pragma weak collector_func_load 13.6 #define collector_func_load(x0,x1,x2,x3,x4,x5,x6) \ 13.7 - ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),0 : 0 ) 13.8 + ( collector_func_load ? collector_func_load(x0,x1,x2,x3,x4,x5,x6),(void)0 : (void)0 ) 13.9 #endif // __APPLE__ 13.10 #endif // !_WINDOWS 13.11
14.1 --- a/src/share/vm/runtime/sharedRuntime.cpp Thu Jun 13 11:16:38 2013 -0700 14.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp Thu Jun 13 22:02:40 2013 -0700 14.3 @@ -2731,7 +2731,7 @@ 14.4 // ResourceObject, so do not put any ResourceMarks in here. 14.5 char *s = sig->as_C_string(); 14.6 int len = (int)strlen(s); 14.7 - *s++; len--; // Skip opening paren 14.8 + s++; len--; // Skip opening paren 14.9 char *t = s+len; 14.10 while( *(--t) != ')' ) ; // Find close paren 14.11
15.1 --- a/src/share/vm/services/diagnosticArgument.cpp Thu Jun 13 11:16:38 2013 -0700 15.2 +++ b/src/share/vm/services/diagnosticArgument.cpp Thu Jun 13 22:02:40 2013 -0700 15.3 @@ -247,7 +247,7 @@ 15.4 } else { 15.5 _value._time = 0; 15.6 _value._nanotime = 0; 15.7 - strcmp(_value._unit, "ns"); 15.8 + strcpy(_value._unit, "ns"); 15.9 } 15.10 } 15.11
16.1 --- a/src/share/vm/utilities/exceptions.hpp Thu Jun 13 11:16:38 2013 -0700 16.2 +++ b/src/share/vm/utilities/exceptions.hpp Thu Jun 13 22:02:40 2013 -0700 16.3 @@ -194,15 +194,15 @@ 16.4 #define HAS_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->has_pending_exception()) 16.5 #define CLEAR_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->clear_pending_exception()) 16.6 16.7 -#define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (0 16.8 -#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (0 16.9 +#define CHECK THREAD); if (HAS_PENDING_EXCEPTION) return ; (void)(0 16.10 +#define CHECK_(result) THREAD); if (HAS_PENDING_EXCEPTION) return result; (void)(0 16.11 #define CHECK_0 CHECK_(0) 16.12 #define CHECK_NH CHECK_(Handle()) 16.13 #define CHECK_NULL CHECK_(NULL) 16.14 #define CHECK_false CHECK_(false) 16.15 16.16 -#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (0 16.17 -#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (0 16.18 +#define CHECK_AND_CLEAR THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return; } (void)(0 16.19 +#define CHECK_AND_CLEAR_(result) THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return result; } (void)(0 16.20 #define CHECK_AND_CLEAR_0 CHECK_AND_CLEAR_(0) 16.21 #define CHECK_AND_CLEAR_NH CHECK_AND_CLEAR_(Handle()) 16.22 #define CHECK_AND_CLEAR_NULL CHECK_AND_CLEAR_(NULL) 16.23 @@ -282,7 +282,7 @@ 16.24 CLEAR_PENDING_EXCEPTION; \ 16.25 ex->print(); \ 16.26 ShouldNotReachHere(); \ 16.27 - } (0 16.28 + } (void)(0 16.29 16.30 // ExceptionMark is a stack-allocated helper class for local exception handling. 16.31 // It is used with the EXCEPTION_MARK macro.
17.1 --- a/src/share/vm/utilities/taskqueue.hpp Thu Jun 13 11:16:38 2013 -0700 17.2 +++ b/src/share/vm/utilities/taskqueue.hpp Thu Jun 13 22:02:40 2013 -0700 17.3 @@ -340,8 +340,12 @@ 17.4 if (dirty_n_elems == N - 1) { 17.5 // Actually means 0, so do the push. 17.6 uint localBot = _bottom; 17.7 - // g++ complains if the volatile result of the assignment is unused. 17.8 - const_cast<E&>(_elems[localBot] = t); 17.9 + // g++ complains if the volatile result of the assignment is 17.10 + // unused, so we cast the volatile away. We cannot cast directly 17.11 + // to void, because gcc treats that as not using the result of the 17.12 + // assignment. However, casting to E& means that we trigger an 17.13 + // unused-value warning. So, we cast the E& to void. 17.14 + (void)const_cast<E&>(_elems[localBot] = t); 17.15 OrderAccess::release_store(&_bottom, increment_index(localBot)); 17.16 TASKQUEUE_STATS_ONLY(stats.record_push()); 17.17 return true; 17.18 @@ -397,7 +401,12 @@ 17.19 return false; 17.20 } 17.21 17.22 - const_cast<E&>(t = _elems[oldAge.top()]); 17.23 + // g++ complains if the volatile result of the assignment is 17.24 + // unused, so we cast the volatile away. We cannot cast directly 17.25 + // to void, because gcc treats that as not using the result of the 17.26 + // assignment. However, casting to E& means that we trigger an 17.27 + // unused-value warning. So, we cast the E& to void. 17.28 + (void) const_cast<E&>(t = _elems[oldAge.top()]); 17.29 Age newAge(oldAge); 17.30 newAge.increment(); 17.31 Age resAge = _age.cmpxchg(newAge, oldAge); 17.32 @@ -640,8 +649,12 @@ 17.33 uint dirty_n_elems = dirty_size(localBot, top); 17.34 assert(dirty_n_elems < N, "n_elems out of range."); 17.35 if (dirty_n_elems < max_elems()) { 17.36 - // g++ complains if the volatile result of the assignment is unused. 17.37 - const_cast<E&>(_elems[localBot] = t); 17.38 + // g++ complains if the volatile result of the assignment is 17.39 + // unused, so we cast the volatile away. We cannot cast directly 17.40 + // to void, because gcc treats that as not using the result of the 17.41 + // assignment. However, casting to E& means that we trigger an 17.42 + // unused-value warning. So, we cast the E& to void. 17.43 + (void) const_cast<E&>(_elems[localBot] = t); 17.44 OrderAccess::release_store(&_bottom, increment_index(localBot)); 17.45 TASKQUEUE_STATS_ONLY(stats.record_push()); 17.46 return true; 17.47 @@ -665,7 +678,12 @@ 17.48 // This is necessary to prevent any read below from being reordered 17.49 // before the store just above. 17.50 OrderAccess::fence(); 17.51 - const_cast<E&>(t = _elems[localBot]); 17.52 + // g++ complains if the volatile result of the assignment is 17.53 + // unused, so we cast the volatile away. We cannot cast directly 17.54 + // to void, because gcc treats that as not using the result of the 17.55 + // assignment. However, casting to E& means that we trigger an 17.56 + // unused-value warning. So, we cast the E& to void. 17.57 + (void) const_cast<E&>(t = _elems[localBot]); 17.58 // This is a second read of "age"; the "size()" above is the first. 17.59 // If there's still at least one element in the queue, based on the 17.60 // "_bottom" and "age" we've read, then there can be no interference with