X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/abb1cb4309abcd21cdbbab2c4a0af5ca44126b47..35e063d82040a7c7a6da8634cf377e19ee0662d1:/src/nameChecks.c diff --git a/src/nameChecks.c b/src/nameChecks.c index 68f8d7d..d17a941 100644 --- a/src/nameChecks.c +++ b/src/nameChecks.c @@ -1,6 +1,6 @@ /* -** LCLint - annotation-assisted static program checker -** Copyright (C) 1994-2001 University of Virginia, +** Splint - annotation-assisted static program checker +** Copyright (C) 1994-2002 University of Virginia, ** Massachusetts Institute of Technology ** ** This program is free software; you can redistribute it and/or modify it @@ -17,23 +17,23 @@ ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, ** MA 02111-1307, USA. ** -** For information on lclint: lclint-request@cs.virginia.edu -** To report a bug: lclint-bug@cs.virginia.edu -** For more information: http://lclint.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 */ /* ** nameChecks.c */ -# include "lclintMacros.nf" +# include "splintMacros.nf" # include "basic.h" # 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) { @@ -1150,7 +1150,7 @@ checkCppName (uentry ue) static ob_mstring cppNames[NCPPNAMES] = { "and", "and_eq", "asm", - "bitand", "bitor", "bool", /* gasp: "bool", is special for lclint */ + "bitand", "bitor", "bool", /* gasp: "bool", is special for splint */ "catch", "class", "compl", "const_class", "delete", "dynamic_cast", "false", "friend", "inline", "mutable", "namespace", "new", @@ -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,11 +1283,11 @@ checkAnsiName (uentry ue) || isupper ((int) schar))) { hasError |= optgenerror2 - (FLG_ANSIRESERVED, FLG_NAMECHECKS, + (FLG_ISORESERVED, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "Macros beginning with E and a digit or uppercase letter " - "may be added to . (See ANSI, Section 4.13.1)", + "may be added to . (ISO99:7.26.3)", name), uentry_whereLast (ue)); } @@ -1305,11 +1305,11 @@ checkAnsiName (uentry ue) && (isupper ((int) rchar))) { hasError |= optgenerror2 - (FLG_ANSIRESERVED, FLG_NAMECHECKS, + (FLG_ISORESERVED, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "Macros beginning with \"LC_\" and an uppercase letter may " - "be added to . (See ANSI, Section 4.13.3)", + "be added to . (ISO99:7.26.5)", name), uentry_whereLast (ue)); } @@ -1326,12 +1326,12 @@ checkAnsiName (uentry ue) || (isupper ((int) rchar)))) { hasError |= optgenerror2 - (FLG_ANSIRESERVED, FLG_NAMECHECKS, + (FLG_ISORESERVED, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "Macros that begin with SIG and an uppercase letter or SIG_ " "and an uppercase letter may be added to " - ". (See ISO99 7.14 or ANSI 4.13.5)", + ". (ISO99:7.14)", name), uentry_whereLast (ue)); } @@ -1339,7 +1339,7 @@ checkAnsiName (uentry ue) DPRINTF (("Here...")); if ((uentry_isVisibleExternally (ue) && !uentry_isAnyTag (ue)) - || context_getFlag (FLG_ANSIRESERVEDLOCAL)) + || context_getFlag (FLG_ISORESERVEDLOCAL)) { flagcode flg; @@ -1347,13 +1347,15 @@ 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))); + /* ** These restrictions only apply to identifiers with global linkage. */ @@ -1371,9 +1373,9 @@ checkAnsiName (uentry ue) hasError |= optgenerror2 (flg, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "Functions beginning with \"is\" or \"to\" and a lowercase " - "letter may be added to . (See ANSI, Section 4.13.2)", + "letter may be added to . (ISO99:7.26.2)", name), uentry_whereLast (ue)); @@ -1395,37 +1397,37 @@ checkAnsiName (uentry ue) if ((cstring_lastChar (name) == 'f' || cstring_lastChar (name) == 'l') && (((length == 4) - && ((cstring_equalPrefix (name, "cos") || - cstring_equalPrefix (name, "sin") || - cstring_equalPrefix (name, "tan") || - cstring_equalPrefix (name, "exp") || - cstring_equalPrefix (name, "log") || - cstring_equalPrefix (name, "pow")))) + && ((cstring_equalPrefixLit (name, "cos") || + cstring_equalPrefixLit (name, "sin") || + cstring_equalPrefixLit (name, "tan") || + cstring_equalPrefixLit (name, "exp") || + cstring_equalPrefixLit (name, "log") || + cstring_equalPrefixLit (name, "pow")))) || ((length == 5) - && ((cstring_equalPrefix (name, "acos") || - cstring_equalPrefix (name, "asin") || - cstring_equalPrefix (name, "atan") || - cstring_equalPrefix (name, "cosh") || - cstring_equalPrefix (name, "sinh") || - cstring_equalPrefix (name, "sqrt") || - cstring_equalPrefix (name, "ceil") || - cstring_equalPrefix (name, "fabs") || - cstring_equalPrefix (name, "fmod") || - cstring_equalPrefix (name, "tanh") || - cstring_equalPrefix (name, "modf")))) + && ((cstring_equalPrefixLit (name, "acos") || + cstring_equalPrefixLit (name, "asin") || + cstring_equalPrefixLit (name, "atan") || + cstring_equalPrefixLit (name, "cosh") || + cstring_equalPrefixLit (name, "sinh") || + cstring_equalPrefixLit (name, "sqrt") || + cstring_equalPrefixLit (name, "ceil") || + cstring_equalPrefixLit (name, "fabs") || + cstring_equalPrefixLit (name, "fmod") || + cstring_equalPrefixLit (name, "tanh") || + cstring_equalPrefixLit (name, "modf")))) || ((length == 6) - && ((cstring_equalPrefix (name, "atan2") || - cstring_equalPrefix (name, "floor") || - cstring_equalPrefix (name, "frexp") || - cstring_equalPrefix (name, "ldexp") || - cstring_equalPrefix (name, "log10")))))) + && ((cstring_equalPrefixLit (name, "atan2") || + cstring_equalPrefixLit (name, "floor") || + cstring_equalPrefixLit (name, "frexp") || + cstring_equalPrefixLit (name, "ldexp") || + cstring_equalPrefixLit (name, "log10")))))) { hasError |= optgenerror2 (flg, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "The names of all existing functions in suffixed " - "with 'f' or 'l' may be added to . (See ANSI, Section 4.13.4)", + "with 'f' or 'l' may be added to . (ISO:7.26.1)", name), uentry_whereLast (ue)); } @@ -1448,9 +1450,9 @@ checkAnsiName (uentry ue) hasError |= optgenerror2 (flg, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "Functions that begin with \"str\" and a lowercase letter " - "may be added to or . (See ANSI, Section 4.13.7)", + "may be added to or . (ISO99:7.26.9)", name), uentry_whereLast (ue)); } @@ -1470,9 +1472,9 @@ checkAnsiName (uentry ue) hasError |= optgenerror2 (flg, FLG_NAMECHECKS, message - ("Name %s is reserved for future ANSI library extensions. " + ("Name %s is reserved for future library extensions. " "Functions that begin with \"mem\" or \"wcs\" and a " - "lowercase letter letter may be added to . (See ANSI, Section 4.13.8)", + "lowercase letter letter may be added to . (ISO:7.26.11)", name), uentry_whereLast (ue)); } @@ -1519,7 +1521,7 @@ void checkParamNames (uentry ue) { cstring pname = uentry_observeRealName (p); - if (!cstring_equalPrefix (pname, cstring_toCharsSafe (fpfx))) + if (!cstring_equalPrefix (pname, fpfx)) { if (context_getFlag (FLG_NAMECHECKS)) { @@ -1540,6 +1542,4 @@ void checkParamNames (uentry ue) } } - - - +/*@i523 POSIX p. 527 - applications should not declare any symbols that end _MAX @*/