Skip to content

[flang][OpenMP] Skip assertion while processing default clause on disallowed constructs #93438

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2108,9 +2108,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
dirContext.defaultDSA == Symbol::Flag::OmpFirstPrivate ||
dirContext.defaultDSA == Symbol::Flag::OmpShared) {
// 1) default
// Allowed only with parallel, teams and task generating constructs.
assert(parallelDir || taskGenDir ||
llvm::omp::allTeamsSet.test(dirContext.directive));
// Allowed only with parallel, teams and task generating constructs,
// skip creating symbols thus.
if (!(parallelDir || taskGenDir ||
llvm::omp::allTeamsSet.test(dirContext.directive)))
return;
if (dirContext.defaultDSA != Symbol::Flag::OmpShared)
declNewSymbol(dirContext.defaultDSA);
else
Expand Down
7 changes: 7 additions & 0 deletions flang/test/Semantics/OpenMP/ordered01.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ program main
integer :: i, N = 10
real :: a, arrayA(10), arrayB(10), arrayC(10)
real, external :: foo, bar, baz

!ERROR: DEFAULT clause is not allowed on the DO directive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message has to improve.

Copy link
Contributor Author

@NimishMishra NimishMishra May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message is coming from CheckAllowed

void DirectiveStructureChecker<D, C, PC, ClauseEnumSize>::CheckAllowed(
. The message needs to be generic, since this is shared across different directives. Do you have anything specific in mind which we could add? Should we need something specific to default, then it would be better to resort to emitting the error at the position where the previous commit of this PR was doing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was a bit confused by the presence of ordered and was thinking this is a restriction only if ordered is present. I see that this is a general constraint for the DO directive, so it is fine.

!$omp do default(private)
do i = 1, N
arrayA(i) = arrayA(i) + 1
end do
!$omp end do

!$omp do ordered
do i = 1, N
Expand Down
Loading