Index: include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- include/clang/Basic/DiagnosticDriverKinds.td +++ include/clang/Basic/DiagnosticDriverKinds.td @@ -93,6 +93,7 @@ def err_drv_I_dash_not_supported : Error< "'%0' not supported, please use -iquote instead">; def err_drv_unknown_argument : Error<"unknown argument: '%0'">; +def warn_drv_unknown_argument_clang_cl : Warning<"unknown argument ignored in clang-cl: '%0'">; def err_drv_invalid_value : Error<"invalid value '%1' in '%0'">; def err_drv_invalid_int_value : Error<"invalid integral value '%1' in '%0'">; def err_drv_invalid_remap_file : Error< Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -146,7 +146,9 @@ } for (const Arg *A : Args.filtered(options::OPT_UNKNOWN)) - Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args); + Diags.Report(IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl : + diag::err_drv_unknown_argument) + << A->getAsString(Args); return Args; } @@ -1710,8 +1712,11 @@ continue; } - Diag(clang::diag::warn_drv_unused_argument) - << A->getAsString(C.getArgs()); + // In clang-cl, don't mention unknown arguments here since they have + // already been warned about. + if (!IsCLMode() || !A->getOption().matches(options::OPT_UNKNOWN)) + Diag(clang::diag::warn_drv_unused_argument) + << A->getAsString(C.getArgs()); } } } Index: lib/Driver/Tools.cpp =================================================================== --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -9694,6 +9694,10 @@ options::OPT__SLASH_MT, options::OPT__SLASH_MTd)) A->render(Args, CmdArgs); + // Pass through all unknown arguments so that the fallback command can see + // them too. + Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN); + // Input filename. assert(Inputs.size() == 1); const InputInfo &II = Inputs[0]; Index: test/Driver/cl-fallback.c =================================================================== --- test/Driver/cl-fallback.c +++ test/Driver/cl-fallback.c @@ -3,6 +3,7 @@ // RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \ // RUN: /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \ +// RUN: -garbage -moregarbage \ // RUN: -### -- %s 2>&1 \ // RUN: | FileCheck %s // CHECK: "-fdiagnostics-format" "msvc-fallback" @@ -31,6 +32,8 @@ // CHECK: "/EHs-" // CHECK: "/Zl" // CHECK: "/MT" +// CHECK: "-garbage" +// CHECK: "-moregarbage" // CHECK: "/Tc" "{{.*cl-fallback.c}}" // CHECK: "/Fo{{.*cl-fallback.*.obj}}" Index: test/Driver/unknown-arg.c =================================================================== --- test/Driver/unknown-arg.c +++ test/Driver/unknown-arg.c @@ -1,5 +1,7 @@ // RUN: not %clang %s -cake-is-lie -%0 -%d -HHHH -munknown-to-clang-option -print-stats -funknown-to-clang-option 2>&1 | \ // RUN: FileCheck %s +// RUN: %clang_cl -cake-is-lie -%0 -%d -HHHH -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -- %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CL // CHECK: unknown argument: '-cake-is-lie' // CHECK: unknown argument: '-%0' @@ -8,6 +10,13 @@ // CHECK: unknown argument: '-munknown-to-clang-option' // CHECK: unknown argument: '-print-stats' // CHECK: unknown argument: '-funknown-to-clang-option' +// CL: unknown argument ignored in clang-cl: '-cake-is-lie' +// CL: unknown argument ignored in clang-cl: '-%0' +// CL: unknown argument ignored in clang-cl: '-%d' +// CL: unknown argument ignored in clang-cl: '-HHHH' +// CL: unknown argument ignored in clang-cl: '-munknown-to-clang-option' +// CL: unknown argument ignored in clang-cl: '-print-stats' +// CL: unknown argument ignored in clang-cl: '-funknown-to-clang-option' // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s Index: test/Misc/warning-flags.c =================================================================== --- test/Misc/warning-flags.c +++ test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (84): +CHECK: Warnings without flags (85): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,6 +58,7 @@ CHECK-NEXT: warn_drv_clang_unsupported CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include +CHECK-NEXT: warn_drv_unknown_argument_clang_cl CHECK-NEXT: warn_dup_category_def CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow