diff --git a/ispc.cpp b/ispc.cpp index d1821151..f74e7808 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -389,7 +389,13 @@ Globals::Globals() { // SourcePos SourcePos::SourcePos(const char *n, int fl, int fc, int ll, int lc) { - name = n ? n : m->module->getModuleIdentifier().c_str(); + name = n; + if (name == NULL) { + if (m != NULL) + name = m->module->getModuleIdentifier().c_str(); + else + name = "(unknown)"; + } first_line = fl; first_column = fc; last_line = ll != 0 ? ll : fl; diff --git a/main.cpp b/main.cpp index 459f1ea9..cd16c531 100644 --- a/main.cpp +++ b/main.cpp @@ -37,6 +37,7 @@ #include "ispc.h" #include "module.h" +#include "util.h" #include #include #include @@ -354,6 +355,11 @@ int main(int Argc, char *Argv[]) { if (debugSet && !optSet) g->opt.level = 0; + if (outFileName == NULL && headerFileName == NULL) + Warning(SourcePos(), "Warning: no output file or header file name " + "specified. Program will be compiled and warnings/errors will " + "be issued, but no output will be generated."); + return Module::CompileAndOutput(file, arch, cpu, target, generatePIC, ot, outFileName, headerFileName); } diff --git a/util.cpp b/util.cpp index ba1b8906..97606a5b 100644 --- a/util.cpp +++ b/util.cpp @@ -267,7 +267,7 @@ Error(SourcePos p, const char *fmt, ...) { va_list args; va_start(args, fmt); lPrint("Error", p, fmt, args); - ++m->errorCount; + if (m != NULL) ++m->errorCount; va_end(args); } @@ -292,7 +292,7 @@ Warning(SourcePos p, const char *fmt, ...) { va_list args; va_start(args, fmt); lPrint(g->warningsAsErrors ? "Error" : "Warning", p, fmt, args); - if (g->warningsAsErrors) + if (g->warningsAsErrors && m != NULL) ++m->errorCount; va_end(args); }