-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[flang][OpenMP]Add support for fail clause #118683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2486,17 +2486,28 @@ void OmpStructureChecker::CheckAtomicMemoryOrderClause( | |
| const parser::OmpAtomicClauseList *leftHandClauseList, | ||
| const parser::OmpAtomicClauseList *rightHandClauseList) { | ||
| int numMemoryOrderClause = 0; | ||
| int numFailClause = 0; | ||
|
||
| auto checkForValidMemoryOrderClause = | ||
| [&](const parser::OmpAtomicClauseList *clauseList) { | ||
| for (const auto &clause : clauseList->v) { | ||
| if (std::get_if<Fortran::parser::OmpMemoryOrderClause>(&clause.u)) { | ||
| numMemoryOrderClause++; | ||
| if (numMemoryOrderClause > 1) { | ||
| if (std::get_if<parser::OmpFailClause>(&clause.u)) { | ||
| numFailClause++; | ||
| if (numFailClause > 1) { | ||
| context_.Say(clause.source, | ||
| "More than one memory order clause not allowed on " | ||
| "More than one fail clause not allowed on " | ||
|
||
| "OpenMP Atomic construct"_err_en_US); | ||
| return; | ||
| } | ||
| } else { | ||
| if (std::get_if<Fortran::parser::OmpMemoryOrderClause>(&clause.u)) { | ||
| numMemoryOrderClause++; | ||
| if (numMemoryOrderClause > 1) { | ||
| context_.Say(clause.source, | ||
| "More than one memory order clause not allowed on " | ||
| "OpenMP Atomic construct"_err_en_US); | ||
|
||
| return; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,11 @@ class SemanticsVisitor : public virtual BaseChecker, public virtual C... { | |
| context_.set_location(std::nullopt); | ||
| } | ||
|
|
||
| // This is necessary to avoid "walking" into the Fail clause, | ||
| // which confuses the CheckAllowed into thinking there's another | ||
| // memoryorder, when it's actually the argument to the fail clause. | ||
| bool Pre(const parser::OmpFailClause &) { return false; } | ||
|
||
|
|
||
| bool Walk(const parser::Program &program) { | ||
| parser::Walk(program, *this); | ||
| return !context_.AnyFatalError(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s | ||
|
|
||
| ! CHECK: not yet implemented: OpenMP atomic compare | ||
| program p | ||
| integer :: x | ||
| logical :: r | ||
| !$omp atomic compare fail(relaxed) | ||
| if (x .eq. 0) then | ||
| x = 2 | ||
| end if | ||
| end program p |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
OmpXyzClauseclasses are ordered alphabetically. Could you move it to the right location?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.