Index: cfe/trunk/docs/UsersManual.rst =================================================================== --- cfe/trunk/docs/UsersManual.rst +++ cfe/trunk/docs/UsersManual.rst @@ -2024,8 +2024,9 @@ To suppress warnings about unused arguments, use the ``-Qunused-arguments`` option. -Options that are not known to clang-cl will cause errors. If they are spelled with a -leading ``/``, they will be mistaken for a filename: +Options that are not known to clang-cl will be ignored by default. Use the +``-Werror=unknown-argument`` option in order to treat them as errors. If these +options are spelled with a leading ``/``, they will be mistaken for a filename: :: Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td @@ -93,6 +93,9 @@ 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'">, + InGroup; 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: cfe/trunk/include/clang/Basic/DiagnosticGroups.td =================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td @@ -848,3 +848,5 @@ def InvalidOrNonExistentDirectory : DiagGroup<"invalid-or-nonexistent-directory">; def OptionIgnored : DiagGroup<"option-ignored">; + +def UnknownArgument : DiagGroup<"unknown-argument">; Index: cfe/trunk/lib/Driver/Driver.cpp =================================================================== --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/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: cfe/trunk/lib/Driver/Tools.cpp =================================================================== --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -9708,6 +9708,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: cfe/trunk/test/Driver/cl-fallback.c =================================================================== --- cfe/trunk/test/Driver/cl-fallback.c +++ cfe/trunk/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: cfe/trunk/test/Driver/unknown-arg.c =================================================================== --- cfe/trunk/test/Driver/unknown-arg.c +++ cfe/trunk/test/Driver/unknown-arg.c @@ -1,5 +1,11 @@ // 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 +// RUN: not %clang_cl -cake-is-lie -%0 -%d -HHHH -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -Werror=unknown-argument -- %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CL +// RUN: %clang_cl -cake-is-lie -%0 -%d -HHHH -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -Wno-unknown-argument -- %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=SILENT --allow-empty // CHECK: unknown argument: '-cake-is-lie' // CHECK: unknown argument: '-%0' @@ -8,6 +14,15 @@ // 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' +// SILENT-NOT: error +// SILENT-NOT: warning // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s Index: cfe/trunk/test/Misc/serialized-diags-driver.c =================================================================== --- cfe/trunk/test/Misc/serialized-diags-driver.c +++ cfe/trunk/test/Misc/serialized-diags-driver.c @@ -5,10 +5,10 @@ // doesn't litter the user's system with preprocessed output. // RUN: rm -f %t -// RUN: %clang -Wx-unknown-warning -Wall -fsyntax-only --serialize-diagnostics %t.diag %s +// RUN: %clang -Wx-typoed-warning -Wall -fsyntax-only --serialize-diagnostics %t.diag %s // RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s -// CHECK: warning: unknown warning option '-Wx-unknown-warning' [-Wunknown-warning-option] [] +// CHECK: warning: unknown warning option '-Wx-typoed-warning' [-Wunknown-warning-option] [] // CHECK: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] // CHECK: note: initialize the variable 'voodoo' to silence this warning []