Skip to content

Commit 8a923cb

Browse files
committed
[flang][OpenMP] Skip assertion while processing default clause on disallowed constructs
1 parent bafda89 commit 8a923cb

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,9 +2108,11 @@ void OmpAttributeVisitor::Post(const parser::Name &name) {
21082108
dirContext.defaultDSA == Symbol::Flag::OmpFirstPrivate ||
21092109
dirContext.defaultDSA == Symbol::Flag::OmpShared) {
21102110
// 1) default
2111-
// Allowed only with parallel, teams and task generating constructs.
2112-
assert(parallelDir || taskGenDir ||
2113-
llvm::omp::allTeamsSet.test(dirContext.directive));
2111+
// Allowed only with parallel, teams and task generating constructs,
2112+
// skip creating symbols thus.
2113+
if (!(parallelDir || taskGenDir ||
2114+
llvm::omp::allTeamsSet.test(dirContext.directive)))
2115+
return;
21142116
if (dirContext.defaultDSA != Symbol::Flag::OmpShared)
21152117
declNewSymbol(dirContext.defaultDSA);
21162118
else

flang/test/Semantics/OpenMP/ordered01.f90

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ program main
77
integer :: i, N = 10
88
real :: a, arrayA(10), arrayB(10), arrayC(10)
99
real, external :: foo, bar, baz
10+
11+
!ERROR: DEFAULT clause is not allowed on the DO directive
12+
!$omp do ordered default(private)
13+
do i = 1, N
14+
!$omp ordered
15+
arrayA(i) = arrayA(i) + 1
16+
!$omp end ordered
17+
end do
18+
!$omp end do
1019

1120
!$omp do ordered
1221
do i = 1, N

0 commit comments

Comments
 (0)