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 @@ -594,7 +594,10 @@ // OpenACC data-sharing attribute AccPrivate, AccFirstPrivate, AccShared, // OpenACC data-mapping attribute - AccCopy, AccCopyIn, AccCopyOut, AccCreate, AccDelete, AccPresent, + AccCopy, AccCopyIn, AccCopyOut, AccCreate, AccDelete, AccPresent, AccLink, + AccDeviceResident, AccDevicePtr, + // OpenACC declare + AccDeclare, // OpenACC data-movement attribute AccDevice, AccHost, AccSelf, // OpenACC miscellaneous flags 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 @@ -195,6 +195,21 @@ return false; } + bool Pre(const parser::AccClause::DeviceResident &x) { + ResolveAccObjectList(x.v, Symbol::Flag::AccDeviceResident); + return false; + } + + bool Pre(const parser::AccClause::Deviceptr &x) { + ResolveAccObjectList(x.v, Symbol::Flag::AccDevicePtr); + return false; + } + + bool Pre(const parser::AccClause::Link &x) { + ResolveAccObjectList(x.v, Symbol::Flag::AccLink); + return false; + } + bool Pre(const parser::AccClause::Host &x) { ResolveAccObjectList(x.v, Symbol::Flag::AccHost); return false; @@ -216,23 +231,27 @@ private: std::int64_t GetAssociatedLoopLevelFromClauses(const parser::AccClauseList &); - static constexpr Symbol::Flags dataSharingAttributeFlags{ + Symbol::Flags dataSharingAttributeFlags{ Symbol::Flag::AccShared, Symbol::Flag::AccPrivate, - Symbol::Flag::AccPresent, Symbol::Flag::AccFirstPrivate, - Symbol::Flag::AccReduction}; + Symbol::Flag::AccFirstPrivate, Symbol::Flag::AccReduction}; - static constexpr Symbol::Flags dataMappingAttributeFlags{ + Symbol::Flags dataMappingAttributeFlags{ Symbol::Flag::AccCreate, Symbol::Flag::AccCopyIn, - Symbol::Flag::AccCopyOut, Symbol::Flag::AccDelete}; + Symbol::Flag::AccCopyOut, Symbol::Flag::AccDelete, + Symbol::Flag::AccPresent}; - static constexpr Symbol::Flags accFlagsRequireNewSymbol{ + Symbol::Flags accFlagsRequireNewSymbol{ Symbol::Flag::AccPrivate, Symbol::Flag::AccFirstPrivate, Symbol::Flag::AccReduction}; - static constexpr Symbol::Flags accDataMvtFlags{ + Symbol::Flags accDataMvtFlags{ Symbol::Flag::AccDevice, Symbol::Flag::AccHost, Symbol::Flag::AccSelf}; - static constexpr Symbol::Flags accFlagsRequireMark{}; + Symbol::Flags accFlagsRequireMark{ + Symbol::Flag::AccCreate, Symbol::Flag::AccCopyIn, Symbol::Flag::AccCopy, + Symbol::Flag::AccCopyOut, Symbol::Flag::AccDevicePtr, + Symbol::Flag::AccDeviceResident, Symbol::Flag::AccLink, + Symbol::Flag::AccPresent}; void PrivatizeAssociatedLoopIndex(const parser::OpenACCLoopConstruct &); void ResolveAccObjectList(const parser::AccObjectList &, Symbol::Flag); @@ -532,26 +551,26 @@ private: std::int64_t GetAssociatedLoopLevelFromClauses(const parser::OmpClauseList &); - static constexpr Symbol::Flags dataSharingAttributeFlags{ + Symbol::Flags dataSharingAttributeFlags{ Symbol::Flag::OmpShared, Symbol::Flag::OmpPrivate, Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpReduction, Symbol::Flag::OmpLinear}; - static constexpr Symbol::Flags privateDataSharingAttributeFlags{ + Symbol::Flags privateDataSharingAttributeFlags{ Symbol::Flag::OmpPrivate, Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate}; - static constexpr Symbol::Flags ompFlagsRequireNewSymbol{ + Symbol::Flags ompFlagsRequireNewSymbol{ Symbol::Flag::OmpPrivate, Symbol::Flag::OmpLinear, Symbol::Flag::OmpFirstPrivate, Symbol::Flag::OmpLastPrivate, Symbol::Flag::OmpReduction, Symbol::Flag::OmpCriticalLock, Symbol::Flag::OmpCopyIn, Symbol::Flag::OmpUseDevicePtr, Symbol::Flag::OmpUseDeviceAddr}; - static constexpr Symbol::Flags ompFlagsRequireMark{ + Symbol::Flags ompFlagsRequireMark{ Symbol::Flag::OmpThreadprivate, Symbol::Flag::OmpDeclareTarget}; - static constexpr Symbol::Flags dataCopyingAttributeFlags{ + Symbol::Flags dataCopyingAttributeFlags{ Symbol::Flag::OmpCopyIn, Symbol::Flag::OmpCopyPrivate}; std::vector allocateNames_; // on one directive @@ -1171,7 +1190,10 @@ Symbol *AccAttributeVisitor::DeclareOrMarkOtherAccessEntity( Symbol &object, Symbol::Flag accFlag) { if (accFlagsRequireMark.test(accFlag)) { - object.set(accFlag); + if (GetContext().directive == llvm::acc::ACCD_declare) { + object.set(Symbol::Flag::AccDeclare); + object.set(accFlag); + } } return &object; } diff --git a/flang/test/Semantics/OpenACC/acc-symbols02.f90 b/flang/test/Semantics/OpenACC/acc-symbols02.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Semantics/OpenACC/acc-symbols02.f90 @@ -0,0 +1,21 @@ +! RUN: %python %S/../test_symbols.py %s %flang_fc1 -fopenacc + +!DEF:/acc_declare_symbolsModule +module acc_declare_symbols + !DEF: /acc_declare_symbols/a PUBLIC (AccCreate, AccDeclare) ObjectEntity REAL(4) + real a(100) + !$acc declare create(a) + + !DEF:/acc_declare_symbols/b PUBLIC (AccCopyIn, AccDeclare) ObjectEntity REAL(4) + real b(20) + !$acc declare copyin(b) + + !DEF:/acc_declare_symbols/c PUBLIC (AccDeviceResident, AccDeclare) ObjectEntity REAL(4) + real c(10) + !$acc declare device_resident(c) + + !DEF:/acc_declare_symbols/d PUBLIC (AccLink, AccDeclare) ObjectEntity REAL(4) + real d(10) + !$acc declare link(d) + +end module