Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -987,8 +987,8 @@ Arg *InputTypeArg = nullptr; // The last /TC or /TP option sets the input type to C or C++ globally. - if (Arg *TCTP = Args.getLastArg(options::OPT__SLASH_TC, - options::OPT__SLASH_TP)) { + if (Arg *TCTP = Args.getLastArgNoClaim(options::OPT__SLASH_TC, + options::OPT__SLASH_TP)) { InputTypeArg = TCTP; InputType = TCTP->getOption().matches(options::OPT__SLASH_TC) ? types::TY_C : types::TY_CXX; Index: test/Driver/cl-inputs.c =================================================================== --- test/Driver/cl-inputs.c +++ test/Driver/cl-inputs.c @@ -42,6 +42,16 @@ // TClib: warning: cl-test.lib: 'linker' input unused // TClib-NOT: cl-test.lib +// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib2 %s +// TPlib2: warning: cl-test.lib: 'linker' input unused +// TPlib2: warning: argument unused during compilation: '/TP' +// TPlib2-NOT: cl-test.lib + +// RUN: env LIB=%S/Inputs/cl-libs %clang_cl /c /TC cl-test.lib -### 2>&1 | FileCheck -check-prefix=TClib2 %s +// TClib2: warning: cl-test.lib: 'linker' input unused +// TClib2: warning: argument unused during compilation: '/TC' +// TClib2-NOT: cl-test.lib + // RUN: not %clang_cl - 2>&1 | FileCheck -check-prefix=STDIN %s // STDIN: error: use /Tc or /Tp