]> granicus.if.org Git - clang/commitdiff
Allow -MF to be used in combination with -E -M or -E -MM.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 26 Sep 2012 19:01:49 +0000 (19:01 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 26 Sep 2012 19:01:49 +0000 (19:01 +0000)
Fixes PR13851. Patch by Dimitry Andric!

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

lib/Driver/Tools.cpp
test/Preprocessor/pr13851.c [new file with mode: 0644]

index f77d8ee6f366357d2e98693729b8e38a31e5a019..12564b43f6c9c990c0ae7e01a91cdc11882d379e 100644 (file)
@@ -219,11 +219,11 @@ void Clang::AddPreprocessingOptions(Compilation &C,
       (A = Args.getLastArg(options::OPT_MMD))) {
     // Determine the output location.
     const char *DepFile;
-    if (Output.getType() == types::TY_Dependencies) {
-      DepFile = Output.getFilename();
-    } else if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
+    if (Arg *MF = Args.getLastArg(options::OPT_MF)) {
       DepFile = MF->getValue(Args);
       C.addFailureResultFile(DepFile);
+    } else if (Output.getType() == types::TY_Dependencies) {
+      DepFile = Output.getFilename();
     } else if (A->getOption().matches(options::OPT_M) ||
                A->getOption().matches(options::OPT_MM)) {
       DepFile = "-";
diff --git a/test/Preprocessor/pr13851.c b/test/Preprocessor/pr13851.c
new file mode 100644 (file)
index 0000000..537594d
--- /dev/null
@@ -0,0 +1,11 @@
+// Check that -E -M -MF does not cause an "argument unused" error, by adding
+// -Werror to the clang invocation.  Also check the dependency output, if any.
+// RUN: %clang -Werror -E -M -MF %t-M.d %s
+// RUN: FileCheck --input-file=%t-M.d %s
+// CHECK: pr13851.o:
+// CHECK: pr13851.c
+
+// Check that -E -MM -MF does not cause an "argument unused" error, by adding
+// -Werror to the clang invocation.  Also check the dependency output, if any.
+// RUN: %clang -Werror -E -MM -MF %t-MM.d %s
+// RUN: FileCheck --input-file=%t-MM.d %s