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 @@ -605,16 +605,16 @@ if (wArg == "error") { res.setWarnAsErr(true); } else if (wArg == "extra") { - const unsigned id = diags.getCustomDiagID( + const unsigned diagID = diags.getCustomDiagID( clang::DiagnosticsEngine::Warning, "Argument `-Wextra` was ignored during compilation. Only `-Werror` " "is supported currently."); - diags.Report(id); + diags.Report(diagID); } else { - const unsigned id = + const unsigned diagID = diags.getCustomDiagID(clang::DiagnosticsEngine::Error, "Only `-Werror` is supported currently."); - diags.Report(id); + diags.Report(diagID); break; } } diff --git a/flang/test/Driver/werror-all.f90 b/flang/test/Driver/werror-all.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Driver/werror-all.f90 @@ -0,0 +1,11 @@ +! Ensures that -Werror is read regardless of whether or not other -W +! flags are present in the CLI args + +! RUN: not %flang -std=f2018 -Werror -Wextra %s +! RUN: %flang -std=f2018 -Wextra -Wall %s + +program werror_check_all + integer :: a(3) + forall (j=1:n) a(i) = 1 +end program werror_check_all + diff --git a/flang/test/Driver/wextra-ok.f90 b/flang/test/Driver/wextra-ok.f90 new file mode 100644 --- /dev/null +++ b/flang/test/Driver/wextra-ok.f90 @@ -0,0 +1,7 @@ +! Ensure that supplying -Wextra into flang-new does not raise error + +! RUN: %flang -std=f2018 -Wextra %s +! RUN: not %flang -std=f2018 -Wblah -Wextra %s + +program wextra_ok +end program wextra_ok