diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -235,6 +235,10 @@ def clang_ignored_m_Group : OptionGroup<"">, Group, Flags<[Ignored]>; +// Unsupported flang groups +def flang_ignored_w_Group : OptionGroup<"">, + Group, Flags<[FlangOnlyOption, Ignored]>; + // Group for clang options in the process of deprecation. // Please include the version that deprecated the flag as comment to allow // easier garbage collection. @@ -4874,6 +4878,10 @@ def fno_#NAME : Flag<["-"], "fno-"#name>; } +multiclass FlangIgnoredWarning { + def unsupported_warning_w#NAME : Flag<["-", "--"], "W"#name>, Group; +} + defm : BooleanFFlag<"keep-inline-functions">, Group; def fprofile_dir : Joined<["-"], "fprofile-dir=">, Group; @@ -5034,6 +5042,34 @@ defm underscoring : BooleanFFlag<"underscoring">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; +// +defm : FlangIgnoredWarning<"extra">; +defm : FlangIgnoredWarning<"aliasing">; +defm : FlangIgnoredWarning<"ampersand">; +defm : FlangIgnoredWarning<"array-bounds">; +defm : FlangIgnoredWarning<"c-binding-type">; +defm : FlangIgnoredWarning<"character-truncation">; +defm : FlangIgnoredWarning<"conversion">; +defm : FlangIgnoredWarning<"do-subscript">; +defm : FlangIgnoredWarning<"function-elimination">; +defm : FlangIgnoredWarning<"implicit-interface">; +defm : FlangIgnoredWarning<"implicit-procedure">; +defm : FlangIgnoredWarning<"intrinsic-shadow">; +defm : FlangIgnoredWarning<"use-without-only">; +defm : FlangIgnoredWarning<"intrinsics-std">; +defm : FlangIgnoredWarning<"line-truncation">; +defm : FlangIgnoredWarning<"no-align-commons">; +defm : FlangIgnoredWarning<"no-overwrite-recursive">; +defm : FlangIgnoredWarning<"no-tabs">; +defm : FlangIgnoredWarning<"real-q-constant">; +defm : FlangIgnoredWarning<"surprising">; +defm : FlangIgnoredWarning<"underflow">; +defm : FlangIgnoredWarning<"unused-parameter">; +defm : FlangIgnoredWarning<"realloc-lhs">; +defm : FlangIgnoredWarning<"realloc-lhs-all">; +defm : FlangIgnoredWarning<"frontend-loop-interchange">; +defm : FlangIgnoredWarning<"target-lifetime">; + // C++ SYCL options def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, Group, HelpText<"Enables SYCL kernels compilation for device">; 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 @@ -604,14 +604,17 @@ // 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); + } } } 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,13 @@ +! 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 2>&1 | FileCheck %s --check-prefix=WRONG +! RUN: %flang -std=f2018 -Wextra -Wall %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK + +! WRONG: Semantic errors in +! CHECK-OK: FORALL index variable + +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,11 @@ +! Ensure that supplying -Wextra into flang-new does not raise error +! The first check should be changed if -Wextra is implemented + +! RUN: %flang -std=f2018 -Wextra %s 2>&1 | FileCheck %s --check-prefix=CHECK-OK +! RUN: not %flang -std=f2018 -Wblah -Wextra %s 2>&1 | FileCheck %s --check-prefix=WRONG + +! CHECK-OK: argument unused during compilation: '-Wextra' +! WRONG: Only `-Werror` is supported currently. + +program wextra_ok +end program wextra_ok