]> git.sur5r.net Git - cc65/commitdiff
Make the warning "statement has no effect" switchable.
authoruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 2 Oct 2010 19:32:11 +0000 (19:32 +0000)
committeruz <uz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 2 Oct 2010 19:32:11 +0000 (19:32 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@4823 b7a2c559-68d2-44c3-8de9-860c34a00d81

doc/cc65.sgml
src/cc65/error.c
src/cc65/error.h
src/cc65/pragma.c
src/cc65/stmt.c

index 50236231c6f2ca5be4f65429ee63b553234ee260..c5e45087216bbc6dc21973488dc275c0ab3bc2c3 100644 (file)
@@ -471,6 +471,8 @@ Here is a description of all the command line options:
   <descrip>
   <tag><tt/error/</tag>
         Treat all warnings as errors.
+  <tag><tt/no-effect/</tag>
+        Warn about statements that don't have an effect.
   <tag><tt/unknown-pragma/</tag>
         Warn about known #pragmas.
   <tag><tt/unused-label/</tag>
index f73f0a4a0c24dbde36d2b65de714936ed1837d29..bce570e34780c3033ac6f193f82178fd51067347 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -63,11 +63,13 @@ unsigned WarningCount       = 0;
 /* Warning and error options */
 IntStack WarnEnable         = INTSTACK(1);  /* Enable warnings */
 IntStack WarningsAreErrors  = INTSTACK(0);  /* Treat warnings as errors */
-IntStack WarnStructParam    = INTSTACK(1);  /* Warn about structs passed by val */
-IntStack WarnUnusedLabel    = INTSTACK(1);  /* Warn about unused labels */
-IntStack WarnUnusedParam    = INTSTACK(1);  /* Warn about unused parameters */
-IntStack WarnUnusedVar      = INTSTACK(1);  /* Warn about unused variables */
-IntStack WarnUnknownPragma  = INTSTACK(1);  /* Warn about unknown #pragmas */
+                                            /* 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 */
 
 /* Map the name of a warning to the intstack that holds its state */
 typedef struct WarnMapEntry WarnMapEntry;
@@ -78,6 +80,7 @@ struct WarnMapEntry {
 static WarnMapEntry WarnMap[] = {
     /* Keep sorted, even if this isn't used for now */
     { &WarningsAreErrors,       "error"                 },
+    { &WarnNoEffect,            "no-effect"             },
     { &WarnStructParam,         "struct-param"          },
     { &WarnUnknownPragma,       "unknown-pragma"        },
     { &WarnUnusedLabel,         "unused-label"          },
index ad66a150650b2a5e7097b81df3e2b40813e45b29..3a4f9c053376e41347a407409e2431991c17ea8b 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -60,11 +60,13 @@ extern unsigned WarningCount;
 /* Warning and error options */
 extern IntStack WarnEnable;             /* Enable warnings */
 extern IntStack WarningsAreErrors;      /* Treat warnings as errors */
-extern IntStack WarnStructParam;        /* Warn about structs passed by val */
-extern IntStack WarnUnusedLabel;        /* Warn about unused labels */
-extern IntStack WarnUnusedParam;        /* Warn about unused parameters */
-extern IntStack WarnUnusedVar;          /* Warn about unused variables */
-extern IntStack WarnUnknownPragma;      /* Warn about unknown #pragmas */
+                                        /* 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 */
 
 
 
index 608ef7e6d03db81ab588ea64c6453f8c07faa9b4..2a4e1085a9909d6355a5160f2f75293b0c4fb108 100644 (file)
@@ -238,7 +238,7 @@ static IntStack* GetWarning (StrBuf* B)
 
     /* Done */
     return S;
-}
+}                
 
 
 
@@ -490,7 +490,7 @@ static void WarnPragma (StrBuf* B)
     int    Push;
 
     /* A warning name must follow */
-    IntStack* S =GetWarning (B);
+    IntStack* S = GetWarning (B);
     if (S == 0) {
         return;
     }
index 5078bfa11a1d32c4076e304247fd1b2d1bcde8cb..5bc4df4a9bf52e8834b6a756437f56d3f4010d11 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2009, Ullrich von Bassewitz                                      */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -653,7 +653,9 @@ int Statement (int* PendingToken)
              * void, emit a warning.
              */
             GetCodePos (&End);
-            if (CodeRangeIsEmpty (&Start, &End) && !IsTypeVoid (Expr.Type)) {
+            if (CodeRangeIsEmpty (&Start, &End) && 
+                !IsTypeVoid (Expr.Type)         &&
+                IS_Get (&WarnNoEffect)) {
                 Warning ("Statement has no effect");
             }
             CheckSemi (PendingToken);