From: Rafael Espindola Date: Mon, 23 Sep 2013 23:55:25 +0000 (+0000) Subject: Produce errors for unknown options. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=06b52b41a98fff69c1c68baf24316eafd8d5a47b;p=clang Produce errors for unknown options. 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 --- diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index a2cf06a20c..1cbb623824 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -144,6 +144,11 @@ InputArgList *Driver::ParseArgStrings(ArrayRef 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; } diff --git a/test/Driver/unknown-arg.c b/test/Driver/unknown-arg.c index b254968c9b..f1cbbdbe8b 100644 --- a/test/Driver/unknown-arg.c +++ b/test/Driver/unknown-arg.c @@ -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