As reported in https://bugs.llvm.org/show_bug.cgi?id=48145, name resolution for omp critical construct was failing. This patch adds functionality to help that name resolution as well as implementation to catch name mismatches. The following semantic restrictions are therefore handled here: - If a name is specified on a critical directive, the same name must also be specified on the end critical directive - If no name appears on the critical directive, no name can appear on the end critical directive - If a name appears on either the start critical directive or the end critical directive Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D110502
54 lines
1.5 KiB
Fortran
54 lines
1.5 KiB
Fortran
! RUN: %python %S/test_errors.py %s %flang -fopenmp
|
|
|
|
! OpenMP Version 5.0
|
|
! 2.17.1 critical construct
|
|
! If the hint clause is specified, the critical construct must have a name.
|
|
program sample
|
|
use omp_lib
|
|
integer i, j
|
|
!ERROR: Hint clause other than omp_sync_hint_none cannot be specified for an unnamed CRITICAL directive
|
|
!$omp critical hint(omp_lock_hint_speculative)
|
|
j = j + 1
|
|
!$omp end critical
|
|
|
|
!$omp critical (foo) hint(omp_lock_hint_speculative)
|
|
i = i - 1
|
|
!$omp end critical (foo)
|
|
|
|
!ERROR: Hint clause other than omp_sync_hint_none cannot be specified for an unnamed CRITICAL directive
|
|
!$omp critical hint(omp_lock_hint_nonspeculative)
|
|
j = j + 1
|
|
!$omp end critical
|
|
|
|
!$omp critical (foo) hint(omp_lock_hint_nonspeculative)
|
|
i = i - 1
|
|
!$omp end critical (foo)
|
|
|
|
!ERROR: Hint clause other than omp_sync_hint_none cannot be specified for an unnamed CRITICAL directive
|
|
!$omp critical hint(omp_lock_hint_contended)
|
|
j = j + 1
|
|
!$omp end critical
|
|
|
|
!$omp critical (foo) hint(omp_lock_hint_contended)
|
|
i = i - 1
|
|
!$omp end critical (foo)
|
|
|
|
!ERROR: Hint clause other than omp_sync_hint_none cannot be specified for an unnamed CRITICAL directive
|
|
!$omp critical hint(omp_lock_hint_uncontended)
|
|
j = j + 1
|
|
!$omp end critical
|
|
|
|
!$omp critical (foo) hint(omp_lock_hint_uncontended)
|
|
i = i - 1
|
|
!$omp end critical (foo)
|
|
|
|
!$omp critical hint(omp_sync_hint_none)
|
|
j = j + 1
|
|
!$omp end critical
|
|
|
|
!$omp critical (foo) hint(omp_sync_hint_none)
|
|
i = i - 1
|
|
!$omp end critical (foo)
|
|
|
|
end program sample
|