diff --git a/samples/main.cc b/samples/main.cc index 89567e342d..5346d7274f 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -642,13 +642,14 @@ int main(int argc, const char** argv) { if (program->Diagnostics().count() > 0) { diag_formatter.format(program->Diagnostics(), diag_printer.get()); } - if (!program->IsValid()) { - return 1; - } if (options.dump_ast) { std::cout << std::endl << program->to_str(options.demangle) << std::endl; } + + if (!program->IsValid()) { + return 1; + } if (options.parse_only) { return 1; }