forked from OSchip/llvm-project
Reland "[clang][driver] Emit a warning if -xc/-xc++ is after the last input file"
This reverts commit ba59476515
.
This commit is contained in:
parent
34ce42fe4d
commit
e2a1f8ec27
clang
|
@ -365,6 +365,9 @@ def warn_drv_preprocessed_input_file_unused : Warning<
|
||||||
def warn_drv_unused_argument : Warning<
|
def warn_drv_unused_argument : Warning<
|
||||||
"argument unused during compilation: '%0'">,
|
"argument unused during compilation: '%0'">,
|
||||||
InGroup<UnusedCommandLineArgument>;
|
InGroup<UnusedCommandLineArgument>;
|
||||||
|
def warn_drv_unused_x : Warning<
|
||||||
|
"'-x %0' after last input file has no effect">,
|
||||||
|
InGroup<UnusedCommandLineArgument>;
|
||||||
def warn_drv_empty_joined_argument : Warning<
|
def warn_drv_empty_joined_argument : Warning<
|
||||||
"joined argument expects additional value: '%0'">,
|
"joined argument expects additional value: '%0'">,
|
||||||
InGroup<UnusedCommandLineArgument>;
|
InGroup<UnusedCommandLineArgument>;
|
||||||
|
|
|
@ -2308,6 +2308,14 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
|
||||||
assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
|
assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warn -x after last input file has no effect
|
||||||
|
{
|
||||||
|
Arg *LastXArg = Args.getLastArgNoClaim(options::OPT_x);
|
||||||
|
Arg *LastInputArg = Args.getLastArgNoClaim(options::OPT_INPUT);
|
||||||
|
if (LastXArg && LastInputArg && LastInputArg->getIndex() < LastXArg->getIndex())
|
||||||
|
Diag(clang::diag::warn_drv_unused_x) << LastXArg->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
for (Arg *A : Args) {
|
for (Arg *A : Args) {
|
||||||
if (A->getOption().getKind() == Option::InputClass) {
|
if (A->getOption().getKind() == Option::InputClass) {
|
||||||
const char *Value = A->getValue();
|
const char *Value = A->getValue();
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
// RUN: %clang -fsyntax-only -Werror -xc %s
|
||||||
|
// RUN: %clang -fsyntax-only -Werror %s -xc %s
|
||||||
|
|
||||||
|
// RUN: %clang -fsyntax-only %s -xc++ -fsyntax-only 2>&1 | FileCheck %s
|
||||||
|
// 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
|
Loading…
Reference in New Issue