[flang-commits] [flang] [flang] Add options -W[no-]unused-dummy-argument and -W[no-]unused-variable (PR #127214)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Tue Feb 18 08:39:07 PST 2025


================
@@ -932,10 +932,24 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
     for (const auto &wArg : wArgs) {
       if (wArg == "error") {
         res.setWarnAsErr(true);
+      } else if (wArg == "unused-dummy-argument") {
+        res.getFrontendOpts().features.Enable(
+            Fortran::common::LanguageFeature::UnusedDummyArgument);
+      } else if (wArg == "no-unused-dummy-argument") {
+        res.getFrontendOpts().features.Enable(
+            Fortran::common::LanguageFeature::UnusedDummyArgument, false);
+      } else if (wArg == "unused-variable") {
+        res.getFrontendOpts().features.Enable(
+            Fortran::common::LanguageFeature::UnusedVariable);
+      } else if (wArg == "no-unused-variable") {
+        res.getFrontendOpts().features.Enable(
+            Fortran::common::LanguageFeature::UnusedVariable, false);
       } else {
-        const unsigned diagID =
-            diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
-                                  "Only `-Werror` is supported currently.");
+        const unsigned diagID = diags.getCustomDiagID(
+            clang::DiagnosticsEngine::Error,
+            "Only `-Werror`, `-W[no]unused-dummy-argument` "
+            "and `-W[no]unused-variable` are supported "
+            "currently.");
----------------
tarunprabhu wrote:

This doesn't look like it is scalable. For every warning option that is added, we would have to add a check and change the diagnostic line. Besides, the comment above suggests that this was intended to be a temporary measure. This code predates my involvement with this project. Perhaps those who have been around longer have some insight on how the warning classes were intended to be handled: @banach-space @kiranchandramohan @jeanPerier 

https://github.com/llvm/llvm-project/pull/127214


More information about the flang-commits mailing list