]> granicus.if.org Git - clang/commitdiff
[driver] In general, the driver claims redundant args and uses the last arg.
authorChad Rosier <mcrosier@apple.com>
Sat, 7 Apr 2012 00:01:31 +0000 (00:01 +0000)
committerChad Rosier <mcrosier@apple.com>
Sat, 7 Apr 2012 00:01:31 +0000 (00:01 +0000)
However, the '-x' option has special handling and wasn't following this
paradigm.  Fix it to do so by claiming the arg as we parse the '-x' option.
rdar://11203340

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154231 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
test/Driver/redundant-args.c [new file with mode: 0644]

index 35e63989a3c2b49463d38e4c718b9561149e9e46..7ab3278c7f67479560ea31a7bbde67c27df6eaca 100644 (file)
@@ -1003,6 +1003,7 @@ void Driver::BuildInputs(const ToolChain &TC, const DerivedArgList &Args,
     } else if (A->getOption().matches(options::OPT_x)) {
       InputTypeArg = A;
       InputType = types::lookupTypeForTypeSpecifier(A->getValue(Args));
+      A->claim();
 
       // Follow gcc behavior and treat as linker input for invalid -x
       // options. Its not clear why we shouldn't just revert to unknown; but
diff --git a/test/Driver/redundant-args.c b/test/Driver/redundant-args.c
new file mode 100644 (file)
index 0000000..7bf98e1
--- /dev/null
@@ -0,0 +1,2 @@
+// RUN: %clang -target x86_64-apple-darwin10 \
+// RUN:   -Werror -x c -x c -fsyntax-only %s