[flang-commits] [clang] [flang] [flang][Driver] Support --no-warnings option (PR #107455)
via flang-commits
flang-commits at lists.llvm.org
Thu Sep 5 12:44:41 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Tarun Prabhu (tarunprabhu)
<details>
<summary>Changes</summary>
Because of the way visibility is implemented in Options.td, options that are aliases do not inherit the visibility of the option being aliased. Therefore, explicitly set the visibility of the alias to be the same as the aliased option.
This partially addresses https://github.com/llvm/llvm-project/issues/89888
---
Full diff: https://github.com/llvm/llvm-project/pull/107455.diff
4 Files Affected:
- (modified) clang/include/clang/Driver/Options.td (+3-1)
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1)
- (modified) flang/lib/Frontend/CompilerInvocation.cpp (+2-1)
- (modified) flang/test/Driver/w-option.f90 (+3)
``````````diff
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1b9b3f2c6600a3..049c6cf4cef955 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5978,7 +5978,9 @@ def _no_line_commands : Flag<["--"], "no-line-commands">, Alias<P>;
def _no_standard_includes : Flag<["--"], "no-standard-includes">, Alias<nostdinc>;
def _no_standard_libraries : Flag<["--"], "no-standard-libraries">, Alias<nostdlib>;
def _no_undefined : Flag<["--"], "no-undefined">, Flags<[LinkerInput]>;
-def _no_warnings : Flag<["--"], "no-warnings">, Alias<w>;
+def _no_warnings : Flag<["--"], "no-warnings">,
+ Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+ Alias<w>;
def _optimize_EQ : Joined<["--"], "optimize=">, Alias<O>;
def _optimize : Flag<["--"], "optimize">, Alias<O>;
def _output_class_directory_EQ : Joined<["--"], "output-class-directory=">, Alias<foutput_class_dir_EQ>;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 6ce79d27e98c48..fc6762f6bdae40 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -777,6 +777,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
// Disable all warnings
// TODO: Handle interactions between -w, -pedantic, -Wall, -WOption
Args.AddLastArg(CmdArgs, options::OPT_w);
+ Args.AddLastArg(CmdArgs, options::OPT__no_warnings);
// Forward flags for OpenMP. We don't do this if the current action is an
// device offloading action other than OpenMP.
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp
index 1d73397d330178..9b35d54f61a0d0 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -942,7 +942,8 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
}
// -w
- if (args.hasArg(clang::driver::options::OPT_w))
+ if (args.hasArg(clang::driver::options::OPT_w,
+ clang::driver::options::OPT__no_warnings))
res.setDisableWarnings();
// -std=f2018
diff --git a/flang/test/Driver/w-option.f90 b/flang/test/Driver/w-option.f90
index e34cddaab373a1..b6aa44a06ab729 100644
--- a/flang/test/Driver/w-option.f90
+++ b/flang/test/Driver/w-option.f90
@@ -4,6 +4,9 @@
! Test that the warnings are not generated with `-w` option.
! RUN: %flang -c -w %s 2>&1 | FileCheck --allow-empty %s -check-prefix=WARNING
+! Test that the warnings are not generated with `--no-warnings` option.
+! RUN: %flang -c --no-warnings %s 2>&1 | FileCheck --allow-empty %s -check-prefix=WARNING
+
! Test that warnings are portability messages are generated.
! RUN: %flang -c -pedantic %s 2>&1 | FileCheck %s -check-prefixes=DEFAULT,PORTABILITY
``````````
</details>
https://github.com/llvm/llvm-project/pull/107455
More information about the flang-commits
mailing list