diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2572,10 +2572,11 @@ } // Warn -x after last input file has no effect - { + if (!IsCLMode()) { Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x); Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT); - if (LastXArg && LastInputArg && LastInputArg->getIndex() < LastXArg->getIndex()) + if (LastXArg && LastInputArg && + LastInputArg->getIndex() < LastXArg->getIndex()) Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue(); } diff --git a/clang/test/Driver/x-args.c b/clang/test/Driver/x-args.c --- a/clang/test/Driver/x-args.c +++ b/clang/test/Driver/x-args.c @@ -5,3 +5,7 @@ // RUN: %clang -fsyntax-only -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s // RUN: %clang -fsyntax-only %s -xc %s -xc++ -fsyntax-only 2>&1 | FileCheck %s // CHECK: '-x c++' after last input file has no effect +// +// RUN: %clang_cl /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | FileCheck -check-prefix=CL %s +// RUN: %clang_cl /WX /clang:-E /clang:-dM %s /clang:-xc 2>&1 | FileCheck -check-prefix=CL %s +// CL-NOT: '-x c' after last input file has no effect