diff --git a/test/Driver/unknown-arg.c b/test/Driver/unknown-arg.c new file mode 100644 index 0000000000..5d0f7afc51 --- /dev/null +++ b/test/Driver/unknown-arg.c @@ -0,0 +1,4 @@ +// RUN: not %clang_cc1 %s -cake-is-lie 2> %t.log +// RUN: FileCheck %s -input-file=%t.log + +// CHECK: unknown argument diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index 0a14fdd315..ad3f3502ec 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -140,8 +140,6 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd, bool Success; Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(), ArgBegin, ArgEnd, Diags); - if (!Success) - return 1; // Infer the builtin include path if unspecified. if (Clang->getHeaderSearchOpts().UseBuiltinIncludes && @@ -160,6 +158,8 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd, static_cast(&Clang->getDiagnostics())); DiagsBuffer->FlushDiagnostics(Clang->getDiagnostics()); + if (!Success) + return 1; // Execute the frontend actions. Success = ExecuteCompilerInvocation(Clang.get());