[flang-commits] [flang] [flang] Add options -W[no-]unused-dummy-argument and -W[no-]unused-variable (PR #127214)
Andrzej WarzyĆski via flang-commits
flang-commits at lists.llvm.org
Wed Feb 19 01:38:55 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.");
----------------
banach-space wrote:
I've just realised that the link that I shared was wrong, I meant this: https://github.com/llvm/llvm-project/blob/055872acc28afdd8d29acdbec24f4bd415481d33/clang/include/clang/Basic/DiagnosticGroups.td#L863
> it would be better to add an entry for each warning flag in the main driver?
Adding things in the main driver makes sense if it's going to be re-used by Clang. Is it? IIRC, Clang ties these "warning" flags to various diagnostic groups (hence the link above), as opposed to using https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Driver/Options.td.
But please keep in mind that I've not touched this in ~3yrs and these are just bits from my memory. In practice, we should re-visit the logic in Clang and see whether there's scope for re-use.
* **If yes**, great, just do it!
* **If not**, then Flang needs something bespoke.
As I no longer actively work in this area, I am unable to make a specific suggestion. But hopefully this provides a good starting point.
https://github.com/llvm/llvm-project/pull/127214
More information about the flang-commits
mailing list