diff --git a/ispc.cpp b/ispc.cpp index a817d17e..4293b21b 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -510,6 +510,7 @@ Globals::Globals() { debugPrint = false; disableWarnings = false; warningsAsErrors = false; + quiet = false; disableLineWrap = false; emitPerfWarnings = true; emitInstrumentation = false; diff --git a/ispc.h b/ispc.h index 9ebfef53..856b988e 100644 --- a/ispc.h +++ b/ispc.h @@ -388,6 +388,9 @@ struct Globals { possible performance pitfalls. */ bool emitPerfWarnings; + /** Indicates whether all printed output should be surpressed. */ + bool quiet; + /** Indicates whether calls should be emitted in the program to an externally-defined program instrumentation function. (See the "Instrumenting your ispc programs" section in the user's diff --git a/main.cpp b/main.cpp index 7874aa81..4c05d044 100644 --- a/main.cpp +++ b/main.cpp @@ -129,6 +129,7 @@ usage(int ret) { #ifndef ISPC_IS_WINDOWS printf(" [--pic]\t\t\t\tGenerate position-independent code\n"); #endif // !ISPC_IS_WINDOWS + printf(" [--quiet]\t\t\t\tSuppress all output\n"); printf(" [--target=]\t\t\tSelect target ISA. ={%s}\n", Target::SupportedTargetISAs()); printf(" [--version]\t\t\t\tPrint ispc version\n"); printf(" [--werror]\t\t\t\tTreat warnings as errors\n"); @@ -383,6 +384,8 @@ int main(int Argc, char *Argv[]) { else if (!strcmp(argv[i], "--pic")) generatePIC = true; #endif // !ISPC_IS_WINDOWS + else if (!strcmp(argv[i], "--quiet")) + g->quiet = true; else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version")) { lPrintVersion(); return 0; diff --git a/parse.yy b/parse.yy index 52dd6809..95b22e00 100644 --- a/parse.yy +++ b/parse.yy @@ -91,7 +91,12 @@ extern int yylex(YYSTYPE *, SourcePos *); extern char *yytext; -void yyerror(const char *s) { fprintf(stderr, "Parse error: %s\n", s); } +void yyerror(const char *s) { + if (!g->quiet) { + ++m->errorCount; + fprintf(stderr, "Parse error: %s\n", s); + } +} static void lAddDeclaration(DeclSpecs *ds, Declarator *decl); static void lAddFunctionParams(Declarator *decl); diff --git a/util.cpp b/util.cpp index 9c802f19..b7976e64 100644 --- a/util.cpp +++ b/util.cpp @@ -265,17 +265,20 @@ lPrint(const char *type, SourcePos p, const char *fmt, va_list args) { void Error(SourcePos p, const char *fmt, ...) { + if (m != NULL) ++m->errorCount; + if (g->quiet) + return; + va_list args; va_start(args, fmt); lPrint("Error", p, fmt, args); - if (m != NULL) ++m->errorCount; va_end(args); } void Debug(SourcePos p, const char *fmt, ...) { - if (!g->debugPrint) + if (!g->debugPrint || g->quiet) return; va_list args; @@ -287,21 +290,23 @@ Debug(SourcePos p, const char *fmt, ...) { void Warning(SourcePos p, const char *fmt, ...) { - if (g->disableWarnings) + if (g->warningsAsErrors && m != NULL) + ++m->errorCount; + + if (g->disableWarnings || g->quiet) return; va_list args; va_start(args, fmt); lPrint(g->warningsAsErrors ? "Error" : "Warning", p, fmt, args); - if (g->warningsAsErrors && m != NULL) - ++m->errorCount; va_end(args); } void PerformanceWarning(SourcePos p, const char *fmt, ...) { - if (!g->emitPerfWarnings || strcmp(p.name, "stdlib.ispc") == 0) + if (!g->emitPerfWarnings || strcmp(p.name, "stdlib.ispc") == 0 || + g->quiet) return; va_list args;