Skip to content

Commit

Permalink
Remove redundant global.params.warnings checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Leandro Lucarella committed Oct 8, 2012
1 parent 9aea891 commit 8fcc1c2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
6 changes: 2 additions & 4 deletions src/doc.c
Expand Up @@ -432,8 +432,7 @@ void escapeStrayParenthesis(OutBuffer *buf, unsigned start, Loc loc)
if (par_open == 0)
{
//stray ')'
if (global.params.warnings)
warning(loc, "Ddoc: Stray ')'. This may cause incorrect Ddoc output."
warning(loc, "Ddoc: Stray ')'. This may cause incorrect Ddoc output."
" Use $(RPAREN) instead for unpaired right parentheses.");
buf->remove(u, 1); //remove the )
buf->insert(u, "$(RPAREN)", 9); //insert this instead
Expand Down Expand Up @@ -468,8 +467,7 @@ void escapeStrayParenthesis(OutBuffer *buf, unsigned start, Loc loc)
if (par_open == 0)
{
//stray '('
if (global.params.warnings)
warning(loc, "Ddoc: Stray '('. This may cause incorrect Ddoc output."
warning(loc, "Ddoc: Stray '('. This may cause incorrect Ddoc output."
" Use $(LPAREN) instead for unpaired left parentheses.");
buf->remove(u, 1); //remove the (
buf->insert(u, "$(LPAREN)", 9); //insert this instead
Expand Down
2 changes: 1 addition & 1 deletion src/expression.c
Expand Up @@ -5129,7 +5129,7 @@ Expression *VarExp::modifiableLvalue(Scope *sc, Expression *e)

#if (BUG6652 == 1)
VarDeclaration *v = var->isVarDeclaration();
if (v && (v->storage_class & STCbug6652) && global.params.warnings)
if (v && (v->storage_class & STCbug6652))
warning("Variable modified in foreach body requires ref storage class");
#elif (BUG6652 == 2)
VarDeclaration *v = var->isVarDeclaration();
Expand Down
4 changes: 1 addition & 3 deletions src/parse.c
Expand Up @@ -3754,9 +3754,7 @@ Statement *Parser::parseStatement(int flags)
if (!(flags & PSsemi_ok))
{
if (flags & PSsemi)
{ if (global.params.warnings)
warning(loc, "use '{ }' for an empty statement, not a ';'");
}
warning(loc, "use '{ }' for an empty statement, not a ';'");
else
error("use '{ }' for an empty statement, not a ';'");
}
Expand Down
3 changes: 1 addition & 2 deletions src/scope.c
Expand Up @@ -255,8 +255,7 @@ Dsymbol *Scope::search(Loc loc, Identifier *ident, Dsymbol **pscopesym)
s = sc->scopesym->search(loc, ident, 0);
if (s)
{
if ((global.params.warnings ||
global.params.Dversion > 1) &&
if (global.params.Dversion > 1 &&
ident == Id::length &&
sc->scopesym->isArrayScopeSymbol() &&
sc->enclosing &&
Expand Down
20 changes: 7 additions & 13 deletions src/typinf.c
Expand Up @@ -633,19 +633,13 @@ void TypeInfoStructDeclaration::toDt(dt_t **pdt)
dtxoff(pdt, fd->toSymbol(), 0, TYnptr);
TypeFunction *tf = (TypeFunction *)fd->type;
assert(tf->ty == Tfunction);
if (global.params.warnings)
{
/* I'm a little unsure this is the right way to do it. Perhaps a better
* way would to automatically add these attributes to any struct member
* function with the name "toHash".
* So I'm leaving this here as an experiment for the moment.
*/
if (!tf->isnothrow || tf->trust == TRUSTsystem /*|| tf->purity == PUREimpure*/)
{ warning(fd->loc, "toHash() must be declared as extern (D) uint toHash() const nothrow @safe, not %s", tf->toChars());
if (global.params.warnings == 1)
global.errors++;
}
}
/* I'm a little unsure this is the right way to do it. Perhaps a better
* way would to automatically add these attributes to any struct member
* function with the name "toHash".
* So I'm leaving this here as an experiment for the moment.
*/
if (!tf->isnothrow || tf->trust == TRUSTsystem /*|| tf->purity == PUREimpure*/)
warning(fd->loc, "toHash() must be declared as extern (D) uint toHash() const nothrow @safe, not %s", tf->toChars());
}
else
{
Expand Down

0 comments on commit 8fcc1c2

Please sign in to comment.