[flang] [OpenMP] add structural checks for `TASKLOOP SIMD`

Original-commit: flang-compiler/f18@21b4dde276
This commit is contained in:
Jinxin Yang 2019-09-05 09:33:23 -07:00 committed by Jinxin (Brian) Yang
parent d1bbccf1d5
commit 5c543da53a
2 changed files with 50 additions and 0 deletions

View File

@ -260,6 +260,23 @@ void OmpStructureChecker::Enter(const parser::OpenMPLoopConstruct &x) {
SetContextAllowedExclusive(allowedExclusive);
} break;
// 2.9.3 taskloop-simd-clause -> taskloop-clause |
// simd-clause
case parser::OmpLoopDirective::Directive::TaskloopSimd: {
PushContext(beginDir.source, OmpDirective::TASKLOOP_SIMD);
OmpClauseSet allowed{OmpClause::LINEAR, OmpClause::ALIGNED,
OmpClause::SHARED, OmpClause::PRIVATE, OmpClause::FIRSTPRIVATE,
OmpClause::LASTPRIVATE, OmpClause::DEFAULT, OmpClause::UNTIED,
OmpClause::MERGEABLE, OmpClause::NOGROUP};
SetContextAllowed(allowed);
OmpClauseSet allowedOnce{OmpClause::COLLAPSE, OmpClause::SAFELEN,
OmpClause::SIMDLEN, OmpClause::IF, OmpClause::FINAL,
OmpClause::PRIORITY};
SetContextAllowedOnce(allowedOnce);
OmpClauseSet allowedExclusive{OmpClause::GRAINSIZE, OmpClause::NUM_TASKS};
SetContextAllowedExclusive(allowedExclusive);
} break;
default:
// TODO others
break;
@ -775,6 +792,7 @@ void OmpStructureChecker::Enter(const parser::OmpDefaultClause &) {
void OmpStructureChecker::Enter(const parser::OmpDependClause &) {
CheckAllowed(OmpClause::DEPEND);
}
void OmpStructureChecker::Enter(const parser::OmpIfClause &x) {
CheckAllowed(OmpClause::IF);
@ -803,6 +821,7 @@ void OmpStructureChecker::Enter(const parser::OmpIfClause &x) {
}
}
}
void OmpStructureChecker::Enter(const parser::OmpLinearClause &x) {
CheckAllowed(OmpClause::LINEAR);

View File

@ -429,4 +429,35 @@
!$omp task priority(-1) firstprivate(a) mergeable
a = 3.14
!$omp end task
! 2.9.3 taskloop-simd-clause -> taskloop-clause |
! simd-clause
!$omp taskloop simd
do i = 1, N
a = 3.14
enddo
!$omp end taskloop simd
!ERROR: REDUCTION clause is not allowed on the TASKLOOP SIMD directive
!$omp taskloop simd reduction(+:a)
do i = 1, N
a = a + 3.14
enddo
!ERROR: Unmatched END TASKLOOP directive
!$omp end taskloop
!ERROR: GRAINSIZE and NUM_TASKS are mutually exclusive and may not appear on the same TASKLOOP SIMD directive
!$omp taskloop simd num_tasks(3) grainsize(2)
do i = 1,N
a = 3.14
enddo
!ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression
!ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression
!ERROR: Internal: no symbol found for 'a'
!$omp taskloop simd simdlen(-1) aligned(a:-2)
do i = 1, N
a = 3.14
enddo
end program