Skip to content

[flang][OpenMP] Don't abort when default is used on an invalid directive #107586

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

Merged
merged 2 commits into from
Sep 9, 2024
Merged
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
4 changes: 3 additions & 1 deletion flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,9 @@ void OmpAttributeVisitor::CreateImplicitSymbols(
dirContext.defaultDSA == Symbol::Flag::OmpShared) {
// 1) default
// Allowed only with parallel, teams and task generating constructs.
assert(parallelDir || taskGenDir || teamsDir);
if (!parallelDir && !taskGenDir && !teamsDir) {
return;
}
if (dirContext.defaultDSA != Symbol::Flag::OmpShared)
makePrivateSymbol(dirContext.defaultDSA);
else
Expand Down
9 changes: 9 additions & 0 deletions flang/test/Semantics/OpenMP/default.f90
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@ program omp_default
end do
!$omp end teams

!$omp parallel
!ERROR: DEFAULT clause is not allowed on the DO directive
!$omp do default(private)
do i = 1, 10
k = i
end do
!$omp end do
!$omp end parallel

end program omp_default
Loading