diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -599,14 +599,24 @@ // 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 if (wArg == "extra") { + const unsigned id = diags.getCustomDiagID( + clang::DiagnosticsEngine::Warning, + "Argument `-Wextra` was ignored during compilation. Only `-Werror` " + "is supported currently."); + diags.Report(id); + } else { + const unsigned id = + diags.getCustomDiagID(clang::DiagnosticsEngine::Error, + "Only `-Werror` is supported currently."); + diags.Report(id); + break; + } } }