diff --git a/flang/include/flang/Semantics/symbol.h b/flang/include/flang/Semantics/symbol.h --- a/flang/include/flang/Semantics/symbol.h +++ b/flang/include/flang/Semantics/symbol.h @@ -506,7 +506,7 @@ // OpenMP miscellaneous flags OmpCommonBlock, OmpReduction, OmpAllocate, OmpDeclareSimd, OmpDeclareTarget, OmpThreadprivate, OmpDeclareReduction, OmpFlushed, - OmpCriticalLock, OmpIfSpecified, OmpNone, OmpPreDetermined); + OmpCriticalLock, OmpIfSpecified, OmpNone, OmpPreDetermined, OmpAligned); using Flags = common::EnumSet; const Scope &owner() const { return *owner_; } diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -269,7 +269,29 @@ ResolveOmpObjectList(x.v, Symbol::Flag::OmpLastPrivate); return false; } - + bool Pre(const parser::OmpLinearClause &x) { + const std::list *linearList{nullptr}; + std::visit(common::visitors{ + [&](const parser::OmpLinearClause::WithoutModifier + &linearWithoutModifier) { + linearList = &(linearWithoutModifier.names); + }, + [&](const parser::OmpLinearClause::WithModifier + &linearWithModifier) { + linearList = &(linearWithModifier.names); + }, + }, + x.u); + if (linearList) { + ResolveOmpNameList(*linearList, Symbol::Flag::OmpLinear); + } + return true; + } + bool Pre(const parser::OmpAlignedClause &x) { + const auto &alignedNameList{std::get>(x.t)}; + ResolveOmpNameList(alignedNameList, Symbol::Flag::OmpAligned); + return true; + } void Post(const parser::Name &); private: @@ -287,7 +309,7 @@ static constexpr Symbol::Flags ompFlagsRequireNewSymbol{ Symbol::Flag::OmpPrivate, Symbol::Flag::OmpLinear, Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate, - Symbol::Flag::OmpReduction}; + Symbol::Flag::OmpReduction, Symbol::Flag::OmpAligned}; static constexpr Symbol::Flags ompFlagsRequireMark{ Symbol::Flag::OmpThreadprivate}; @@ -316,6 +338,9 @@ Symbol *ResolveOmp(const parser::Name &, Symbol::Flag, Scope &); Symbol *ResolveOmp(Symbol &, Symbol::Flag, Scope &); Symbol *ResolveOmpCommonBlockName(const parser::Name *); + void ResolveOmpNameList(const std::list &, Symbol::Flag); + void ResolveOmpName(const parser::Name &, Symbol::Flag); + Symbol *ResolveName(const parser::Name *); Symbol *DeclareOrMarkOtherAccessEntity(const parser::Name &, Symbol::Flag); Symbol *DeclareOrMarkOtherAccessEntity(Symbol &, Symbol::Flag); void CheckMultipleAppearances( @@ -915,6 +940,32 @@ } // within OpenMP construct } +Symbol *OmpAttributeVisitor::ResolveName(const parser::Name *name) { + if (auto *resolvedSymbol{ + name ? GetContext().scope.FindSymbol(name->source) : nullptr}) { + name->symbol = resolvedSymbol; + return resolvedSymbol; + } else { + return nullptr; + } +} + +void OmpAttributeVisitor::ResolveOmpName( + const parser::Name &name, Symbol::Flag ompFlag) { + if (ResolveName(&name)) { + if (auto *resolvedSymbol{ResolveOmp(name, ompFlag, currScope())}) { + AddToContextObjectWithDSA(*resolvedSymbol, ompFlag); + } + } +} + +void OmpAttributeVisitor::ResolveOmpNameList( + const std::list &nameList, Symbol::Flag ompFlag) { + for (const auto &name : nameList) { + ResolveOmpName(name, ompFlag); + } +} + Symbol *OmpAttributeVisitor::ResolveOmpCommonBlockName( const parser::Name *name) { if (auto *prev{name diff --git a/flang/test/Semantics/omp-clause-validity01.f90 b/flang/test/Semantics/omp-clause-validity01.f90 --- a/flang/test/Semantics/omp-clause-validity01.f90 +++ b/flang/test/Semantics/omp-clause-validity01.f90 @@ -197,7 +197,6 @@ enddo !ERROR: A modifier may not be specified in a LINEAR clause on the DO directive - !ERROR: Internal: no symbol found for 'b' !$omp do linear(ref(b)) do i = 1, N a = 3.14 @@ -217,8 +216,6 @@ !ERROR: The parameter of the ORDERED clause must be a constant positive integer expression !ERROR: A loop directive may not have both a LINEAR clause and an ORDERED clause with a parameter - !ERROR: Internal: no symbol found for 'b' - !ERROR: Internal: no symbol found for 'a' !$omp do ordered(1-1) private(b) linear(b) linear(a) do i = 1, N a = 3.14 @@ -369,7 +366,6 @@ enddo !ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression - !ERROR: Internal: no symbol found for 'b' !$omp simd aligned(b:-2) do i = 1, N a = 3.14 @@ -388,7 +384,6 @@ !ERROR: At most one PROC_BIND clause can appear on the PARALLEL DO directive !ERROR: A modifier may not be specified in a LINEAR clause on the PARALLEL DO directive - !ERROR: Internal: no symbol found for 'b' !$omp parallel do proc_bind(master) proc_bind(close) linear(val(b)) do i = 1, N a = 3.14 @@ -558,7 +553,6 @@ !ERROR: The parameter of the SIMDLEN clause must be a constant positive integer expression !ERROR: The ALIGNMENT parameter of the ALIGNED clause must be a constant positive integer expression - !ERROR: Internal: no symbol found for 'a' !$omp taskloop simd simdlen(-1) aligned(a:-2) do i = 1, N a = 3.14 diff --git a/flang/test/Semantics/omp-do03.f90 b/flang/test/Semantics/omp-do03.f90 --- a/flang/test/Semantics/omp-do03.f90 +++ b/flang/test/Semantics/omp-do03.f90 @@ -1,5 +1,4 @@ ! RUN: %S/test_errors.sh %s %t %f18 -fopenmp -! XFAIL: * ! OpenMP Version 4.5 ! 2.7.1 Loop Construct diff --git a/flang/test/Semantics/omp-loop-simd01.f90 b/flang/test/Semantics/omp-loop-simd01.f90 --- a/flang/test/Semantics/omp-loop-simd01.f90 +++ b/flang/test/Semantics/omp-loop-simd01.f90 @@ -1,5 +1,4 @@ ! RUN: %S/test_errors.sh %s %t %f18 -fopenmp -! XFAIL: * ! OpenMP Version 4.5 ! 2.8.3 Loop simd Construct diff --git a/flang/test/Semantics/omp-simd02.f90 b/flang/test/Semantics/omp-simd02.f90 --- a/flang/test/Semantics/omp-simd02.f90 +++ b/flang/test/Semantics/omp-simd02.f90 @@ -1,5 +1,4 @@ ! RUN: %S/test_errors.sh %s %t %f18 -fopenmp -! XFAIL: * ! OpenMP Version 4.5 ! 2.8.1 simd Construct