Mercurial > projects > ldc
changeset 1586:7f728c52e63c
Fix several 'reaches end of function' warnings by making fatal noreturn.
The warnings also pointed out a few genuine bugs. Replace some tabs with
spaces.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Fri, 06 Nov 2009 21:51:41 +0100 |
parents | 29b0f2d11c92 |
children | def7a1d494fd |
files | dmd/mars.h gen/complex.cpp gen/irstate.cpp gen/linker.cpp gen/main.cpp |
diffstat | 5 files changed, 31 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/mars.h Thu Oct 22 13:30:30 2009 +0200 +++ b/dmd/mars.h Fri Nov 06 21:51:41 2009 +0100 @@ -412,7 +412,12 @@ void vwarning(Loc loc, const char *format, va_list); void error(Loc loc, const char *format, ...) IS_PRINTF(2); void verror(Loc loc, const char *format, va_list); + +#ifdef __GNUC__ +__attribute__((noreturn)) +#endif void fatal(); + void err_nomem(); void inifile(char *argv0, const char *inifile); void halt();
--- a/gen/complex.cpp Thu Oct 22 13:30:30 2009 +0200 +++ b/gen/complex.cpp Fri Nov 06 21:51:41 2009 +0100 @@ -456,7 +456,9 @@ DImValue* re = new DImValue(extractty, repart); return DtoCastFloat(loc, re, to); } - else + else { error(loc, "Don't know how to cast %s to %s", vty->toChars(), to->toChars()); + fatal(); + } }
--- a/gen/irstate.cpp Thu Oct 22 13:30:30 2009 +0200 +++ b/gen/irstate.cpp Fri Nov 06 21:51:41 2009 +0100 @@ -39,6 +39,7 @@ begin = rhs.begin; end = rhs.end; builder.SetInsertPoint(begin); + return *this; } //////////////////////////////////////////////////////////////////////////////////////////
--- a/gen/linker.cpp Thu Oct 22 13:30:30 2009 +0200 +++ b/gen/linker.cpp Fri Nov 06 21:51:41 2009 +0100 @@ -100,13 +100,13 @@ exedir.set(gExePath.getDirname()); if (!exedir.exists()) { - exedir.createDirectoryOnDisk(true, &errstr); - if (!errstr.empty()) - { - error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); - fatal(); - } - } + exedir.createDirectoryOnDisk(true, &errstr); + if (!errstr.empty()) + { + error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); + fatal(); + } + } // strip debug info if (!global.params.symdebug) @@ -204,8 +204,10 @@ error("linking failed:\nstatus: %d", status); if (!errstr.empty()) error("message: %s", errstr.c_str()); - fatal(); + return status; } + + return 0; } ////////////////////////////////////////////////////////////////////////////// @@ -266,13 +268,13 @@ exedir.set(gExePath.getDirname()); if (!exedir.exists()) { - exedir.createDirectoryOnDisk(true, &errstr); - if (!errstr.empty()) - { - error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); - fatal(); - } - } + exedir.createDirectoryOnDisk(true, &errstr); + if (!errstr.empty()) + { + error("failed to create path to linking output: %s\n%s", exedir.c_str(), errstr.c_str()); + fatal(); + } + } // additional linker switches for (int i = 0; i < global.params.linkswitches->dim; i++) @@ -339,14 +341,16 @@ // terminate args list args.push_back(NULL); - // try to call linker!!! + // try to call linker if (int status = llvm::sys::Program::ExecuteAndWait(gcc, &args[0], NULL, NULL, 0,0, &errstr)) { error("linking failed:\nstatus: %d", status); if (!errstr.empty()) error("message: %s", errstr.c_str()); - fatal(); + return status; } + + return 0; } //////////////////////////////////////////////////////////////////////////////