From 3f5b2a8fbd62d0add837534a9e2bc2c482a11098 Mon Sep 17 00:00:00 2001 From: uz Date: Sun, 28 Nov 2010 21:16:46 +0000 Subject: [PATCH] Allow to disable the "Result of comparison is constant" warning. git-svn-id: svn://svn.cc65.org/cc65/trunk@4883 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- doc/cc65.sgml | 4 ++++ src/cc65/error.c | 14 ++++++++------ src/cc65/error.h | 13 +++++++------ src/cc65/expr.c | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/doc/cc65.sgml b/doc/cc65.sgml index c5e450872..020109e4c 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -469,10 +469,14 @@ Here is a description of all the command line options: The following warning names are currently recognized: + + Warn if the result of a comparison is constant. Treat all warnings as errors. Warn about statements that don't have an effect. + + Warn when passing structs by value. Warn about known #pragmas. diff --git a/src/cc65/error.c b/src/cc65/error.c index bce570e34..1b4a04e85 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -64,12 +64,13 @@ unsigned WarningCount = 0; IntStack WarnEnable = INTSTACK(1); /* Enable warnings */ IntStack WarningsAreErrors = INTSTACK(0); /* Treat warnings as errors */ /* Warn about: */ -IntStack WarnNoEffect = INTSTACK(1); /* ... statements without an effect */ -IntStack WarnStructParam = INTSTACK(1); /* ... structs passed by val */ -IntStack WarnUnusedLabel = INTSTACK(1); /* ... unused labels */ -IntStack WarnUnusedParam = INTSTACK(1); /* ... unused parameters */ -IntStack WarnUnusedVar = INTSTACK(1); /* ... unused variables */ -IntStack WarnUnknownPragma = INTSTACK(1); /* ... unknown #pragmas */ +IntStack WarnConstComparison= INTSTACK(1); /* - constant comparison results */ +IntStack WarnNoEffect = INTSTACK(1); /* - statements without an effect */ +IntStack WarnStructParam = INTSTACK(1); /* - structs passed by val */ +IntStack WarnUnusedLabel = INTSTACK(1); /* - unused labels */ +IntStack WarnUnusedParam = INTSTACK(1); /* - unused parameters */ +IntStack WarnUnusedVar = INTSTACK(1); /* - unused variables */ +IntStack WarnUnknownPragma = INTSTACK(1); /* - unknown #pragmas */ /* Map the name of a warning to the intstack that holds its state */ typedef struct WarnMapEntry WarnMapEntry; @@ -80,6 +81,7 @@ struct WarnMapEntry { static WarnMapEntry WarnMap[] = { /* Keep sorted, even if this isn't used for now */ { &WarningsAreErrors, "error" }, + { &WarnConstComparison, "const-comparison" }, { &WarnNoEffect, "no-effect" }, { &WarnStructParam, "struct-param" }, { &WarnUnknownPragma, "unknown-pragma" }, diff --git a/src/cc65/error.h b/src/cc65/error.h index 3a4f9c053..ce8bacb51 100644 --- a/src/cc65/error.h +++ b/src/cc65/error.h @@ -61,12 +61,13 @@ extern unsigned WarningCount; extern IntStack WarnEnable; /* Enable warnings */ extern IntStack WarningsAreErrors; /* Treat warnings as errors */ /* Warn about: */ -extern IntStack WarnNoEffect; /* ... statements without an effect */ -extern IntStack WarnStructParam; /* ... structs passed by val */ -extern IntStack WarnUnusedLabel; /* ... unused labels */ -extern IntStack WarnUnusedParam; /* ... unused parameters */ -extern IntStack WarnUnusedVar; /* ... unused variables */ -extern IntStack WarnUnknownPragma; /* ... unknown #pragmas */ +extern IntStack WarnConstComparison; /* - constant comparison results */ +extern IntStack WarnNoEffect; /* - statements without an effect */ +extern IntStack WarnStructParam; /* - structs passed by val */ +extern IntStack WarnUnusedLabel; /* - unused labels */ +extern IntStack WarnUnusedParam; /* - unused parameters */ +extern IntStack WarnUnusedVar; /* - unused variables */ +extern IntStack WarnUnknownPragma; /* - unknown #pragmas */ diff --git a/src/cc65/expr.c b/src/cc65/expr.c index b0bc18d14..4e65e294c 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -261,7 +261,7 @@ static void WarnConstCompareResult (void) * preprocessor mode. */ { - if (!Preprocessing) { + if (!Preprocessing && IS_Get (&WarnConstComparison) != 0) { Warning ("Result of comparison is constant"); } } -- 2.39.5