From 5cbe39ef880e0d8a61db111fca0b14b3ca17a17b Mon Sep 17 00:00:00 2001 From: Nimish Mishra Date: Mon, 11 Jul 2022 21:23:41 +0530 Subject: [PATCH] [flang][OpenMP] Allow default(none) to access variables with PARAMETER attribute This patch fixes https://github.com/flang-compiler/f18-llvm-project/issues/1351. Concretely, data-sharing attributes on PARAMETER data used in a block with DEFAULT(NONE) should be ignored. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D129444 --- flang/lib/Semantics/resolve-directives.cpp | 2 +- flang/test/Semantics/OpenMP/omp-resolve05.f90 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp index bb42638..0bb8798 100644 --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -1475,7 +1475,7 @@ void OmpAttributeVisitor::Post(const parser::Name &name) { auto *symbol{name.symbol}; if (symbol && !dirContext_.empty() && GetContext().withinConstruct) { if (!symbol->owner().IsDerivedType() && !symbol->has() && - !IsObjectWithDSA(*symbol)) { + !IsObjectWithDSA(*symbol) && !IsNamedConstant(*symbol)) { // TODO: create a separate function to go through the rules for // predetermined, explicitly determined, and implicitly // determined data-sharing attributes (2.15.1.1). diff --git a/flang/test/Semantics/OpenMP/omp-resolve05.f90 b/flang/test/Semantics/OpenMP/omp-resolve05.f90 index 509e67b..00f4860 100644 --- a/flang/test/Semantics/OpenMP/omp-resolve05.f90 +++ b/flang/test/Semantics/OpenMP/omp-resolve05.f90 @@ -5,7 +5,7 @@ subroutine default_none() integer a(3) - + integer, parameter :: D=10 A = 1 B = 2 !$omp parallel default(none) private(c) @@ -13,7 +13,7 @@ subroutine default_none() A(1:2) = 3 !ERROR: The DEFAULT(NONE) clause requires that 'b' must be listed in a data-sharing attribute clause B = 4 - C = 5 + C = 5 + D !$omp end parallel end subroutine default_none -- 2.7.4