Fix error messages.
This commit is contained in:
parent
4442fced82
commit
029719370c
@ -143,7 +143,7 @@ private:
|
||||
|
||||
// 'OmpWorkdistributeBlockChecker' is used to check the validity of the
|
||||
// assignment statements and the expressions enclosed in an OpenMP
|
||||
// workdistribute construct
|
||||
// WORKDISTRIBUTE construct
|
||||
class OmpWorkdistributeBlockChecker {
|
||||
public:
|
||||
OmpWorkdistributeBlockChecker(
|
||||
@ -163,8 +163,7 @@ public:
|
||||
lhs->GetType(), lhs->Rank(), rhs->GetType(), rhs->Rank())};
|
||||
if (isDefined == Tristate::Yes) {
|
||||
context_.Say(expr.source,
|
||||
"Defined assignment statement is not "
|
||||
"allowed in a WORKDISTRIBUTE construct"_err_en_US);
|
||||
"Defined assignment statement is not allowed in a WORKDISTRIBUTE construct"_err_en_US);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -172,25 +171,23 @@ public:
|
||||
|
||||
bool Pre(const parser::Expr &expr) {
|
||||
if (const auto *e{GetExpr(context_, expr)}) {
|
||||
if (!e)
|
||||
return false;
|
||||
for (const Symbol &symbol : evaluate::CollectSymbols(*e)) {
|
||||
const Symbol &root{GetAssociationRoot(symbol)};
|
||||
if (IsFunction(root)) {
|
||||
std::string attrs{""};
|
||||
std::vector<std::string> attrs;
|
||||
if (!IsElementalProcedure(root)) {
|
||||
attrs = " non-ELEMENTAL";
|
||||
attrs.push_back("non-ELEMENTAL");
|
||||
}
|
||||
if (root.attrs().test(Attr::IMPURE)) {
|
||||
if (attrs != "") {
|
||||
attrs = "," + attrs;
|
||||
}
|
||||
attrs = " IMPURE" + attrs;
|
||||
}
|
||||
if (attrs != "") {
|
||||
context_.Say(expr.source,
|
||||
"User defined%s function '%s' is not allowed in a "
|
||||
"WORKDISTRIBUTE construct"_err_en_US,
|
||||
attrs, root.name());
|
||||
attrs.push_back("IMPURE");
|
||||
}
|
||||
std::string attrsStr =
|
||||
attrs.empty() ? "" : " " + llvm::join(attrs, ", ");
|
||||
context_.Say(expr.source,
|
||||
"User defined%s function '%s' is not allowed in a WORKDISTRIBUTE construct"_err_en_US,
|
||||
attrsStr, root.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -877,8 +874,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPBlockConstruct &x) {
|
||||
if (GetContext().directive == llvm::omp::Directive::OMPD_workdistribute &&
|
||||
GetContextParent().directive != llvm::omp::Directive::OMPD_teams) {
|
||||
context_.Say(x.BeginDir().DirName().source,
|
||||
"%s region can only be strictly nested within the "
|
||||
"teams region"_err_en_US,
|
||||
"%s region can only be strictly nested within TEAMS region"_err_en_US,
|
||||
ContextDirectiveAsFortran());
|
||||
}
|
||||
}
|
||||
@ -967,7 +963,7 @@ void OmpStructureChecker::Enter(const parser::OpenMPBlockConstruct &x) {
|
||||
case llvm::omp::OMPD_workdistribute:
|
||||
if (!CurrentDirectiveIsNested()) {
|
||||
context_.Say(beginSpec.source,
|
||||
"A workdistribute region must be nested inside teams region only."_err_en_US);
|
||||
"A WORKDISTRIBUTE region must be nested inside TEAMS region only."_err_en_US);
|
||||
}
|
||||
CheckWorkdistributeBlockStmts(block, beginSpec.source);
|
||||
break;
|
||||
@ -4578,6 +4574,11 @@ void OmpStructureChecker::CheckWorkshareBlockStmts(
|
||||
|
||||
void OmpStructureChecker::CheckWorkdistributeBlockStmts(
|
||||
const parser::Block &block, parser::CharBlock source) {
|
||||
unsigned version{context_.langOptions().OpenMPVersion};
|
||||
if (version < 60)
|
||||
context_.Say(source,
|
||||
"WORKDISTRIBUTE construct is only supported from openMP 6.0"_err_en_US);
|
||||
|
||||
OmpWorkdistributeBlockChecker ompWorkdistributeBlockChecker{context_, source};
|
||||
|
||||
for (auto it{block.begin()}; it != block.end(); ++it) {
|
||||
@ -4585,9 +4586,7 @@ void OmpStructureChecker::CheckWorkdistributeBlockStmts(
|
||||
parser::Walk(*it, ompWorkdistributeBlockChecker);
|
||||
} else {
|
||||
context_.Say(source,
|
||||
"The structured block in a WORKDISTRIBUTE construct may consist of "
|
||||
"only "
|
||||
"SCALAR or ARRAY assignments"_err_en_US);
|
||||
"The structured block in a WORKDISTRIBUTE construct may consist of only SCALAR or ARRAY assignments"_err_en_US);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
!RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
|
||||
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=61 %s | FileCheck --check-prefix="PARSE-TREE" %s
|
||||
!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
|
||||
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s
|
||||
|
||||
!UNPARSE: SUBROUTINE teams_workdistribute
|
||||
!UNPARSE: USE :: iso_fortran_env
|
||||
|
@ -1,11 +1,11 @@
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
|
||||
! OpenMP Version 6.0
|
||||
! workdistribute Construct
|
||||
! Invalid do construct inside !$omp workdistribute
|
||||
|
||||
subroutine workdistribute()
|
||||
integer n, i
|
||||
!ERROR: A workdistribute region must be nested inside teams region only.
|
||||
!ERROR: A WORKDISTRIBUTE region must be nested inside TEAMS region only.
|
||||
!ERROR: The structured block in a WORKDISTRIBUTE construct may consist of only SCALAR or ARRAY assignments
|
||||
!$omp workdistribute
|
||||
do i = 1, n
|
||||
|
@ -1,4 +1,4 @@
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
|
||||
! OpenMP Version 6.0
|
||||
! workdistribute Construct
|
||||
! The !omp workdistribute construct must not contain any user defined
|
||||
|
@ -1,4 +1,4 @@
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=60
|
||||
! OpenMP Version 6.0
|
||||
! workdistribute Construct
|
||||
! All array assignments, scalar assignments, and masked array assignments
|
||||
|
15
flang/test/Semantics/OpenMP/workdistribute04.f90
Normal file
15
flang/test/Semantics/OpenMP/workdistribute04.f90
Normal file
@ -0,0 +1,15 @@
|
||||
! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=50
|
||||
! OpenMP Version 6.0
|
||||
! workdistribute Construct
|
||||
! Invalid do construct inside !$omp workdistribute
|
||||
|
||||
subroutine teams_workdistribute()
|
||||
use iso_fortran_env
|
||||
real(kind=real32) :: a
|
||||
real(kind=real32), dimension(10) :: x
|
||||
real(kind=real32), dimension(10) :: y
|
||||
!ERROR: WORKDISTRIBUTE construct is only supported from openMP 6.0
|
||||
!$omp teams workdistribute
|
||||
y = a * x + y
|
||||
!$omp end teams workdistribute
|
||||
end subroutine teams_workdistribute
|
Loading…
x
Reference in New Issue
Block a user