diff options
author | Jean-Didier PAILLEUX <jean-didier.pailleux@sipearl.com> | 2025-03-03 12:55:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-03 11:55:36 +0000 |
commit | 370d34fe40162946905b900097ed746dd4aeb6ad (patch) | |
tree | 36864e85db697a922fc804ccb3fb77e695899c89 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | a55786170df204ca38caf922850df68ac188c7e0 (diff) | |
download | llvm-370d34fe40162946905b900097ed746dd4aeb6ad.zip llvm-370d34fe40162946905b900097ed746dd4aeb6ad.tar.gz llvm-370d34fe40162946905b900097ed746dd4aeb6ad.tar.bz2 |
[flang][Driver] Add support of -fd-lines-as-comments and -fd-lines-as-code flags (#127605)
`-fd-lines-as-code` and `-fd-lines-as-comments` enables treatment for
lines beginning with `d` or `D` in fixed form sources.
Using these options in free form has no effect.
If the `-fd-lines-as-code` option is given they are treated as if the
first column contained a blank.
If the `-fd-lines-as-comments` option is given, they are treated as
comment lines.
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 724316f..8b07a50 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -961,6 +961,32 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args, clang::DiagnosticsEngine &diags) { unsigned numErrorsBefore = diags.getNumErrors(); + // -fd-lines-as-code + if (args.hasArg(clang::driver::options::OPT_fd_lines_as_code)) { + if (res.getFrontendOpts().fortranForm == FortranForm::FreeForm) { + const unsigned fdLinesAsWarning = diags.getCustomDiagID( + clang::DiagnosticsEngine::Warning, + "‘-fd-lines-as-code’ has no effect in free form."); + diags.Report(fdLinesAsWarning); + } else { + res.getFrontendOpts().features.Enable( + Fortran::common::LanguageFeature::OldDebugLines, true); + } + } + + // -fd-lines-as-comments + if (args.hasArg(clang::driver::options::OPT_fd_lines_as_comments)) { + if (res.getFrontendOpts().fortranForm == FortranForm::FreeForm) { + const unsigned fdLinesAsWarning = diags.getCustomDiagID( + clang::DiagnosticsEngine::Warning, + "‘-fd-lines-as-comments’ has no effect in free form."); + diags.Report(fdLinesAsWarning); + } else { + res.getFrontendOpts().features.Enable( + Fortran::common::LanguageFeature::OldDebugLines, false); + } + } + // -fdefault* family if (args.hasArg(clang::driver::options::OPT_fdefault_real_8)) { res.getDefaultKinds().set_defaultRealKind(8); |