diff options
author | Ethan Luis McDonough <ethanluismcdonough@gmail.com> | 2023-02-21 16:09:34 -0600 |
---|---|---|
committer | Ethan Luis McDonough <ethanluismcdonough@gmail.com> | 2023-02-21 16:14:19 -0600 |
commit | ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491 (patch) | |
tree | 5ac96f018c720e6e8f25cb960ee9dbfa8a8363cc /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | ae2322a0dca9f8c39b1db51756c7155610fe668a (diff) | |
download | llvm-ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491.zip llvm-ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491.tar.gz llvm-ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491.tar.bz2 |
[flang] Handle unsupported warning flags
This PR makes flang emit a warning when the user passes an unsupported gfortran warning flag in as a CLI arg. This PR also checks each `-W` argument instead of just looking at the last one passed in.
Reviewed By: awarzynski
Differential Revision: https://reviews.llvm.org/D143301
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 9bccb7e..4fb1eb8 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -610,14 +610,17 @@ static bool parseDiagArgs(CompilerInvocation &res, llvm::opt::ArgList &args, // TODO: Currently throws a Diagnostic for anything other than -W<error>, // this has to change when other -W<opt>'s are supported. if (args.hasArg(clang::driver::options::OPT_W_Joined)) { - if (args.getLastArgValue(clang::driver::options::OPT_W_Joined) - .equals("error")) { - res.setWarnAsErr(true); - } else { - const unsigned diagID = - diags.getCustomDiagID(clang::DiagnosticsEngine::Error, - "Only `-Werror` is supported currently."); - diags.Report(diagID); + const auto &wArgs = + args.getAllArgValues(clang::driver::options::OPT_W_Joined); + for (const auto &wArg : wArgs) { + if (wArg == "error") { + res.setWarnAsErr(true); + } else { + const unsigned diagID = + diags.getCustomDiagID(clang::DiagnosticsEngine::Error, + "Only `-Werror` is supported currently."); + diags.Report(diagID); + } } } |