[Openmp-dev] suppress more unused-variable and unused-function warnings

Jack Howarth howarth.mailing.lists at gmail.com
Sun Jun 7 13:13:54 PDT 2015


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

On Sun, Jun 7, 2015 at 3:21 PM, C Bergström <cbergstrom at pathscale.com> wrote:
> 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;
>
>
> On Mon, Jun 8, 2015 at 12:22 AM, Jack Howarth
> <howarth.mailing.lists at gmail.com> wrote:
>> 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
>>
>> _______________________________________________
>> Openmp-dev mailing list
>> Openmp-dev at dcs-maillist2.engr.illinois.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/openmp-dev
>>




More information about the Openmp-dev mailing list