From ce3a1c59e18027e7d18a2a0a99e4bc81ccc03491 Mon Sep 17 00:00:00 2001 From: Ethan Luis McDonough Date: Tue, 21 Feb 2023 16:09:34 -0600 Subject: [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 --- flang/lib/Frontend/CompilerInvocation.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'flang/lib/Frontend/CompilerInvocation.cpp') 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, // this has to change when other -W'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); + } } } -- cgit v1.1