/*
** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
** Massachusetts Institute of Technology
**
** This program is free software; you can redistribute it and/or modify it
** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
** MA 02111-1307, USA.
**
-** For information on splint: splint@cs.virginia.edu
-** To report a bug: splint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
** For more information: http://www.splint.org
*/
/*
# include <string.h>
# include "splintMacros.nf"
-# include "llbasic.h"
+# include "basic.h"
# include "cpplib.h"
# include "cpphash.h"
# include "cppexp.h"
static struct operation cppexp_lex (cppReader *);
static void integer_overflow (cppReader *);
-static long left_shift (cppReader *, long, bool p_unsignedp, size_t);
+static long left_shift (cppReader *, long, bool p_unsignedp, unsigned long);
static long right_shift (long, bool p_unsignedp, unsigned long);
/*@constant short CPPREADER_ERRORTOK@*/
for (i = 0; i < len; i++)
{
- /*drl bee: is*/ if (p[i] == '.') {
+ if (p[i] == '.') {
/* It's a float since it contains a point. */
cppReader_errorLit
(pfile,
}
else if (*p == '0')
{
- /*@i3434*/
- /* drl: see if there is a reason that we shouldn't do
- p++;
- len--; */
-
base = 8;
}
else
/*@innerbreak@*/ break;
}
- /*drl bee: ltc*/ c = *p++;
+ c = *p++;
}
/* Don't look for any more digits after the suffixes. */
break;
if (overflow)
{
- /*@i23 add flags for all these...*/
cppReader_pedwarnLit
(pfile,
cstring_makeLiteralTemp ("Integer constant out of range"));
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')
}
++ptr;
- /*drl bee: hda*/ while (ptr < tok_end && ((c = *ptr++) != '\''))
+ while (ptr < tok_end && ((c = *ptr++) != '\''))
{
if (c == '\\')
{
}
}
- /*drl bee: dad*/ token_buffer[num_chars] = 0;
+ token_buffer[num_chars] = 0;
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
{
{
for (toktab = tokentab2; toktab->operator != NULL; toktab++)
{
- /*drl bee: hda*/ if (tok_start[0] == /*drl bee: hda*/ toktab->operator[0]
- && /*drl bee: hda*/ tok_start[1] == /*drl bee: hda*/ toktab->operator[1])
+ if (tok_start[0] == toktab->operator[0] &&
+ tok_start[1] == toktab->operator[1])
{
/*@loopbreak@*/ break;
}
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;
int
cppReader_parseEscape (cppReader *pfile, char **string_ptr)
{
- /*drl bee: pbr*/ char c = *(*string_ptr)++;
+ char c = *(*string_ptr)++;
switch (c)
{
if (cppReader_isPedantic (pfile))
{
cppReader_pedwarn (pfile,
- message ("non-ANSI-standard escape sequence, `\\%c'", c));
+ message ("non-standard escape sequence, `\\%c'", c));
}
return (char) 033;
case 'f':
else
{
- /*drl bee: pbr*/ (*string_ptr)--;
+ (*string_ptr)--;
/*@loopbreak@*/ break;
}
}
}
static long
-left_shift (cppReader *pfile, long a, bool unsignedp, size_t b)
+left_shift (cppReader *pfile, long a, bool unsignedp, unsigned long b)
{
if (b >= HOST_BITS_PER_LONG)
{
}
else
{
- long l = int_toNonNegative (a) << b;
-
- if (int_toNonNegative (l) >> b != a)
+ /*@-shiftimplementation@*/
+ long l = a << b; /* int_toNonNegative removed (allow shifts of negative values) */
+
+# ifdef WIN32
+# pragma warning( disable : 4018 )
+# endif
+
+ if (l >> b != a) /* int_toNonNegative removed (allow shifts of negative values) */
{
integer_overflow (pfile);
}
else if (unsignedp)
return (unsigned long) a >> b;
else
- return int_toNonNegative (a) >> b;
+ return a >> b; /* int_toNonNegative removed (allow shifts of negative values) */
+ /*@=shiftimplementation@*/
}
/* These priorities are all even, so we can handle associatively. */
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;
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;
&& ((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);*/
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;
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;
if ((top->flags & HAVE_VALUE) != 0)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("syntax error"));
+ cstring_makeLiteralTemp ("syntax error"));
goto syntax_error;
}
top->value = ~ v2;
/*@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)
|| ((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
|| ((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
if (top != stack)
{
cppReader_errorLit (pfile,
- cstring_makeLiteralTemp ("internal error in #if expression"));
+ cstring_makeLiteralTemp ("internal error in #if expression"));
}
val = top->value;
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 = (size_t) (2 * old_size);
if (stack != init_stack)
{