Mercurial > projects > ldc
diff dmd/statement.c @ 1103:b30fe7e1dbb9
- Updated to DMD frontend 1.041.
- Removed dmd/inifile.c , it's not under a free license, replaced with libconfig based config file.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Thu, 12 Mar 2009 20:37:27 +0100 |
parents | 03d7c4aac654 |
children | e7f0c2b48047 |
line wrap: on
line diff
--- a/dmd/statement.c Thu Mar 12 14:08:57 2009 +0100 +++ b/dmd/statement.c Thu Mar 12 20:37:27 2009 +0100 @@ -1,6 +1,6 @@ // Compiler implementation of the D programming language -// Copyright (c) 1999-2008 by Digital Mars +// Copyright (c) 1999-2009 by Digital Mars // All Rights Reserved // written by Walter Bright // http://www.digitalmars.com @@ -12,7 +12,7 @@ #include <stdlib.h> #include <assert.h> -#include "mem.h" +#include "rmem.h" #include "statement.h" #include "expression.h" @@ -96,6 +96,18 @@ va_end( ap ); } +void Statement::warning(const char *format, ...) +{ + if (global.params.warnings && !global.gag) + { + fprintf(stdmsg, "warning - "); + va_list ap; + va_start(ap, format); + ::verror(loc, format, ap); + va_end( ap ); + } +} + int Statement::hasBreak() { //printf("Statement::hasBreak()\n"); @@ -539,10 +551,7 @@ //printf("%s\n", s->toChars()); if (!(result & BEfallthru) && !s->comeFrom()) { - if (global.params.warnings) - { fprintf(stdmsg, "warning - "); - s->error("statement is not reachable"); - } + s->warning("statement is not reachable"); } result &= ~BEfallthru; @@ -1029,9 +1038,11 @@ sc = sc->push(sym); if (init) init = init->semantic(sc); +#if 0 if (!condition) // Use a default value condition = new IntegerExp(loc, 1, Type::tboolean); +#endif sc->noctor++; if (condition) { @@ -1096,9 +1107,9 @@ result &= ~BEfallthru; // the body must do the exiting if (body) { int r = body->blockExit(); - if (r & BEbreak) + if (r & (BEbreak | BEgoto)) result |= BEfallthru; - result |= r & ~(BEbreak | BEcontinue); + result |= r & ~(BEfallthru | BEbreak | BEcontinue); } if (increment && increment->canThrow()) result |= BEthrow; @@ -1669,7 +1680,7 @@ default: assert(0); } const char *r = (op == TOKforeach_reverse) ? "R" : ""; - int j = sprintf(fdname, "_aApply%s%.*s%" PRIuSIZE, r, 2, fntab[flag], dim); + int j = sprintf(fdname, "_aApply%s%.*s%zu", r, 2, fntab[flag], dim); assert(j < sizeof(fdname)); //LDC: Build arguments. Arguments* args = new Arguments; @@ -2323,9 +2334,7 @@ if (!sc->sw->sdefault) { hasNoDefault = 1; - if (global.params.warnings) - { warning("%s: switch statement has no default", loc.toChars()); - } + warning("switch statement has no default"); // Generate runtime error if the default is hit Statements *a = new Statements(); @@ -3930,5 +3939,3 @@ { return this; } - -