Index: flang/tools/f18/f18.cpp =================================================================== --- flang/tools/f18/f18.cpp +++ flang/tools/f18/f18.cpp @@ -85,7 +85,7 @@ bool compileOnly{false}; // -c std::string outputPath; // -o path std::vector searchDirectories; // -I dir - std::string moduleDirectory{"."s}; // -module dir + std::string moduleDirectory{"."s}; // -module/-module-dir dir std::string moduleFileSuffix{".mod"}; // -moduleSuffix suff bool forcedForm{false}; // -Mfixed or -Mfree appeared bool warnOnNonstandardUsage{false}; // -Mstandard @@ -102,6 +102,7 @@ bool dumpSymbols{false}; bool debugNoSemantics{false}; bool debugModuleWriter{false}; + bool defaultReal8{false}; bool measureTree{false}; bool unparseTypedExprsToF18_FC{false}; std::vector F18_FCArgs; @@ -563,10 +564,22 @@ } } else if (arg.substr(0, 2) == "-U") { predefinitions.emplace_back(arg.substr(2), std::optional{}); - } else if (arg == "-fdefault-double-8") { - defaultKinds.set_defaultRealKind(4); } else if (arg == "-r8" || arg == "-fdefault-real-8") { + driver.defaultReal8 = true; defaultKinds.set_defaultRealKind(8); + defaultKinds.set_doublePrecisionKind(16); + } else if (arg == "-fdefault-double-8") { + if (!driver.defaultReal8) { + // -fdefault-double-8 has to be used with -fdefault-real-8 + // to be compatible with gfortran + llvm::errs() << "Use of `-fdefault-double-8` requires `-fdefault-real-8`\n"; + return EXIT_FAILURE; + } + // For -fdefault-double-8 + -fdefault-real-8, only the size of + // DOUBLE PRECISION type changes, the size of default real type stays + // the same + // https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html + defaultKinds.set_doublePrecisionKind(8); } else if (arg == "-i8" || arg == "-fdefault-integer-8") { defaultKinds.set_defaultIntegerKind(8); defaultKinds.set_subscriptIntegerKind(8); @@ -582,6 +595,7 @@ defaultKinds.set_sizeIntegerKind(4); } else if (arg == "-module") { driver.moduleDirectory = args.front(); + driver.searchDirectories.push_back(driver.moduleDirectory); args.pop_front(); } else if (arg == "-module-dir") { driver.moduleDirectory = args.front(); @@ -655,7 +669,7 @@ << " -Werror treat warnings as errors\n" << " -ed enable fixed form D lines\n" << " -E prescan & preprocess only\n" - << " -module dir module output directory (default .)\n" + << " -module/-module-dir module output directory (default .)\n" << " -flatin interpret source as Latin-1 (ISO 8859-1) " "rather than UTF-8\n" << " -fsyntax-only parsing and semantics only, no output "