Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions flang/test/Semantics/OpenMP/ordered01.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ 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 ordered default(private)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think ordered is not necessary for this test.

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

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