]> andersk Git - splint.git/blobdiff - src/nameChecks.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / nameChecks.c
index 2cb8c563c44ede54444e3d350edd62ede86cbb96..20e8fa5245eb9c978dce80829dbcf04ca5472f3f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** 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
 # include "nameChecks.h"
 
 static bool checkCzechName (uentry p_ue, flagcode p_czechflag, bool p_report)
-  /*@modifies p_ue, g_msgstream@*/ ;
+  /*@modifies p_ue, g_warningstream@*/ ;
 
 static bool checkSlovakName (uentry p_ue, flagcode p_slovakflag, bool p_report)
-  /*@modifies p_ue, g_msgstream@*/ ;
+  /*@modifies p_ue, g_warningstream@*/ ;
 
 static cstring czechPrefix (cstring name)
 {
@@ -42,7 +42,7 @@ static cstring czechPrefix (cstring name)
 
 static cstring slovakPrefix (cstring name)
 {
-  int i = 0;
+  size_t i = 0;
 
   cstring_chars (name, c)
     {
@@ -119,9 +119,9 @@ static bool matchPrefix (cstring name, cstring prefix)
     }
   else
     {
-      int namelen = cstring_length (name);
+      size_t namelen = cstring_length (name);
       int last = (int) '\0';
-      int n = 1;
+      size_t n = 1;
 
       cstring_chars (prefix, pc)
        {
@@ -1124,7 +1124,7 @@ checkFileScopeName (/*@unused@*/ uentry ue)
   ** No file scope checks (yet)
   */
 
-  /*@i423 add a file scope naming convention policy? */
+  /* add a file scope naming convention policy? */
 
   return;
 }
@@ -1181,7 +1181,7 @@ checkAnsiName (uentry ue)
 {
   bool hasError = FALSE;
   cstring name = uentry_observeRealName (ue);
-  int length = cstring_length (name);
+  size_t length = cstring_length (name);
   char fchar = (length >= 1) ? cstring_firstChar (name) : '\0';
   char schar = (length >= 2) ? cstring_secondChar (name) : '\0';
   char tchar = (length >= 3) ? cstring_getChar (name, 3) : '\0';
@@ -1231,19 +1231,19 @@ checkAnsiName (uentry ue)
                                          NRESERVEDNAMES)))
     {
       hasError |= optgenerror2
-       (FLG_ANSIRESERVED, FLG_NAMECHECKS,
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message ("Name %s is reserved for the standard library",
                  name),
         uentry_whereLast (ue));
     }
 
   if (uentry_isFileStatic (ue) || uentry_isVisibleExternally (ue) || uentry_isAnyTag (ue)
-      || context_getFlag (FLG_ANSIRESERVEDLOCAL))
+      || context_getFlag (FLG_ISORESERVEDLOCAL))
     {
       if (fchar == '_')
        {
          hasError |= optgenerror2
-           (FLG_ANSIRESERVED, FLG_NAMECHECKS,
+           (FLG_ISORESERVED, FLG_NAMECHECKS,
             message 
             ("Name %s is in the implementation name space (any identifier "
              "beginning with underscore)", 
@@ -1263,7 +1263,7 @@ checkAnsiName (uentry ue)
          && (schar == '_' || isupper ((int) schar)))
        {
          hasError |= optgenerror2
-           (FLG_ANSIRESERVED, FLG_NAMECHECKS,
+           (FLG_ISORESERVED, FLG_NAMECHECKS,
             message 
             ("Name %s is in the implementation name space (any identifier "
              "beginning with underscore and either an uppercase letter or "
@@ -1283,7 +1283,7 @@ checkAnsiName (uentry ue)
                       || isupper ((int) schar)))
     {
       hasError |= optgenerror2
-       (FLG_ANSIRESERVED, FLG_NAMECHECKS,
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message 
         ("Name %s is reserved for future library extensions. "
          "Macros beginning with E and a digit or uppercase letter "
@@ -1305,7 +1305,7 @@ checkAnsiName (uentry ue)
       && (isupper ((int) rchar)))
     {
       hasError |= optgenerror2
-       (FLG_ANSIRESERVED, FLG_NAMECHECKS,
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message
         ("Name %s is reserved for future library extensions.  "
          "Macros beginning with \"LC_\" and an uppercase letter may "
@@ -1326,7 +1326,7 @@ checkAnsiName (uentry ue)
               || (isupper ((int) rchar))))
     {
       hasError |= optgenerror2
-       (FLG_ANSIRESERVED, FLG_NAMECHECKS,
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
         message
         ("Name %s is reserved for future library extensions.  "
          "Macros that begin with SIG and an uppercase letter or SIG_ "
@@ -1336,10 +1336,23 @@ checkAnsiName (uentry ue)
         uentry_whereLast (ue));
     }
 
-  DPRINTF (("Here..."));
+  /*
+  ** evans - 2002-12-16: added this check (even though it is not required by ISO)
+  */
+
+  if (fchar == 'S' && schar == 'A' && tchar == '_')
+    {
+      hasError |= optgenerror2
+       (FLG_ISORESERVED, FLG_NAMECHECKS,
+        message 
+        ("Name %s may be defined as a macro by Linux library. "
+         "It is not research by the ISO specification, but may produce conflicts on some systems.",
+         name),
+        uentry_whereLast (ue));
+    }
 
   if ((uentry_isVisibleExternally (ue) && !uentry_isAnyTag (ue))
-      || context_getFlag (FLG_ANSIRESERVEDLOCAL))
+      || context_getFlag (FLG_ISORESERVEDLOCAL))
     {
       flagcode flg;
 
@@ -1347,11 +1360,11 @@ checkAnsiName (uentry ue)
 
       if (uentry_isVisibleExternally (ue) && !uentry_isAnyTag (ue))
        {
-         flg = FLG_ANSIRESERVED;
+         flg = FLG_ISORESERVED;
        }
       else
        {
-         flg = FLG_ANSIRESERVEDLOCAL;
+         flg = FLG_ISORESERVEDLOCAL;
        }
 
       DPRINTF (("ue: %s", uentry_unparseFull (ue)));
@@ -1542,7 +1555,4 @@ void checkParamNames (uentry ue)
     }
 }
 
-
-
-
-/*@i523 POSIX p. 527 - applications should not declare any symbols that end _MAX @*/
+/* not yet checked: POSIX p. 527 - applications should not declare any symbols that end _MAX */
This page took 0.077667 seconds and 4 git commands to generate.