std::string dir_{"."};
// The mod file consists of uses, declarations, and contained subprograms:
std::stringstream uses_;
+ std::stringstream useExtraAttrs_; // attrs added to used entity
std::stringstream decls_;
std::stringstream contains_;
// Any errors encountered during writing:
void PutDerivedType(const Symbol &);
void PutSubprogram(const Symbol &);
void PutUse(const Symbol &);
+ void PutUseExtraAttr(Attr, const Symbol &, const Symbol &);
static void PutEntity(std::ostream &, const Symbol &);
static void PutObjectEntity(std::ostream &, const Symbol &);
static void PutProcEntity(std::ostream &, const Symbol &);
all << "module " << name << '\n';
all << uses_.str();
uses_.str(""s);
+ all << useExtraAttrs_.str();
+ useExtraAttrs_.str(""s);
all << decls_.str();
decls_.str(""s);
auto str{contains_.str()};
void ModFileWriter::PutUse(const Symbol &symbol) {
auto &details{symbol.get<UseDetails>()};
+ auto &use{details.symbol()};
PutLower(uses_ << "use ", details.module());
PutLower(uses_ << ",only:", symbol);
- if (details.symbol().name() != symbol.name()) {
- PutLower(uses_ << "=>", details.symbol());
+ if (use.name() != symbol.name()) {
+ PutLower(uses_ << "=>", use);
}
uses_ << '\n';
+ PutUseExtraAttr(Attr::VOLATILE, symbol, use);
+ PutUseExtraAttr(Attr::ASYNCHRONOUS, symbol, use);
+}
+
+// We have "USE local => use" in this module. If attr was added locally
+// (i.e. on local but not on use), also write it out in the mod file.
+void ModFileWriter::PutUseExtraAttr(Attr attr, const Symbol &local, const Symbol &use) {
+ if (local.attrs().test(attr) && !use.attrs().test(attr)) {
+ PutLower(useExtraAttrs_, AttrToString(attr)) << "::";
+ PutLower(useExtraAttrs_, local) << '\n';
+ }
}
void ModFileWriter::PutEntity(std::ostream &os, const Symbol &symbol) {
--- /dev/null
+! Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+!
+! Licensed under the Apache License, Version 2.0 (the "License");
+! you may not use this file except in compliance with the License.
+! You may obtain a copy of the License at
+!
+! http://www.apache.org/licenses/LICENSE-2.0
+!
+! Unless required by applicable law or agreed to in writing, software
+! distributed under the License is distributed on an "AS IS" BASIS,
+! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+! See the License for the specific language governing permissions and
+! limitations under the License.
+
+! Use-association with VOLATILE or ASYNCHRONOUS
+
+module m1
+ real x
+ integer y
+ volatile z
+contains
+end
+
+module m2
+ use m1
+ volatile x
+ asynchronous y
+end
+
+!Expect: m1.mod
+!module m1
+!real::x
+!integer::y
+!real,volatile::z
+!end
+
+!Expect: m2.mod
+!module m2
+!use m1,only:x
+!use m1,only:y
+!use m1,only:z
+!volatile::x
+!asynchronous::y
+!end