public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104913] New: [OpenMP] Bogus 'unused variable' with 'omp depobj'
@ 2022-03-14 11:23 burnus at gcc dot gnu.org
  2022-03-14 12:41 ` [Bug c/104913] " jakub at gcc dot gnu.org
  2022-03-14 13:33 ` jakub at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-03-14 11:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104913

            Bug ID: 104913
           Summary: [OpenMP] Bogus 'unused variable' with 'omp depobj'
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic, openmp
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

The following C code shows the warning

foo.c:6:7: warning: unused variable ‘x’ [-Wunused-variable]
    6 |   int x;
      |       ^

but the variable is used in 'depend(inout: x)'.

(No warning for the Fortran code, which is fine. Found when looking at
https://github.com/SOLLVE/sollve_vv/pull/493 which then uses obj with
omp_target_memcpy_async.)


-----------------------
#include <omp.h>

void
foo ()
{
  int x;
  omp_depend_t obj;
  #pragma omp depobj(obj) depend(inout: x)
}
-----------------------
subroutine foo
  use omp_lib
  implicit none
  integer :: x
  integer(omp_depend_kind) obj
  !$omp depobj(obj) depend(inout: x)
end

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/104913] [OpenMP] Bogus 'unused variable' with 'omp depobj'
  2022-03-14 11:23 [Bug c/104913] New: [OpenMP] Bogus 'unused variable' with 'omp depobj' burnus at gcc dot gnu.org
@ 2022-03-14 12:41 ` jakub at gcc dot gnu.org
  2022-03-14 13:33 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-14 12:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104913

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
That isn't depobj related but depend clause related:
void
foo ()
{
  int x;
  #pragma omp task depend(inout: x)
  ;
}

warns as well.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/104913] [OpenMP] Bogus 'unused variable' with 'omp depobj'
  2022-03-14 11:23 [Bug c/104913] New: [OpenMP] Bogus 'unused variable' with 'omp depobj' burnus at gcc dot gnu.org
  2022-03-14 12:41 ` [Bug c/104913] " jakub at gcc dot gnu.org
@ 2022-03-14 13:33 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-03-14 13:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104913

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
We also warn e.g. in
void
foo ()
{
  int x;
  #pragma omp task firstprivate(x)
  ;
}
case.
To some extent at least for data sharing and most other OpenMP clauses the data
sharing isn't really a kind of use, the variable there is still unused.
depend clause is a border line, it also isn't either setter nor use and such
use is questionable, on the other side under the hood it is taking the address
of the variable and using that for the dependency purposes, so it is some kind
of a light use.
On the other side, e.g. the C FE build_external_ref function handles various
other tasks, like -Wdeprecated or setting DECL_NONLOCAL, so perhaps we want to
do it for all OpenMP clauses somewhere.  Similarly, C++ mark_used can even
instantiate stuff etc.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-14 13:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 11:23 [Bug c/104913] New: [OpenMP] Bogus 'unused variable' with 'omp depobj' burnus at gcc dot gnu.org
2022-03-14 12:41 ` [Bug c/104913] " jakub at gcc dot gnu.org
2022-03-14 13:33 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).