]> andersk Git - splint.git/blobdiff - src/llerror.c
Fixed bug in handling of sizeof
[splint.git] / src / llerror.c
index 4b82b318e9abe5b206af9e11a1502152a449682b..16ab4312970e39fe527dbf89f49d21957ac39cba 100644 (file)
 static void printIndentMessage (FILE *p_stream, /*@only@*/ cstring p_sc, int p_indent)
    /*@modifies *p_stream@*/ ;
 
-# ifndef NOLCL
 static int lclerrors = 0;
-# endif
-
 static size_t lastfileloclen = 10;
 static /*@only@*/ cstring lastmsg = cstring_undefined;
 static int mcount = 0;
@@ -118,7 +115,7 @@ void closeMessage (void)
       && context_getFlag (FLG_SHOWSCAN))
     {
       llflush ();
-      displayScanOpen (cstring_makeLiteral ("more preprocessing ."));
+      displayScanOpen (cstring_makeLiteral ("more preprocessing ."));
       llassertprotect (!s_needsPrepare);
       s_needsPrepare = TRUE;
     }
@@ -173,16 +170,7 @@ void llerror_flagWarning (cstring s)
 {
   if (context_getFlag (FLG_WARNFLAGS))
     {
-      showHerald ();
-
-      if (fileloc_isBuiltin (g_currentloc))
-       {
-         llmsg (message ("Warning: %q", s));
-       }
-      else
-       {
-         llgenmsg (message ("Warning: %q", s), g_currentloc);
-       }
+      llgenmsg (s, g_currentloc);
     }
   else
     {
@@ -674,7 +662,20 @@ llgentypeerroraux (char *srcFile, int srcLine,
     {
       if (!bool_equal (ctype_isSigned (ut1), ctype_isSigned (ut2)))
        {
-         hcode = FLG_IGNORESIGNS;
+         if (ctype_isArbitraryIntegral (ctype_realType (ut1))
+             && !ctype_isArbitraryIntegral (ctype_realType (ut2)))
+           {
+             hcode = FLG_MATCHANYINTEGRAL;
+           }
+         else if (ctype_isArbitraryIntegral (ctype_realType (ut2))
+                  && !ctype_isArbitraryIntegral (ctype_realType (ut1)))
+           {
+             hcode = FLG_MATCHANYINTEGRAL;
+           }
+         else
+           {
+             hcode = FLG_IGNORESIGNS;
+           }
        }
       else
        {
@@ -846,8 +847,17 @@ llgentypeerroraux (char *srcFile, int srcLine,
          if (hcode != INVALID_FLAG && hcode != ocode)
            {
              code = hcode;
-             llshowhint (code);
 
+             if (context_flagOn (code, fl))
+               {
+                 /* The flag is alreay set, something buggy in the flag code */
+                 llcontbug (message ("No hint available, flag %s is already set.",
+                                     flagcode_unparse (code)));
+               }
+             else
+               {
+                 llshowhint (code);
+               }
            }
          else
            {
@@ -1340,7 +1350,6 @@ xllfatalbug (char *srcFile, int srcLine, /*@only@*/ cstring s)
   llexit (LLFAILURE);
 }
 
-# ifndef NOLCL
 void
 lclfatalbug (char *msg)
 {
@@ -1351,7 +1360,6 @@ lclfatalbug (char *msg)
   printBugReport ();
   llexit (LLFAILURE);
 }
-# endif
 
 void
 checkParseError (void)
@@ -1435,7 +1443,6 @@ void llbugaux (cstring file, int line, /*@only@*/ cstring s)
   inbug = FALSE;
 }
 
-# ifndef NOLCL
 void
 lclbug (/*@only@*/ cstring s)
 {
@@ -1446,29 +1453,29 @@ lclbug (/*@only@*/ cstring s)
   fprintf (g_errorstream, "       (attempting to continue, results may be incorrect)\n");
   closeMessage ();
 }
-# endif
 
 void
-llfatalerror (cstring s)
+xllfatalerror (char *srcFile, int srcLine, cstring s)
 {
   prepareMessage ();
   printError (g_errorstream, s);
   printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue."));
+  showSourceLoc (srcFile, srcLine);
   llexit (LLFAILURE);
 }
 
 void
-llfatalerrorLoc (/*@only@*/ cstring s)
+xllfatalerrorLoc (char *srcFile, int srcLine, /*@only@*/ cstring s)
 {
   prepareMessage ();
   (void) fflush (g_warningstream);
   printError (g_errorstream, message ("%q: %q", fileloc_unparse (g_currentloc), s));
   printError (g_errorstream, cstring_makeLiteral ("*** Cannot continue."));
+  showSourceLoc (srcFile, srcLine);
   (void) fflush (g_warningstream);
   llexit (LLFAILURE);
 }
 
-# ifndef NOLCL
 bool
 lclHadError (void)
 {
@@ -1570,7 +1577,6 @@ lclRedeclarationError (ltoken id)
       lclerror (id, message ("Identifier redeclared: %s", s));
     }
 }
-# endif
 
 void genppllerror (flagcode code, /*@only@*/ cstring s)
 {
@@ -1802,7 +1808,7 @@ bool xllnoptgenerror (char *srcFile, int srcLine,
   return FALSE;
 }
 
-void llparseerror (cstring s)
+void xllparseerror (char *srcFile, int srcLine, cstring s)
 {
   if (context_getFlag (FLG_TRYTORECOVER))
     {
@@ -1812,14 +1818,16 @@ void llparseerror (cstring s)
        {
          if (cstring_isDefined (s))
            {
-             llfatalerror (message ("%q: Parse Error: %q.  "
-                                    "Too many errors, giving up.",
-                                    fileloc_unparse (g_currentloc), s));
+             xllfatalerror (srcFile, srcLine,
+                            message ("%q: Parse Error: %q.  "
+                                     "Too many errors, giving up.",
+                                     fileloc_unparse (g_currentloc), s));
            }
          else
            {
-             llfatalerror (message ("%q: Parse Error.  Too many errors, giving up.",
-                                    fileloc_unparse (g_currentloc)));
+             xllfatalerror (srcFile, srcLine,
+                            message ("%q: Parse Error.  Too many errors, giving up.",
+                                     fileloc_unparse (g_currentloc)));
            }
        }
       else
@@ -1828,10 +1836,12 @@ void llparseerror (cstring s)
            {
              llreportparseerror (message ("Parse Error: %q. Attempting to continue.",
                                           s));
+             showSourceLoc (srcFile, srcLine);
            }
          else
            {
              llreportparseerror (message ("Parse Error. Attempting to continue."));
+             showSourceLoc (srcFile, srcLine);
            }
        }
     }
@@ -1848,8 +1858,9 @@ void llparseerror (cstring s)
          msg = message ("Parse Error.");
        }
 
-      llfatalerror
-       (message ("%q: %s (For help on parse errors, "
+      xllfatalerror
+       (srcFile, srcLine,
+        message ("%q: %s (For help on parse errors, "
                  "see splint -help parseerrors.)",
                  fileloc_unparse (g_currentloc), msg));
     }
@@ -1947,10 +1958,16 @@ static bool s_scanOpen = FALSE;
 
 void displayScan (cstring msg)
 {
+  if (s_scanOpen)
+    {
+      displayScanClose ();
+    }
+
   llassert (!s_scanOpen);
 
   if (context_getFlag (FLG_SHOWSCAN))
     {
+      showHerald ();
       fprintf (g_messagestream, "< %s >\n", cstring_toCharsSafe (msg));
       (void) fflush (g_messagestream);
     }
@@ -1960,6 +1977,11 @@ void displayScan (cstring msg)
 
 void displayScanOpen (cstring msg)
 {
+  if (s_scanOpen)
+    {
+      displayScanClose ();
+    }
+
   llassert (!s_scanOpen);
   s_scanOpen = TRUE;
 
This page took 0.24122 seconds and 4 git commands to generate.