https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118690
Bug ID: 118690
Summary: [OpenMP] declare_variant - multiple use for same
procedure not diagnosed
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: accepts-invalid, openmp
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The following cases are accepted but shouldn't:
! (A) Self reference:
subroutine sub()
!$omp declare variant(sub) match(user={condition(.true.)})
end
! (B) having the multiple 'declare variant' in the same scope
!
! → this is accepted to for C for '#include <header_file.h>'
! following by identical version
! the same selector par is checked for in omp_mark_declare_variant
subroutine var1(); end
subroutine b1()
!$omp declare variant(var1) match(user={condition(.true.)})
!$omp declare variant(var1) match(user={condition(.true.)})
end
! (C) Same issue
subroutine var2(); end
subroutine b2(x)
use iso_c_binding
type(c_ptr) :: x
!$omp declare variant(var2) match(construct={dispatch}) &
!$omp& adjust_args(need_device_ptr: x)
!$omp declare variant(var2) match(construct={dispatch}) &
!$omp& adjust_args(need_device_ptr: x)
! ---OR--- nothing : x
end
! (D) Same as (B), but differently written - might not yet be accepted
! syntax wise:
subroutine var3(); end
subroutine bar()
interface
subroutine b3()
!$omp declare variant(var2) match(user={condition(.true.)})
end
end interface
!$omp declare variant(b2 : var2) match(user={condition(.true.)})
end
! (E) The following is also wrong - similar code required to
! omp_mark_declare_variant - or extend it?
! i.e. check both adjust_args and append_args.
!
! [not quite sure whether it can occur for Fortran or not.]
void f(int *);
#pragma omp declare variant(f) adjust_args(nothing: x) \
match(construct={dispatch})
void g(int *x);
// …
#pragma omp declare variant(f) adjust_args(need_device_ptr: x) \
match(construct={dispatch})
void g(int *x)
{ /* … */ }