diff options
-rw-r--r-- | Driver/clang.cpp | 6 | ||||
-rw-r--r-- | test/CodeGen/2008-07-17-no-emit-on-error.c | 10 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 5e8f51cbc9..cf3f9793d9 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -1285,6 +1285,12 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, ParseAST(PP, Consumer, Stats); } + // Don't emit code when the input had errors. + if (CodeGenModule && PP.getDiagnostics().hasErrorOccurred()) { + delete CodeGenModule; + CodeGenModule = 0; + } + // If running the code generator, finish up now. if (CodeGenModule) { std::ostream *Out; diff --git a/test/CodeGen/2008-07-17-no-emit-on-error.c b/test/CodeGen/2008-07-17-no-emit-on-error.c new file mode 100644 index 0000000000..5339695887 --- /dev/null +++ b/test/CodeGen/2008-07-17-no-emit-on-error.c @@ -0,0 +1,10 @@ +// RUN: rm -f %t1.bc +// RUN: ! clang %s -emit-llvm-bc -o %t1.bc +// RUN: ! test -f %t1.bc + +void f() { +} + +void g() { + *10; +} |