]> andersk Git - splint.git/blobdiff - src/cppexp.c
Fixed but with multiple globals clauses reported by Gayath Ratnayaka.
[splint.git] / src / cppexp.c
index c19eb8bdb5a662e309e7ecd68fda2b703ab9065a..e79321e68b66f771d02b234855f540444b19b641 100644 (file)
@@ -434,7 +434,14 @@ struct operation cppexp_lex (cppReader *pfile)
   ic = cpplib_bufPeek (cppReader_getBufferSafe (pfile));
 
   c = (char) ic;
-  llassert (c != '#');
+
+  if  (c == '#') 
+    {
+      /* was: llassert (c != '#'); - Solaris uses this, attempt to continue anyway... */
+      cppReader_pedwarn (pfile, 
+                        message ("non-standard pre-processor directive: %c", c));
+    }
+
   DPRINTF (("Read: %c", c));
 
   if (c == '\n')
@@ -544,20 +551,20 @@ struct operation cppexp_lex (cppReader *pfile)
 
        if (c != '\'')
          cppReader_errorLit (pfile,
-                       cstring_makeLiteralTemp ("malformatted character constant"));
+                             cstring_makeLiteralTemp ("malformatted character constant"));
        else if (num_chars == 0)
          cppReader_errorLit (pfile, 
-                       cstring_makeLiteralTemp ("empty character constant"));
+                             cstring_makeLiteralTemp ("empty character constant"));
        else if (num_chars > max_chars)
          {
            num_chars = max_chars;
            cppReader_errorLit (pfile, 
-                         cstring_makeLiteralTemp ("character constant too long"));
+                               cstring_makeLiteralTemp ("character constant too long"));
          }
        else if (num_chars != 1 && ! cppReader_isTraditional (pfile))
          {
            cppReader_warningLit (pfile, 
-                           cstring_makeLiteralTemp ("multi-character character constant"));
+                                 cstring_makeLiteralTemp ("multi-character character constant"));
          }
        else
          {
@@ -631,7 +638,9 @@ struct operation cppexp_lex (cppReader *pfile)
 
          if (toktab->token == CPPREADER_ERRORTOK)
            {
-             cppReader_error (pfile, message ("`%s' not allowed in operand of `#if'", cstring_fromChars (tok_start)));
+             cppReader_error (pfile, 
+                              message ("`%s' not allowed in operand of `#if'",
+                                       cstring_fromChars (tok_start)));
            }
 
          op.op = toktab->token; 
@@ -990,7 +999,7 @@ cppReader_parseExpression (cppReader *pfile)
       if ((top->flags & HAVE_VALUE) != 0)
        {
          cppReader_errorLit (pfile, 
-                       cstring_makeLiteralTemp ("syntax error in #if"));
+                             cstring_makeLiteralTemp ("syntax error in #if"));
          goto syntax_error;
        }
       top->flags |= HAVE_VALUE;
@@ -1001,7 +1010,8 @@ cppReader_parseExpression (cppReader *pfile)
       while (top->rprio > lprio)
        {
          /*@-usedef@*/
-         long v1 = top[-1].value, v2 = top[0].value;
+         HOST_WIDE_INT v1 = top[-1].value;
+         HOST_WIDE_INT v2 = top[0].value;
          bool unsigned1 = top[-1].unsignedp;
          bool unsigned2 = top[0].unsignedp;
 
@@ -1011,14 +1021,14 @@ cppReader_parseExpression (cppReader *pfile)
              && ((top[0].flags & HAVE_VALUE) == 0))
            {
              cppReader_errorLit (pfile, 
-                           cstring_makeLiteralTemp ("syntax error - missing left operand"));
+                                 cstring_makeLiteralTemp ("syntax error - missing left operand"));
              goto syntax_error;
            }
          if (((top[1].flags & RIGHT_OPERAND_REQUIRED) != 0)
              && ((top[1].flags & HAVE_VALUE) == 0))
            {
              cppReader_errorLit (pfile, 
-                           cstring_makeLiteralTemp ("syntax error - missing right operand"));
+                                 cstring_makeLiteralTemp ("syntax error - missing right operand"));
              goto syntax_error;
            }
          /* top[0].value = (top[1].op)(v1, v2);*/
@@ -1090,7 +1100,7 @@ cppReader_parseExpression (cppReader *pfile)
              if (v2 == 0)
                {
                  cppReader_errorLit (pfile, 
-                               cstring_makeLiteralTemp ("Division by zero in #if"));
+                                     cstring_makeLiteralTemp ("Division by zero in #if"));
                  v2 = 1;
                }
              top->unsignedp = unsigned1 || unsigned2;
@@ -1109,7 +1119,7 @@ cppReader_parseExpression (cppReader *pfile)
              if (v2 == 0)
                {
                  cppReader_errorLit (pfile, 
-                               cstring_makeLiteralTemp ("Division by zero in #if"));
+                                     cstring_makeLiteralTemp ("Division by zero in #if"));
                  v2 = 1;
                }
              top->unsignedp = unsigned1 || unsigned2;
@@ -1134,7 +1144,7 @@ cppReader_parseExpression (cppReader *pfile)
              if ((top->flags & HAVE_VALUE) != 0)
                {
                  cppReader_errorLit (pfile, 
-                               cstring_makeLiteralTemp ("syntax error"));
+                                     cstring_makeLiteralTemp ("syntax error"));
                  goto syntax_error;
                }
              top->value = ~ v2;
@@ -1211,13 +1221,13 @@ cppReader_parseExpression (cppReader *pfile)
              /*@switchbreak@*/ break;
            case '(':  case '?':
              cppReader_errorLit (pfile, 
-                           cstring_makeLiteralTemp ("syntax error in #if"));
+                                 cstring_makeLiteralTemp ("syntax error in #if"));
              goto syntax_error;
            case ':':
              if (top[0].op != '?')
                {
                  cppReader_errorLit (pfile,
-                               cstring_makeLiteralTemp ("syntax error ':' without preceding '?'"));
+                                     cstring_makeLiteralTemp ("syntax error ':' without preceding '?'"));
                  goto syntax_error;
                }
              else if (((top[1].flags & HAVE_VALUE) == 0)
@@ -1225,7 +1235,7 @@ cppReader_parseExpression (cppReader *pfile)
                       || ((top[0].flags & HAVE_VALUE) == 0))
                {
                  cppReader_errorLit (pfile, 
-                               cstring_makeLiteralTemp ("bad syntax for ?: operator"));
+                                     cstring_makeLiteralTemp ("bad syntax for ?: operator"));
                  goto syntax_error;
                }
              else
@@ -1247,7 +1257,7 @@ cppReader_parseExpression (cppReader *pfile)
                  || ((top[-1].flags & HAVE_VALUE) != 0))
                {
                  cppReader_errorLit (pfile, 
-                               cstring_makeLiteralTemp ("mismatched parentheses in #if"));
+                                     cstring_makeLiteralTemp ("mismatched parentheses in #if"));
                  goto syntax_error;
                }
              else
@@ -1275,7 +1285,7 @@ cppReader_parseExpression (cppReader *pfile)
          if (top != stack)
            {
              cppReader_errorLit (pfile, 
-                           cstring_makeLiteralTemp ("internal error in #if expression"));
+                                 cstring_makeLiteralTemp ("internal error in #if expression"));
            }
 
          val = top->value;
@@ -1294,8 +1304,8 @@ cppReader_parseExpression (cppReader *pfile)
       if (top == limit)
        {
          struct operation *new_stack;
-         int old_size = (char *) limit - (char *) stack;
-         size_t new_size = size_fromInt (2 * old_size);
+         size_t old_size = size_fromInt ((char *) limit - (char *) stack);
+         size_t new_size = 2 * old_size;
 
          if (stack != init_stack)
            {
This page took 0.08307 seconds and 4 git commands to generate.