* src/SDCCerr.c (vwerror, setWError),
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 14 Oct 2007 20:32:34 +0000 (20:32 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 14 Oct 2007 20:32:34 +0000 (20:32 +0000)
* src/SDCCerr.h,
* src/SDCCmain.c (parseCmdLine): added option --Werror to treat all
  warnings as errors, thanks Stas Sergeev for PATCH 1813211

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4932 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCerr.c
src/SDCCerr.h
src/SDCCmain.c

index 056ba649b3af838dcfeb479b66957883a08f5429..70b9eb997ed9974f2651203d880e24dfe5c75021 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
        * src/SDCCast.h: replaced AST_LIT_VALUE with AST_FLOAT_VALUE and
          AST_ULONG_VALUE
        * src/SDCCast.c (decorateType): improved optimization of tri-op
+       * src/SDCCerr.c (vwerror, setWError),
+       * src/SDCCerr.h,
+       * src/SDCCmain.c (parseCmdLine): added option --Werror to treat all
+         warnings as errors, thanks Stas Sergeev for PATCH 1813211
 
 2007-10-13 Maarten Brock <sourceforge.brock AT dse.nl>
 
index a20917f0b6c73e28e20e813274afdd582cf56a82..610f95080d95a4ac62f0efcea3035eb7996f96e6 100644 (file)
@@ -484,7 +484,7 @@ void vwerror (int errNum, va_list marker)
     }
 
     if ((ErrTab[errNum].errType >= _SDCCERRG.logLevel) && (!_SDCCERRG.disabled[errNum])) {
-        if ( ErrTab[errNum].errType == ERROR_LEVEL_ERROR )
+        if ( ErrTab[errNum].errType == ERROR_LEVEL_ERROR || _SDCCERRG.werror )
             fatalError++ ;
   
         if ( filename && lineno ) {
@@ -505,7 +505,10 @@ void vwerror (int errNum, va_list marker)
                 break;
             case ERROR_LEVEL_WARNING:
             case ERROR_LEVEL_PEDANTIC:
-                fprintf(_SDCCERRG.out, "warning %d: ", errNum);
+                if (_SDCCERRG.werror)
+                    fprintf(_SDCCERRG.out, "error %d: ", errNum);
+                else
+                    fprintf(_SDCCERRG.out, "warning %d: ", errNum);
                 break;
             case ERROR_LEVEL_INFO:
                 fprintf(_SDCCERRG.out, "info %d: ", errNum);
@@ -599,3 +602,14 @@ void setWarningDisabled (int errNum)
     if ((errNum < MAX_ERROR_WARNING) && (ErrTab[errNum].errType <= ERROR_LEVEL_WARNING))
         _SDCCERRG.disabled[errNum] = 1;
 }
+
+/*
+-------------------------------------------------------------------------------
+Set the flag to treat warnings as errors
+-------------------------------------------------------------------------------
+*/
+
+void setWError (int flag)
+{
+    _SDCCERRG.werror = flag;
+}
index e523cc7a4c81db729e0bb9dd2d1b4b4db476a125..3bccf1df1a7835186e5fcbc40b7b3ac75bb79331 100644 (file)
@@ -238,6 +238,7 @@ struct SDCCERRG {
     ERROR_LOG_LEVEL logLevel;
     FILE *out;
     int style;                        /* 1=MSVC */
+    int werror;                       /* treat the warnings as errors */
     char disabled[MAX_ERROR_WARNING]; /* 1=warning disabled*/
 };
 
@@ -310,4 +311,11 @@ disabled - Disable output of specified warning
 
 void setWarningDisabled (int errNum) ;
 
+/*
+-------------------------------------------------------------------------------
+Set the flag to treat warnings as errors
+-------------------------------------------------------------------------------
+*/
+void setWError (int flag);
+
 #endif
index e7d91fcd35063e361ffb1e621c529c5bd1749907..aa1e5e4636367e78bca44a73ba8d9da4a3db50e6 100644 (file)
@@ -120,6 +120,7 @@ char buffer[PATH_MAX * 2];
 #define OPTION_NO_LOOP_IND      "--noinduction"
 #define OPTION_LESS_PEDANTIC    "--less-pedantic"
 #define OPTION_DISABLE_WARNING  "--disable-warning"
+#define OPTION_WERROR           "--Werror"
 #define OPTION_NO_GCSE          "--nogcse"
 #define OPTION_SHORT_IS_8BITS   "--short-is-8bits"
 #define OPTION_NO_XINIT_OPT     "--no-xinit-opt"
@@ -167,6 +168,7 @@ optionsTable[] = {
     { 0,    "--nostdinc",           &options.nostdinc, "Do not include the standard include directory in the search path" },
     { 0,    OPTION_LESS_PEDANTIC,   NULL, "Disable some of the more pedantic warnings" },
     { 0,    OPTION_DISABLE_WARNING, NULL, "<nnnn> Disable specific warning" },
+    { 0,    OPTION_WERROR,          NULL, "Treat the warnings as errors" },
     { 0,    "--debug",              &options.debug, "Enable debugging symbol output" },
     { 0,    "--cyclomatic",         &options.cyclomatic, "Display complexity of compiled functions" },
     { 0,    OPTION_STD_C89,         NULL, "Use C89 standard only" },
@@ -1037,6 +1039,13 @@ parseCmdLine (int argc, char **argv)
               continue;
             }
 
+          if (strcmp (argv[i], OPTION_WERROR) == 0)
+            {
+              setWError(1);
+              addSet(&preArgvSet, Safe_strdup("-Werror"));
+              continue;
+            }
+
           if (strcmp (&argv[i][1], OPTION_SHORT_IS_8BITS) == 0)
             {
               options.shortis8bits=1;