[flang-commits] [flang] 7f90479 - [flang][OpenMP] Don't abort when default is used on an invalid directive (#107586)
via flang-commits
flang-commits at lists.llvm.org
Mon Sep 9 10:09:49 PDT 2024
Author: Leandro Lupori
Date: 2024-09-09T14:09:45-03:00
New Revision: 7f90479b2300b3758fd90015a2e6e7e94cfcf1e7
URL: https://github.com/llvm/llvm-project/commit/7f90479b2300b3758fd90015a2e6e7e94cfcf1e7
DIFF: https://github.com/llvm/llvm-project/commit/7f90479b2300b3758fd90015a2e6e7e94cfcf1e7.diff
LOG: [flang][OpenMP] Don't abort when default is used on an invalid directive (#107586)
The previous assert was not considering programs with semantic errors.
Fixes https://github.com/llvm/llvm-project/issues/107495
Fixes https://github.com/llvm/llvm-project/issues/93437
Added:
Modified:
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/OpenMP/default.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 17567a555db326..3b20d9e77e1cfe 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -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
diff --git a/flang/test/Semantics/OpenMP/default.f90 b/flang/test/Semantics/OpenMP/default.f90
index 94de7fa4686927..a8d170724c12c9 100644
--- a/flang/test/Semantics/OpenMP/default.f90
+++ b/flang/test/Semantics/OpenMP/default.f90
@@ -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
More information about the flang-commits
mailing list