[flang-commits] [clang] [flang] [flang][Driver] Support --no-warnings option (PR #107455)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Thu Sep 5 12:46:16 PDT 2024


https://github.com/tarunprabhu updated https://github.com/llvm/llvm-project/pull/107455

>From 984032c16fd7ebadf06737973ad3a165b689cc3c Mon Sep 17 00:00:00 2001
From: Tarun Prabhu <tarun.prabhu at gmail.com>
Date: Thu, 5 Sep 2024 13:34:51 -0600
Subject: [PATCH] [flang][Driver] Support --no-warnings option

Because of the way visibility is implemented in Options.td, options that are
aliases do not inherit the visibility of the option being aliased. For now,
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
---
 clang/include/clang/Driver/Options.td | 4 +++-
 flang/test/Driver/w-option.f90        | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

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/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
 



More information about the flang-commits mailing list