]> andersk Git - splint.git/commitdiff
Fixed handling of octal constants.
authorevans1629 <evans1629>
Sun, 7 Oct 2001 04:43:17 +0000 (04:43 +0000)
committerevans1629 <evans1629>
Sun, 7 Oct 2001 04:43:17 +0000 (04:43 +0000)
src/Makefile
src/context.c
src/cpplib.c
src/cscanner.l
src/flags.c
src/llmain.c
test/Makefile
test/longconstants.c [new file with mode: 0644]
test/longconstants.expect [new file with mode: 0644]

index 4fe367cebfc2152018c81c8dbb9e728aaa670380..af7f0af7f986ff179752d6cb9e39c5f2f2dc8780 100644 (file)
@@ -203,9 +203,12 @@ stateClause.c: Headers/cgrammar_tokens.h
 ifeq ($(CHECK), 1)
        ${MAKE} $*.check
 endif
-       @echo '//  Compiling '$*.c' / compiled: '`$(OFILES)`'  (of 181 files)'
        $(CC) $(CPPFLAGS) $(CFLAGS) -c $*.c
 
+### removed this: / compiled: '`$(OFILES)`'  (of 181 files)'
+### Apparently it is slow on some platforms...
+
+
 ###
 ### alternatives (tests, releases, backups, etc.)
 ###
@@ -245,9 +248,9 @@ betarelease:
        cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; rm -r test/temp
        cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; rm -f *~ */*~ */*/*~ #* */#* */*/#* .#* */.#* */*/.#* */*.core
        cd ~/temp/lclint-`cat ${VERSION_NUMBER}`; rm -rf CVS */CVS */*/CVS */*/*/CVS */*/*/*/CVS
-       cd ~/temp/; tar czvf ~/public_html/lclint/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`
-       chmod 644 ~/public_html/lclint/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz
-       ls -l ~/public_html/lclint/lclint-*.tgz
+       cd ~/temp/; tar czvf ~/public_html/lclint/downloads/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`
+       chmod 644 ~/public_html/lclint/downloads/lclint-`cat ${SRCPWD}/${VERSION_NUMBER}`.src.tgz
+       ls -l ~/public_html/lclint/downloads/lclint-*.tgz
        @echo "Made release lclint-`cat ${VERSION_NUMBER}`"
 
 opt :
index 4344a3f006286512456044fe2dc9aaa36d806c31..b4fc25f8bd2fa7aa5dba76005a8742bbc5ff9ae7 100644 (file)
@@ -2847,7 +2847,7 @@ context_setString (flagcode flag, cstring val)
     }
 
   if (cstring_length (val) >= 1
-      && cstring_firstChar (val) == '"')
+      && cstring_firstChar (val) == '\"')
     {
       llerror_flagWarning (message
                       ("setting %s to string beginning with \".  You probably "
index ba7dada7782e6c6aa274e6d75188ecdb0ab9dd78..499b9af72b38e1bb0afdc75ab224923026d9683a 100644 (file)
@@ -1635,7 +1635,7 @@ collect_expansion (cppReader *pfile, char *buf, char *limit,
          exp_p--;
          SKIP_WHITE_SPACE (p);
          if (p == limit || ! is_idstart[(int) *p]
-             || (*p == 'L' && p + 1 < limit && (p[1] == '\'' || p[1] == '"')))
+             || (*p == 'L' && p + 1 < limit && (p[1] == '\'' || p[1] == '\"')))
            cppReader_errorLit (pfile,
                          cstring_makeLiteralTemp ("`#' operator is not followed by a macro argument name"));
          else
@@ -1702,7 +1702,7 @@ collect_expansion (cppReader *pfile, char *buf, char *limit,
       id_len = p - id_beg;
 
       if (is_idstart[(int) c]
-         && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '"'))) {
+         && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '\"'))) {
        register struct arglist *arg;
 
        for (arg = arglist; arg != NULL; arg = arg->next) {
@@ -1992,7 +1992,7 @@ create_definition (/*@exposed@*/ char *buf, char *limit,
          SKIP_WHITE_SPACE (bp);
        } else {
          switch (*bp) {
-         case '!':  case '"':  case '#':  case '%':  case '&':  case '\'':
+         case '!':  case '\"':  case '#':  case '%':  case '&':  case '\'':
          case ')':  case '*':  case '+':  case ',':  case '-':  case '.':
          case '/':  case ':':  case ';':  case '<':  case '=':  case '>':
          case '?':  case '[':  case '\\': case ']':  case '^':  case '{':
@@ -2057,7 +2057,7 @@ int cppReader_checkMacroName (cppReader *pfile,
   sym_length = size_fromInt (p - symname);
 
   if (sym_length == 0
-      || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
+      || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '\"')))
     cppReader_error (pfile, message ("invalid %s name", usage));
   else if (!is_idstart[(int) *symname])
     {
@@ -2933,7 +2933,7 @@ special_symbol (hashNode hp, cppReader *pfile)
 
       if (!is_idstart[(int) *ip->cur])
        goto oops;
-      if (ip->cur[0] == 'L' && (ip->cur[1] == '\'' || ip->cur[1] == '"'))
+      if (ip->cur[0] == 'L' && (ip->cur[1] == '\'' || ip->cur[1] == '\"'))
        goto oops;
 
       if ((hp = cppReader_lookup (ip->cur, -1, -1)) != 0)
index d87930ecb494a35107d98029161a777d1f2890ea..6930ccdd31507fbd9e5c4e22c81937c68b436633 100644 (file)
@@ -2983,6 +2983,22 @@ long processOctal ()
     
     if (c >= '0' && c <= '7') {
       tval = (int) c - (int) '0';
+    } else if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
+      index++;
+      while (yytext[index] != '\0') {
+       if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
+         ;
+       } else {
+         voptgenerror
+           (FLG_SYNTAX, 
+            message ("Invalid character (%c) following specifier in octal constant: %s",
+                     c, cstring_fromChars (yytext)),
+            g_currentloc);
+       }
+       index++;
+      }
+
+      break;
     } else {
       voptgenerror
        (FLG_SYNTAX, 
index 9b5d4cda7029113410cd687af8d1651775063f63..5c92b6e005f2cc4f26b4ffbc0737024afda83bb8 100644 (file)
@@ -1072,7 +1072,7 @@ describeModes ()
   return (s);
 }
 
-static cstring
+static /*@unused@*/ cstring
 listModes (void)
 {
   cstring s = cstring_makeLiteral ("\t");
index 347303ac7a5b12f6e6956f22d30aa80d9ebe6f79..1b8f4eb6e333441383f39ead6a50ceda95799232 100644 (file)
@@ -2177,6 +2177,10 @@ llexit (int status)
   exit ((status == LLSUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
+/*
+** This shouldn't be necessary, but Apple Darwin can't handle '"''s.
+*/
+
 void
 loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs)
    /*@ensures closed rcfile@*/
@@ -2444,16 +2448,16 @@ loadrc (/*:open:*/ FILE *rcfile, cstringSList *passThroughArgs)
                            }
                          else if (flagcode_hasString (opt))
                            {
-                             if (cstring_firstChar (extra) == '"')
+                             if (cstring_firstChar (extra) == '\"')
                                {
-                                 if (cstring_lastChar (extra) == '"')
+                                 if (cstring_lastChar (extra) == '\"')
                                    {
                                      char *extras = cstring_toCharsSafe (extra);
                                      
-                                     llassert (extras[strlen(extras) - 1] == '"');
+                                     llassert (extras[strlen(extras) - 1] == '\"');
                                      extras[strlen(extras) - 1] = '\0';
                                      extra = cstring_fromChars (extras + 1); 
-                                     DPRINTF (("Remove quites: %s", extra));
+                                     DPRINTF (("Remove quotes: %s", extra));
                                    }
                                  else
                                    {
index ce8f52349e63289d931546771ac10e600295d521..3db48c437e903808a4aeba05e7f426da7f088c31 100644 (file)
@@ -13,7 +13,7 @@
 .PHONY: compdestroy constannot controldepth csyntax czechnames czechoslovaknames 
 .PHONY: deadparam decl enum exports external fields fileio flags forbody format funcpointer glob globals 
 .PHONY: impabstract init inparam internal iter keep libs lintcomments 
-.PHONY: list macros macrosef merge mergestate modifies modtest moduncon mongoincludes 
+.PHONY: list longconstants macros macrosef merge mergestate modifies modtest moduncon mongoincludes 
 .PHONY: noeffect null observer oldstyle outglob outparam postnotnull preds prefixes printflike rc 
 .PHONY: refcounts release repexpose returned sharing slovaknames special
 .PHONY: specclauses stack staticarray 
@@ -57,7 +57,7 @@ UNITTESTS = \
   abstptr abstract alias alttypes ansireserved argorder args blocks branchstate break cases cast \
   charlit clauses commentchar compdestroy constannot controldepth csyntax czechnames czechoslovaknames deadparam \
   decl enum exports external fields flags forbody format freearray funcpointer glob globals impabstract \
-  init inparam internal iter keep libs linked lintcomments list macros macrosef merge modifies \
+  init inparam internal iter keep libs linked lintcomments list longconstants macros macrosef merge modifies \
   modtest moduncon mongoincludes mystrncat noeffect null observer oldstyle \
   outglob outparam postnotnull preds prefixes \
   printflike rc refcounts release repexpose returned sharing slovaknames specclauses special stack \
@@ -415,6 +415,9 @@ lintcomments:
 list:
        $(LCLINTR) list.c -expect 3
 
+longconstants:
+       $(LCLINTR) longconstants.c -expect 1
+
 macros:
        $(LCLINTR) macros -expect 17 
        $(LCLINTR) macros.c +allmacros -expect 34
diff --git a/test/longconstants.c b/test/longconstants.c
new file mode 100644 (file)
index 0000000..5ec761b
--- /dev/null
@@ -0,0 +1,4 @@
+long octlong = 07L;
+long hexlong = 0x34L;
+long llong = 3594UL;
+unsigned long ullong = 3594UL;
diff --git a/test/longconstants.expect b/test/longconstants.expect
new file mode 100644 (file)
index 0000000..bc9e1d6
--- /dev/null
@@ -0,0 +1,5 @@
+
+longconstants.c:3:14: Variable llong initialized to type unsigned long int,
+                         expects long int: 3594UL
+
+Finished LCLint checking --- 1 code error found, as expected
This page took 0.565294 seconds and 5 git commands to generate.