suppress more unused-variable and unused-function warnings

Jonathan,
      The attached patch eliminates most of the unused-variable and
unused-function warnings during the cmake build of openmp on
x86_64-apple-darwin14. The resulting build shows no regressions in the
OpenMP3.1_Validation test suite at -m64 or -m32.
                 Jack
ps The remaining instances fall in three main categories...

1) instances of "warning: unused variable 'temp_val'
[-Wunused-variable]" from runtime/src/kmp_atomic.c

2) instances of "warning: unused variable '__kmp_build_check_*'
[-Wunused-variable]" from runtime/src/kmp_itt.inl,
runtime/src/kmp_itt.c, runtime/src/kmp_global.c and
runtime/src/kmp_dispatch.cpp.

3) instances of "warning: unused function '__kmp_x86_pause'
[-Wunused-function]" from runtime/src/kmp.h

unused_v2.patch (29.6 KB)

Are these false warnings? I think clang should be fixed. Is there a
ticket on this?
- kmp_task_team_t * task_team = this_thr->th.th_task_team;
+ kmp_task_team_t * task_team;
+ task_team = this_thr->th.th_task_team;

I'd like to keep the c90 style instead of c99
- int f;

C,
   I see the same behavior with -Wunused-variable under FSF gcc 5.1 as
well as with clang 3.6/3.7svn. When the only usage of a variable is
its initialization during declaration, this is treated as an unused
variable by both compilers. These errors fall into the following
categories...

1) instances of truly dead code where the variable isn't used after it
is declared and initialized.

2) instances where the variable is used by macros which can be no-ops
(such as the KA_TRACE macro call when KMP_DEBUG isn't defined for
example.)

3) instances when the variable declaration is actually part of an
essential function call.

It is interesting that the third case is also the behavior under FSF
gcc 5.1 such that...

% cat warn_test.c
#include <math.h>
int main()
{
int i=log(0);
}
% gcc-fsf-5 -Wunused-variable -c warn_test.c
warn_test.c: In function ‘main’:
warn_test.c:4:5: warning: unused variable ‘i’ [-Wunused-variable]
int i=log(0);
     ^

I would also note that the rest of the
llvm/clang/compiler-rt/polly/libc++ is free of these unused variable
warnings so they must be practicing different code hygiene than
openmp.
           Jack

Are these false warnings? I think clang should be fixed. Is there a
ticket on this?
- kmp_task_team_t * task_team = this_thr->th.th_task_team;
+ kmp_task_team_t * task_team;
+ task_team = this_thr->th.th_task_team;

I'd like to keep the c90 style instead of c99
- int f;

C,
     If you search for instances of...

grep -R int * | grep for | grep " = " | grep "\+\+"

in openmp, you will find that the C99 syntax is already widely used so
this seems to be a moot point unless all those are going to be
reversed as well.
           Jack

Hmm. I'll look into that. We may be compiling the code as c++ in order
to get around that. For super legacy reasons c99 isn't supported on
some linux. (GCC claimed support, but it wasn't actually
correct/complete)