]> andersk Git - splint.git/commitdiff
Added realrelatecompare flag.
authorevans1629 <evans1629>
Wed, 5 Nov 2003 14:42:41 +0000 (14:42 +0000)
committerevans1629 <evans1629>
Wed, 5 Nov 2003 14:42:41 +0000 (14:42 +0000)
src/context.c
src/cpplib.c
src/exprNode.c
src/flags.def
test/info.expect

index 0f1906b921bdf4f761bf2dbe48ac5e86f4f5b28e..f3e0290c96922c9c3df782fa3b8b074e07eb88b1 100644 (file)
@@ -850,7 +850,7 @@ context_resetAllFlags (void)
   gc.flags[FLG_NUMLITERAL] = TRUE;
   gc.flags[FLG_DUPLICATEQUALS] = TRUE;
   gc.flags[FLG_SKIPISOHEADERS] = TRUE;
-  gc.flags[FLG_SKIPPOSIXHEADERS] = TRUE;
+  gc.flags[FLG_SKIPPOSIXHEADERS] = FALSE;
   gc.flags[FLG_SYSTEMDIREXPAND] = TRUE;
   gc.flags[FLG_UNRECOGCOMMENTS] = TRUE;
   gc.flags[FLG_UNRECOGFLAGCOMMENTS] = TRUE;
@@ -1235,7 +1235,7 @@ context_setModeAux (cstring s, bool warn)
          FLG_CHECKSTRICTGLOBALS, FLG_IMPCHECKEDSPECGLOBALS,
           FLG_MACROMATCHNAME, FLG_WARNLINTCOMMENTS,
          FLG_INCLUDENEST, FLG_ISORESERVED, FLG_CPPNAMES, 
-         FLG_NOPARAMS, FLG_IFEMPTY, FLG_WHILEEMPTY, FLG_REALCOMPARE,
+         FLG_NOPARAMS, FLG_IFEMPTY, FLG_WHILEEMPTY, FLG_REALCOMPARE, FLG_REALRELATECOMPARE,
          FLG_BOOLOPS, FLG_SHIFTNEGATIVE,
          FLG_SHIFTIMPLEMENTATION,
          FLG_BUFFEROVERFLOWHIGH, FLG_BUFFEROVERFLOW,
@@ -1371,7 +1371,7 @@ context_setModeAux (cstring s, bool warn)
          FLG_FOREMPTY, FLG_WHILEEMPTY,
          FLG_IFEMPTY, FLG_IFBLOCK,
          FLG_ELSEIFCOMPLETE,
-         FLG_REALCOMPARE, FLG_BOOLOPS,
+         FLG_REALCOMPARE, FLG_BOOLOPS, FLG_REALRELATECOMPARE,
          FLG_SYSTEMDIRERRORS, FLG_UNUSEDSPECIAL,
 
          FLG_SHIFTNEGATIVE,
index 5aff1e99c75028d74ffe01e561487b3d32750459..4b4e1622b967d8918c902f724e5a1b2d7e85591b 100644 (file)
@@ -6210,6 +6210,8 @@ get_next:
                      if (cc == '\n')
                        {
                          /* Backslash newline is replaced by nothing at all.  */
+                         pfile->lineno++; /* 2003-11-03: AMiller suggested adding this, but
+                                             its not clear why it is needed. */
                          cppReader_adjustWritten (pfile, -1);
                          pfile->lineno++;
                        }
index dca9548f46e4e2a13587fa788639c142107c8e29..9ddccbee6ad38af9ed8181316dcdef88a62b2445 100644 (file)
@@ -5829,12 +5829,24 @@ exprNode_makeOp (/*@keep@*/ exprNode e1, /*@keep@*/ exprNode e2,
            }
          else
            {
-             voptgenerror
-               (FLG_REALCOMPARE,
-                message ("Dangerous comparison involving %s types: %s",
-                         ctype_unparse (rtype),
-                         exprNode_unparse (ret)),
-                ret->loc);
+             if (opid == EQ_OP || opid == NE_OP) 
+               {
+                 voptgenerror
+                   (FLG_REALCOMPARE,
+                    message ("Dangerous equality comparison involving %s types: %s",
+                             ctype_unparse (rtype),
+                             exprNode_unparse (ret)),
+                    ret->loc);
+               }
+             else
+               {
+                 voptgenerror
+                   (FLG_REALRELATECOMPARE,
+                    message ("Possibly dangerous relational comparison involving %s types: %s",
+                             ctype_unparse (rtype),
+                             exprNode_unparse (ret)),
+                    ret->loc);
+               }
            }
        }
       /*@fallthrough@*/
index e210f93ac3000b26b4a68d6ea9afe5f0a7d683f1..6b616e61f8c36dcc10bfae5b3b05963a94deb870 100644 (file)
@@ -248,10 +248,23 @@ static flaglist flags =
     FK_OPS, FK_NONE, modeFlag,
     "realcompare",
     FLG_REALCOMPARE,
-    "dangerous comparison between reals (dangerous because of inexact "
+    "dangerous equality comparison between reals (dangerous because of inexact "
     "floating point representations)",
     "Two real (float, double, or long double) values are compared "
-    "directly using a C primitive. "
+    "directly using == or != primitive. "
+    "This may produce unexpected results since floating point "
+    "representations are inexact. Instead, compare the difference to "
+    "FLT_EPSILON or DBL_EPSILON.",
+    0, 0,
+  },
+  {
+    FK_OPS, FK_NONE, modeFlag,
+    "realrelatecompare",
+    FLG_REALRELATECOMPARE,
+    "possibly dangerous relational comparison between reals (dangerous because of inexact "
+    "floating point representations)",
+    "Two real (float, double, or long double) values are compared "
+    "directly using < or >. "
     "This may produce unexpected results since floating point "
     "representations are inexact. Instead, compare the difference to "
     "FLT_EPSILON or DBL_EPSILON.",
index 31b8bbc57df5088748d3efbaa42eac5cfde06638..676c8b768b8b86c742d08eaabc2ad9e06d3c58b4 100644 (file)
@@ -4,8 +4,8 @@ info.c:3:3: Unrecognized identifier: i
 info.c:6:57: Unrecognized pre-processor directive:
                 #info "LcLint ignores all code that follows this line!"
 info.c: (in function unhuppy_bug)
-info.c:9:3: Observer storage assigned to unqualified reference: i = "Asdf"
-   info.c:9:7: Storage becomes observer
+info.c:10:3: Observer storage assigned to unqualified reference: i = "Asdf"
+   info.c:10:7: Storage becomes observer
 info.c:1:13: File static function huppy_bug declared but not used
    info.c:4:1: Definition of huppy_bug
 
This page took 0.086715 seconds and 5 git commands to generate.