Add --werror flag to treat warnings as errors.
The specific need for it was so that tests in tests_errors can test to see if a desired diagnostic warning is issued (like ptrcast-lose-info does.)
This commit is contained in:
1
ispc.cpp
1
ispc.cpp
@@ -341,6 +341,7 @@ Globals::Globals() {
|
|||||||
runCPP = true;
|
runCPP = true;
|
||||||
debugPrint = false;
|
debugPrint = false;
|
||||||
disableWarnings = false;
|
disableWarnings = false;
|
||||||
|
warningsAsErrors = false;
|
||||||
disableLineWrap = false;
|
disableLineWrap = false;
|
||||||
emitPerfWarnings = true;
|
emitPerfWarnings = true;
|
||||||
emitInstrumentation = false;
|
emitInstrumentation = false;
|
||||||
|
|||||||
3
ispc.h
3
ispc.h
@@ -348,6 +348,9 @@ struct Globals {
|
|||||||
/** Indicates whether all warning messages should be surpressed. */
|
/** Indicates whether all warning messages should be surpressed. */
|
||||||
bool disableWarnings;
|
bool disableWarnings;
|
||||||
|
|
||||||
|
/** Indicates whether warnings should be issued as errors. */
|
||||||
|
bool warningsAsErrors;
|
||||||
|
|
||||||
/** Indicates whether line wrapping of error messages to the terminal
|
/** Indicates whether line wrapping of error messages to the terminal
|
||||||
width should be disabled. */
|
width should be disabled. */
|
||||||
bool disableLineWrap;
|
bool disableLineWrap;
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@@ -104,6 +104,7 @@ static void usage(int ret) {
|
|||||||
#endif // !ISPC_IS_WINDOWS
|
#endif // !ISPC_IS_WINDOWS
|
||||||
printf(" [--target=<isa>]\t\t\tSelect target ISA. <isa>={%s}\n", Target::SupportedTargetISAs());
|
printf(" [--target=<isa>]\t\t\tSelect target ISA. <isa>={%s}\n", Target::SupportedTargetISAs());
|
||||||
printf(" [--version]\t\t\t\tPrint ispc version\n");
|
printf(" [--version]\t\t\t\tPrint ispc version\n");
|
||||||
|
printf(" [--werror]\t\t\tTreat warnings as errors\n");
|
||||||
printf(" [--woff]\t\t\t\tDisable warnings\n");
|
printf(" [--woff]\t\t\t\tDisable warnings\n");
|
||||||
printf(" [--wno-perf]\t\t\tDon't issue warnings related to performance-related issues\n");
|
printf(" [--wno-perf]\t\t\tDon't issue warnings related to performance-related issues\n");
|
||||||
printf(" <file to compile or \"-\" for stdin>\n");
|
printf(" <file to compile or \"-\" for stdin>\n");
|
||||||
@@ -283,6 +284,8 @@ int main(int Argc, char *Argv[]) {
|
|||||||
g->disableWarnings = true;
|
g->disableWarnings = true;
|
||||||
g->emitPerfWarnings = false;
|
g->emitPerfWarnings = false;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[i], "--werror"))
|
||||||
|
g->warningsAsErrors = true;
|
||||||
else if (!strcmp(argv[i], "--nowrap"))
|
else if (!strcmp(argv[i], "--nowrap"))
|
||||||
g->disableLineWrap = true;
|
g->disableLineWrap = true;
|
||||||
else if (!strcmp(argv[i], "--wno-perf") || !strcmp(argv[i], "-wno-perf"))
|
else if (!strcmp(argv[i], "--wno-perf") || !strcmp(argv[i], "-wno-perf"))
|
||||||
|
|||||||
@@ -107,8 +107,8 @@ def run_tasks_from_queue(queue):
|
|||||||
# is this a test to make sure an error is issued?
|
# is this a test to make sure an error is issued?
|
||||||
want_error = (filename.find("tests_errors") != -1)
|
want_error = (filename.find("tests_errors") != -1)
|
||||||
if want_error == True:
|
if want_error == True:
|
||||||
ispc_cmd = "ispc --nowrap %s --arch=%s --target=%s" % \
|
ispc_cmd = "ispc --werror --nowrap %s --arch=%s --target=%s" % \
|
||||||
( filename, options.arch, options.target)
|
(filename, options.arch, options.target)
|
||||||
sp = subprocess.Popen(shlex.split(ispc_cmd), stdin=None, stdout=subprocess.PIPE,
|
sp = subprocess.Popen(shlex.split(ispc_cmd), stdin=None, stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
output = sp.communicate()[1]
|
output = sp.communicate()[1]
|
||||||
|
|||||||
4
util.cpp
4
util.cpp
@@ -291,7 +291,9 @@ Warning(SourcePos p, const char *fmt, ...) {
|
|||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
lPrint("Warning", p, fmt, args);
|
lPrint(g->warningsAsErrors ? "Error" : "Warning", p, fmt, args);
|
||||||
|
if (g->warningsAsErrors)
|
||||||
|
++m->errorCount;
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user