diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -331,9 +331,6 @@ [&](const auto &) { PutEntity(decls_, symbol); PutDirective(decls_, symbol); - if (symbol.test(Symbol::Flag::OmpThreadprivate)) { - decls_ << "!$omp threadprivate(" << symbol.name() << ")\n"; - } }, }, symbol.details()); @@ -875,7 +872,7 @@ return os; } -void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) { +void PutOpenACCDirective(llvm::raw_ostream &os, const Symbol &symbol) { if (symbol.test(Symbol::Flag::AccDeclare)) { os << "!$acc declare "; if (symbol.test(Symbol::Flag::AccCopy)) { @@ -899,6 +896,17 @@ } } +void PutOpenMPDirective(llvm::raw_ostream &os, const Symbol &symbol) { + if (symbol.test(Symbol::Flag::OmpThreadprivate)) { + os << "!$omp threadprivate(" << symbol.name() << ")\n"; + } +} + +void ModFileWriter::PutDirective(llvm::raw_ostream &os, const Symbol &symbol) { + PutOpenACCDirective(os, symbol); + PutOpenMPDirective(os, symbol); +} + struct Temp { Temp(int fd, std::string path) : fd{fd}, path{path} {} Temp(Temp &&t) : fd{std::exchange(t.fd, -1)}, path{std::move(t.path)} {}