]> granicus.if.org Git - clang/commitdiff
Produce errors for unknown options.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 23 Sep 2013 23:55:25 +0000 (23:55 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 23 Sep 2013 23:55:25 +0000 (23:55 +0000)
This doesn't change a lot since clang still thinks it knows all of the
-f*, -m* and -W* options for example.

Other than the options clang explicitly claims to know, this fixes pr9701.

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

lib/Driver/Driver.cpp
test/Driver/unknown-arg.c

index a2cf06a20cdc427f462b57be80ddf81d0e5b71d5..1cbb623824af9b81beaffbfbee451680e5397a8c 100644 (file)
@@ -144,6 +144,11 @@ InputArgList *Driver::ParseArgStrings(ArrayRef<const char *> ArgList) {
     }
   }
 
+  for (arg_iterator it = Args->filtered_begin(options::OPT_UNKNOWN),
+         ie = Args->filtered_end(); it != ie; ++it) {
+    Diags.Report(diag::err_drv_unknown_argument) << (*it) ->getAsString(*Args);
+  }
+
   return Args;
 }
 
index b254968c9b7d71255ede914cf6d6b7716bf66bae..f1cbbdbe8b02e4d46af581f71f8366423dbfb8d4 100644 (file)
@@ -1,9 +1,10 @@
-// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d 2> %t.log
-// RUN: FileCheck %s -input-file=%t.log
+// RUN: not %clang_cc1 %s -cake-is-lie -%0 -%d -HHHH 2>&1 | \
+// RUN: FileCheck %s
 
-// CHECK: unknown argument
-// CHECK: unknown argument
-// CHECK: unknown argument
+// CHECK: unknown argument: '-cake-is-lie'
+// CHECK: unknown argument: '-%0'
+// CHECK: unknown argument: '-%d'
+// CHECK: unknown argument: '-HHHH'
 
 
 // RUN: %clang -S %s -o %t.s -funknown-to-clang-option -Wunknown-to-clang-option -munknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s