Issue a warning if no output file is specified.

This commit is contained in:
Matt Pharr
2011-12-05 17:07:59 -08:00
parent 765d86076f
commit 9475e13d81
3 changed files with 15 additions and 3 deletions

View File

@@ -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;

View File

@@ -37,6 +37,7 @@
#include "ispc.h"
#include "module.h"
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
#include <llvm/Support/PrettyStackTrace.h>
@@ -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);
}

View File

@@ -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);
}