From c4f0ea5a14c79754fb660a35a3bac744012fe704 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Fri, 21 Jun 2019 14:06:17 -0700 Subject: [PATCH] [flang] Pass PGF90 options on only if underlying compiler is PGF90 Original-commit: flang-compiler/f18@dc34f75b07cf96bd48d4c6116f9a55b47b5b1079 Reviewed-on: https://github.com/flang-compiler/f18/pull/531 Tree-same-pre-rewrite: false --- flang/tools/f18/f18.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/flang/tools/f18/f18.cc b/flang/tools/f18/f18.cc index 28a7b719c76d..94d1e22cdcaa 100644 --- a/flang/tools/f18/f18.cc +++ b/flang/tools/f18/f18.cc @@ -321,6 +321,7 @@ int main(int argc, char *const argv[]) { DriverOptions driver; const char *pgf90{getenv("F18_FC")}; driver.pgf90Args.push_back(pgf90 ? pgf90 : "pgf90"); + bool isPGF90{driver.pgf90Args.back().rfind("pgf90") != std::string::npos}; std::list args{argList(argc, argv)}; std::string prefix{args.front()}; @@ -386,7 +387,7 @@ int main(int argc, char *const argv[]) { Fortran::parser::LanguageFeature::BackslashEscapes, false); } else if (arg == "-Mnobackslash") { options.features.Enable( - Fortran::parser::LanguageFeature::BackslashEscapes); + Fortran::parser::LanguageFeature::BackslashEscapes, true); } else if (arg == "-Mstandard") { driver.warnOnNonstandardUsage = true; } else if (arg == "-fopenmp") { @@ -400,7 +401,7 @@ int main(int argc, char *const argv[]) { driver.dumpCookedChars = true; } else if (arg == "-fbackslash") { options.features.Enable( - Fortran::parser::LanguageFeature::BackslashEscapes); + Fortran::parser::LanguageFeature::BackslashEscapes, true); } else if (arg == "-fno-backslash") { options.features.Enable( Fortran::parser::LanguageFeature::BackslashEscapes, false); @@ -455,9 +456,8 @@ int main(int argc, char *const argv[]) { driver.encoding = Fortran::parser::Encoding::UTF_8; } else if (arg == "-flatin") { driver.encoding = Fortran::parser::Encoding::LATIN_1; - } else if (arg == "-fkanji") { + } else if (arg == "-fkanji" || arg == "-Mx,125,4") { driver.encoding = Fortran::parser::Encoding::EUC_JP; - driver.pgf90Args.push_back("-Mx,125,4"); // PGI "Kanji" mode } else if (arg == "-help" || arg == "--help" || arg == "-?") { std::cerr << "f18 options:\n" @@ -504,8 +504,6 @@ int main(int argc, char *const argv[]) { args.pop_front(); } else if (arg.substr(0, 2) == "-I") { driver.searchDirectories.push_back(arg.substr(2)); - } else if (arg == "-Mx,125,4") { // PGI "all Kanji" mode - driver.encoding = Fortran::parser::Encoding::EUC_JP; } } } @@ -516,6 +514,18 @@ int main(int argc, char *const argv[]) { if (options.features.IsEnabled(Fortran::parser::LanguageFeature::OpenMP)) { driver.pgf90Args.push_back("-mp"); } + if (isPGF90) { + if (driver.encoding == Fortran::parser::Encoding::EUC_JP) { + driver.pgf90Args.push_back("-Mx,125,4"); // PGI "Kanji" mode + } + if (!options.features.IsEnabled( + Fortran::parser::LanguageFeature::BackslashEscapes)) { + driver.pgf90Args.push_back( + "-Mbackslash"); // yes, this *disables* them in pgf90 + } + } else { + // TODO: equivalents for other Fortran compilers + } Fortran::parser::AllSources allSources; allSources.set_encoding(driver.encoding);