[flang-commits] [flang] cc2172b - [flang] Fix multi-file compilations in throwaway driver

peter klausler via flang-commits flang-commits at lists.llvm.org
Thu Apr 9 08:15:23 PDT 2020


Author: peter klausler
Date: 2019-07-08T10:43:42-07:00
New Revision: cc2172b6f4749abbc933f3ec39f845112a0370ec

URL: https://github.com/llvm/llvm-project/commit/cc2172b6f4749abbc933f3ec39f845112a0370ec
DIFF: https://github.com/llvm/llvm-project/commit/cc2172b6f4749abbc933f3ec39f845112a0370ec.diff

LOG: [flang] Fix multi-file compilations in throwaway driver

Original-commit: flang-compiler/f18 at 7954d0aecf6874027fb138a45485b3a9701db334
Reviewed-on: https://github.com/flang-compiler/f18/pull/553
Tree-same-pre-rewrite: false

Added: 
    

Modified: 
    flang/tools/f18/f18.cc

Removed: 
    


################################################################################
diff  --git a/flang/tools/f18/f18.cc b/flang/tools/f18/f18.cc
index 6a0c7008026a..ece113e30572 100644
--- a/flang/tools/f18/f18.cc
+++ b/flang/tools/f18/f18.cc
@@ -164,7 +164,16 @@ int exitStatus{EXIT_SUCCESS};
 
 std::string CompileFortran(std::string path, Fortran::parser::Options options,
     DriverOptions &driver,
-    Fortran::semantics::SemanticsContext &semanticsContext) {
+    const Fortran::common::IntrinsicTypeDefaultKinds &defaultKinds) {
+  Fortran::parser::AllSources allSources;
+  allSources.set_encoding(driver.encoding);
+  Fortran::semantics::SemanticsContext semanticsContext{
+      defaultKinds, options.features, allSources};
+  semanticsContext.set_moduleDirectory(driver.moduleDirectory)
+      .set_moduleFileSuffix(driver.moduleFileSuffix)
+      .set_searchDirectories(driver.searchDirectories)
+      .set_warnOnNonstandardUsage(driver.warnOnNonstandardUsage)
+      .set_warningsAreErrors(driver.warningsAreErrors);
   if (!driver.forcedForm) {
     auto dot{path.rfind(".")};
     if (dot != std::string::npos) {
@@ -529,24 +538,14 @@ int main(int argc, char *const argv[]) {
     // TODO: equivalents for other Fortran compilers
   }
 
-  Fortran::parser::AllSources allSources;
-  allSources.set_encoding(driver.encoding);
-  Fortran::semantics::SemanticsContext semanticsContext{
-      defaultKinds, options.features, allSources};
-  semanticsContext.set_moduleDirectory(driver.moduleDirectory)
-      .set_moduleFileSuffix(driver.moduleFileSuffix)
-      .set_searchDirectories(driver.searchDirectories)
-      .set_warnOnNonstandardUsage(driver.warnOnNonstandardUsage)
-      .set_warningsAreErrors(driver.warningsAreErrors);
-
   if (!anyFiles) {
     driver.measureTree = true;
     driver.dumpUnparse = true;
-    CompileFortran("-", options, driver, semanticsContext);
+    CompileFortran("-", options, driver, defaultKinds);
     return exitStatus;
   }
   for (const auto &path : fortranSources) {
-    std::string relo{CompileFortran(path, options, driver, semanticsContext)};
+    std::string relo{CompileFortran(path, options, driver, defaultKinds)};
     if (!driver.compileOnly && !relo.empty()) {
       relocatables.push_back(relo);
     }


        


More information about the flang-commits mailing list