2 ** LCLint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2000 University of Virginia,
4 ** Massachusetts Institute of Technology
6 ** This program is free software; you can redistribute it and/or modify it
7 ** under the terms of the GNU General Public License as published by the
8 ** Free Software Foundation; either version 2 of the License, or (at your
9 ** option) any later version.
11 ** This program is distributed in the hope that it will be useful, but
12 ** WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ** General Public License for more details.
16 ** The GNU General Public License is available from http://www.gnu.org/ or
17 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 ** MA 02111-1307, USA.
20 ** For information on lclint: lclint-request@cs.virginia.edu
21 ** To report a bug: lclint-bug@cs.virginia.edu
22 ** For more information: http://lclint.cs.virginia.edu
28 * Modified by Herbert 04/19/97:
29 * - added include for new header portab.h containing OS dependent stuff.
30 * - changed occurrances of '/' as path delimiters to macro from portab.h
31 * - changed the handling of the tmp directory -- will no longer always be
32 * ".", if possible, environment variables "TMP" or, if not set, "TMP",
33 * or, if not set "." will be used.
36 # include "lclintMacros.nf"
40 # include "usymtab_interface.h"
43 # include "exprChecks.h"
44 # include "filelocStack.h"
45 # include "fileIdList.h"
51 extern /*@external@*/ int yydebug;
61 CX_FUNCTION, CX_FCNDECL,
62 CX_MACROFCN, CX_MACROCONST, CX_UNKNOWNMACRO,
63 CX_ITERDEF, CX_ITEREND,
67 static struct _context
70 int speclinesprocessed;
72 flagMarkerList markers;
75 ** used to record state where a macro must match a function name
76 ** (i.e., no params were listed in the macro definition
79 bool macroMissingParams BOOLBITS;
80 bool preprocessing BOOLBITS;
81 bool incommandline BOOLBITS;
82 bool insuppressregion BOOLBITS;
83 bool inDerivedFile BOOLBITS;
84 bool instandardlib BOOLBITS;
85 bool inimport BOOLBITS;
86 bool inheader BOOLBITS;
87 bool inmacrocache BOOLBITS;
88 bool protectVars BOOLBITS;
90 bool showfunction BOOLBITS;
91 bool savedFlags BOOLBITS;
92 bool justpopped BOOLBITS;
93 bool anyExports BOOLBITS;
106 filelocStack locstack;
109 /*@observer@*/ sRef aliasAnnote;
110 /*@observer@*/ sRef aliasAnnoteAls;
114 /*@observer@*/ sRefSet mods;
116 /* file access types */
119 /* local access types (this function) */
122 /* no access types (@noaccess) */
125 /*@observer@*/ globSet globs;
126 /*@only@*/ globSet globs_used;
130 /*@reldef@*/ maccesst *moduleaccess; /* Not defined is nmods == 0. */
136 bool flags[NUMFLAGS];
137 bool saveflags[NUMFLAGS];
138 bool setGlobally[NUMFLAGS];
139 bool setLocally[NUMFLAGS];
141 int values[NUMVALUEFLAGS];
142 int counters[NUMVALUEFLAGS];
144 o_cstring strings[NUMSTRINGFLAGS];
151 /*@dependent@*/ /*@exposed@*/ uentry fcn;
155 static /*@exposed@*/ cstring context_exposeString (flagcode p_flag) ;
156 static void context_restoreFlagSettings (void) /*@modifies gc@*/ ;
157 static void context_saveFlagSettings (void) /*@modifies gc@*/ ;
158 static void context_exitClauseAux (exprNode p_pred, exprNode p_tbranch)
160 static void context_exitClauseSimp (void) /*@modifies gc@*/ ;
161 static void context_exitClausePlain (void) /*@modifies gc@*/ ;
162 static void context_setJustPopped (void) /*@modifies gc.justpopped@*/ ;
163 static void context_setValue (flagcode p_flag, int p_val) /*@modifies gc.flags@*/ ;
164 static void context_setFlag (flagcode p_f, bool p_b)
165 /*@modifies gc.flags@*/ ;
168 context_setFlagAux (flagcode p_f, bool p_b, bool p_inFile, bool p_isRestore)
169 /*@modifies gc.flags@*/ ;
171 static void context_restoreFlag (flagcode p_f) /*@modifies gc.flags@*/ ;
175 cstring context_unparseFlagMarkers ()
177 return (flagMarkerList_unparse (gc.markers));
180 void context_setPreprocessing (void)
182 llassert (!gc.preprocessing);
183 gc.preprocessing = TRUE;
186 void context_clearPreprocessing (void)
188 llassert (gc.preprocessing);
189 gc.preprocessing = FALSE;
192 bool context_isPreprocessing (void)
194 return gc.preprocessing;
197 void context_setInCommandLine (void)
199 llassert (!gc.incommandline);
200 gc.incommandline = TRUE;
203 void context_clearInCommandLine (void)
205 llassert (gc.incommandline);
206 gc.incommandline = FALSE;
209 bool context_isInCommandLine (void)
211 return gc.incommandline;
215 void pushClause (clause c) /*@modifies gc.clauses, gc.inclause@*/
218 clauseStack_push (gc.clauses, c);
220 if (clause_isConditional (c)
221 && context_getFlag (FLG_CONTROLNESTDEPTH))
223 int maxdepth = context_getValue (FLG_CONTROLNESTDEPTH);
224 int depth = clauseStack_controlDepth (gc.clauses);
226 if (depth == maxdepth + 1)
229 (FLG_CONTROLNESTDEPTH,
230 message ("Maximum control nesting depth "
239 clause topClause (clauseStack s) /*@*/
241 if (clauseStack_isEmpty (s)) return NOCLAUSE;
242 return ((clause) clauseStack_top (s));
246 context_addMacroCache (/*@only@*/ cstring def)
248 macrocache_addEntry (gc.mc, fileloc_copy (g_currentloc), def);
252 context_addComment (/*@only@*/ cstring def)
254 macrocache_addComment (gc.mc, fileloc_copy (g_currentloc), def);
258 ** returns TRUE is fl is in ignore region, or region where -code
260 ** the logic is fuzzy...
264 context_inSuppressFlagZone (fileloc fl, flagcode code)
266 ynm ret = flagMarkerList_suppressError (gc.markers, code, fl);
269 if (ynm_isMaybe (ret))
277 res = !gc.saveflags[code];
281 res = !context_getFlag (code);
286 res = ynm_toBoolStrict (ret);
293 context_suppressSystemMsg (fileloc fl)
295 if (context_getFlag (FLG_SYSTEMDIRERRORS))
301 return (fileloc_isSystemFile (fl));
306 context_suppressFlagMsg (flagcode flag, fileloc fl)
308 if (context_suppressSystemMsg (fl))
313 /* want same object compare here */
315 if (fileloc_equal (fl, g_currentloc) || gc.inDerivedFile)
317 return (!context_getFlag (flag)
318 || context_inSuppressRegion ()
319 || context_inSuppressZone (fl)
320 || (gc.inDerivedFile && context_inSuppressFlagZone (fl, flag)));
324 return (context_inSuppressFlagZone (fl, flag));
329 context_suppressNotFlagMsg (flagcode flag, fileloc fl)
332 if (context_suppressSystemMsg (fl))
338 if (fl == g_currentloc)
339 /*@noaccess fileloc@*/
341 return (context_getFlag (flag) || context_inSuppressRegion ());
346 return (context_getFlag (flag) || context_inSuppressRegion ());
351 context_inSuppressZone (fileloc fl)
353 if (context_suppressSystemMsg (fl))
358 return (flagMarkerList_inIgnore (gc.markers, fl));
362 context_inSuppressRegion (void)
364 return (gc.insuppressregion);
368 context_enterSuppressRegion (void)
370 if (gc.insuppressregion)
372 gc.insuppressregion = FALSE; /* get this msg! */
374 ("%q: New ignore errors region entered while in ignore errors region",
375 fileloc_unparse (g_currentloc)));
378 gc.insuppressregion = TRUE;
379 flagMarkerList_add (gc.markers, flagMarker_createIgnoreOn (g_currentloc));
383 context_addFlagMarker (flagcode code, ynm set)
385 flagMarkerList_add (gc.markers,
386 flagMarker_createLocalSet (code, set, g_currentloc));
390 context_enterSuppressLine (int count)
392 fileloc nextline = fileloc_copy (g_currentloc);
394 flagMarkerList_add (gc.markers,
395 flagMarker_createIgnoreCount (count, g_currentloc));
397 fileloc_nextLine (nextline);
398 flagMarkerList_add (gc.markers,
399 flagMarker_createIgnoreOff (nextline));
400 fileloc_free (nextline);
403 void context_checkSuppressCounts (void)
405 if (context_getFlag (FLG_SUPCOUNTS))
407 flagMarkerList_checkSuppressCounts (gc.markers);
411 void context_incLineno (void)
418 context_exitSuppressRegion (void)
420 if (!gc.insuppressregion)
422 llerrorlit (FLG_SYNTAX,
423 "End ignore errors in region while not ignoring errors");
426 gc.insuppressregion = FALSE;
427 flagMarkerList_add (gc.markers, flagMarker_createIgnoreOff (g_currentloc));
432 context_enterLCLfile (void)
435 gc.facct = typeIdSet_emptySet ();
440 addModuleAccess (/*@only@*/ cstring fname, typeIdSet mods)
444 for (i = 0; i < gc.nmods; i++)
446 if (cstring_equal (gc.moduleaccess[i].file, fname))
448 gc.moduleaccess[i].daccess = typeIdSet_union (gc.moduleaccess[i].daccess, mods);
449 cstring_free (fname);
454 if (gc.nmods == gc.maxmods)
458 gc.maxmods = gc.maxmods + DEFAULTMAXMODS;
459 oldmods = gc.moduleaccess;
461 gc.moduleaccess = (maccesst *) dmalloc (sizeof (*gc.moduleaccess) * (gc.maxmods));
463 for (i = 0; i < gc.nmods; i++)
465 gc.moduleaccess[i] = oldmods[i];
471 gc.moduleaccess[gc.nmods].file = fname;
472 gc.moduleaccess[gc.nmods].daccess = mods;
478 insertModuleAccess (cstring fname, typeId t)
482 for (i = 0; i < gc.nmods; i++)
484 if (cstring_equal (gc.moduleaccess[i].file, fname))
486 gc.moduleaccess[i].daccess = typeIdSet_insert (gc.moduleaccess[i].daccess, t);
491 addModuleAccess (cstring_copy (fname), typeIdSet_single (t));
496 context_exitLCLfile (void)
498 if (gc.kind != CX_LCLLIB)
501 removeExtension (cstring_toCharsSafe
502 (fileName (currentFile ())), ".lcl");
504 addModuleAccess (cstring_fromCharsO (removePath (lclname)), gc.facct);
506 mstring_free (lclname);
511 gc.facct = typeIdSet_emptySet ();
516 context_dumpModuleAccess (FILE *fout)
520 for (i = 0; i < gc.nmods; i++)
522 cstring td = typeIdSet_dump (gc.moduleaccess[i].daccess);
524 fprintf (fout, "%s#%s@\n",
525 cstring_toCharsSafe (gc.moduleaccess[i].file),
526 cstring_toCharsSafe (td));
532 bool context_usingPosixLibrary ()
534 return (gc.library == FLG_POSIXLIB
535 || gc.library == FLG_POSIXSTRICTLIB
536 || gc.library == FLG_UNIXLIB
537 || gc.library == FLG_UNIXSTRICTLIB);
540 bool context_usingAnsiLibrary ()
542 return (gc.library != FLG_NOLIB);
545 flagcode context_getLibrary ()
550 void context_setLibrary (flagcode code)
555 /*@observer@*/ char *context_selectedLibrary ()
560 return LLSTRICTLIBS_NAME;
562 return LLPOSIXLIBS_NAME;
563 case FLG_POSIXSTRICTLIB:
564 return LLPOSIXSTRICTLIBS_NAME;
566 return LLUNIXLIBS_NAME;
567 case FLG_UNIXSTRICTLIB:
568 return LLUNIXSTRICTLIBS_NAME;
570 return LLSTDLIBS_NAME;
577 context_loadModuleAccess (FILE *in)
579 char *s = mstring_create (MAX_DUMP_LINE_LENGTH);
581 char *name = mstring_create (MAX_NAME_LENGTH);
587 while (fgets (s, MAX_DUMP_LINE_LENGTH, in) != NULL
593 while (s != NULL && *s != ';' && *s != '\0')
597 while (*s != '#' && *s != '\0')
606 llcontbug (message ("context_loadModuleAccess: bad library line: %s\n",
607 cstring_fromChars (s)));
613 addModuleAccess (cstring_copy (cstring_fromChars (oname)),
614 typeIdSet_undump (&s));
616 (void) fgets (s, MAX_DUMP_LINE_LENGTH, in);
617 llassert (s != lasts);
627 typeIdSet context_fileAccessTypes (void)
633 context_resetModeFlags (void)
638 if (flagcode_isModeFlag (code))
640 context_setFlag (code, FALSE);
649 ** Set all flags to FALSE, except for a few which are
652 ** Set all values and strings to appropriate defaults.
653 ** Set all counters to 0.
657 conext_resetAllCounters (void)
661 for (i = 0; i < NUMVALUEFLAGS; i++)
668 context_resetAllFlags (void)
672 gc.flags[code] = FALSE;
674 if (flagcode_hasValue (code))
678 /*@-loopswitchbreak@*/
682 val = DEFAULT_LIMIT; break;
684 val = DEFAULT_LINELEN; break;
685 case FLG_EXTERNALNAMELEN:
686 val = DEFAULT_EXTERNALNAMELEN; break;
687 case FLG_INTERNALNAMELEN:
688 val = DEFAULT_INTERNALNAMELEN; break;
689 case FLG_COMMENTCHAR:
690 val = (int) DEFAULT_COMMENTCHAR; break;
691 case FLG_CONTROLNESTDEPTH:
692 val = (int) DEFAULT_CONTROLNESTDEPTH; break;
693 case FLG_STRINGLITERALLEN:
694 val = (int) DEFAULT_STRINGLITERALLEN; break;
695 case FLG_INCLUDENEST:
696 val = (int) DEFAULT_INCLUDENEST; break;
697 case FLG_NUMSTRUCTFIELDS:
698 val = (int) DEFAULT_NUMSTRUCTFIELDS; break;
699 case FLG_NUMENUMMEMBERS:
700 val = (int) DEFAULT_NUMENUMMEMBERS; break;
705 llbug (message ("Bad value flag: %s", flagcode_unparse (code)));
707 /*@=loopswitchbreak@*/
709 context_setValue (code, val);
711 else if (flagcode_hasString (code))
713 cstring val = cstring_undefined;
716 { /*@-loopswitchbreak@*/
719 char *larchpath = osd_getEnvironmentVariable (LARCH_PATH);
721 if (larchpath != NULL)
723 val = cstring_fromCharsNew (larchpath);
727 val = cstring_makeLiteral (DEFAULT_LARCHPATH);
732 case FLG_LCLIMPORTDIR:
734 val = cstring_fromCharsNew (osd_getEnvironment (LCLIMPORTDIR, DEFAULT_LCLIMPORTDIR));
738 # if defined(OS2) || defined(MSDOS) || defined(WIN32)
740 char *env = osd_getEnvironmentVariable ("TMP");
744 env = osd_getEnvironmentVariable ("TEMP");
747 val = cstring_makeLiteral (env != NULL ? env : DEFAULT_TMPDIR);
750 val = cstring_makeLiteral (DEFAULT_TMPDIR);
751 # endif /* !defined(OS2) && !defined(MSDOS) */
755 val = cstring_makeLiteral (DEFAULT_BOOLTYPE); break;
757 val = cstring_makeLiteral ("FALSE"); break;
759 val = cstring_makeLiteral ("TRUE"); break;
760 case FLG_MACROVARPREFIX:
761 val = cstring_makeLiteral ("m_"); break;
763 val = cstring_makeLiteral (DEFAULT_SYSTEMDIR); break;
766 } /*@=loopswitchbreak@*/
768 context_setString (code, val);
772 ; /* nothing to set */
777 ** These flags are true by default.
780 gc.flags[FLG_MODIFIES] = TRUE;
781 gc.flags[FLG_NESTCOMMENT] = TRUE;
782 gc.flags[FLG_GLOBALS] = TRUE;
783 gc.flags[FLG_FULLINITBLOCK] = TRUE;
784 gc.flags[FLG_LIKELYBOOL] = TRUE;
785 gc.flags[FLG_ZEROPTR] = TRUE;
786 gc.flags[FLG_NUMLITERAL] = TRUE;
787 gc.flags[FLG_DUPLICATEQUALS] = TRUE;
788 gc.flags[FLG_SKIPANSIHEADERS] = TRUE;
789 gc.flags[FLG_SKIPPOSIXHEADERS] = TRUE;
790 gc.flags[FLG_SYSTEMDIREXPAND] = TRUE;
791 gc.flags[FLG_UNRECOGCOMMENTS] = TRUE;
792 gc.flags[FLG_CASTFCNPTR] = TRUE;
793 gc.flags[FLG_DOLCS] = TRUE;
794 gc.flags[FLG_USEVARARGS] = TRUE;
795 gc.flags[FLG_MAINTYPE] = TRUE;
796 gc.flags[FLG_SPECMACROS] = TRUE;
797 gc.flags[FLG_REDEF] = TRUE;
798 gc.flags[FLG_MACRONEXTLINE] = TRUE;
800 gc.flags[FLG_SIZEOFFORMALARRAY] = TRUE;
801 gc.flags[FLG_FIXEDFORMALARRAY] = TRUE;
803 gc.flags[FLG_PREDASSIGN] = TRUE;
804 gc.flags[FLG_MODOBSERVER] = TRUE;
805 gc.flags[FLG_MACROVARPREFIXEXCLUDE] = TRUE;
806 gc.flags[FLG_EXTERNALNAMECASEINSENSITIVE] = TRUE;
808 gc.flags[FLG_PARAMIMPTEMP] = TRUE;
809 gc.flags[FLG_RETIMPONLY] = TRUE;
810 gc.flags[FLG_GLOBIMPONLY] = TRUE;
811 gc.flags[FLG_STRUCTIMPONLY] = TRUE;
812 gc.flags[FLG_PREPROC] = TRUE;
813 gc.flags[FLG_NAMECHECKS] = TRUE;
814 gc.flags[FLG_FORMATCODE] = TRUE;
815 gc.flags[FLG_FORMATTYPE] = TRUE;
816 gc.flags[FLG_BADFLAG] = TRUE;
817 gc.flags[FLG_WARNFLAGS] = TRUE;
818 gc.flags[FLG_WARNUNIXLIB] = TRUE;
819 gc.flags[FLG_WARNPOSIX] = TRUE;
820 gc.flags[FLG_SHOWCOL] = TRUE;
821 gc.flags[FLG_SHOWFUNC] = TRUE;
822 gc.flags[FLG_SUPCOUNTS] = TRUE;
823 gc.flags[FLG_HINTS] = TRUE;
824 gc.flags[FLG_SYNTAX] = TRUE;
825 gc.flags[FLG_TYPE] = TRUE;
826 gc.flags[FLG_INCOMPLETETYPE] = TRUE;
827 gc.flags[FLG_ABSTRACT] = TRUE;
828 gc.flags[FLG_ITER] = TRUE;
829 gc.flags[FLG_CONTROL] = TRUE;
830 gc.flags[FLG_UNRECOG] = TRUE;
831 gc.flags[FLG_SYSTEMUNRECOG] = TRUE;
832 gc.flags[FLG_LINTCOMMENTS] = TRUE;
833 gc.flags[FLG_ACCESSCZECH] = TRUE;
834 gc.flags[FLG_ACCESSMODULE] = TRUE;
835 gc.flags[FLG_ACCESSFILE] = TRUE;
836 gc.flags[FLG_MACROVARPREFIX] = TRUE;
839 ** Changed for version 2.4.
842 gc.flags[FLG_GNUEXTENSIONS] = TRUE;
845 ** On by default for Win32, but not Unix (to support MS/VC++ error message format).
849 gc.flags[FLG_PARENFILEFORMAT] = TRUE;
854 ** C is way-lame, and you can initialize an array to a constant except where
855 ** it is declared. Hence, a macro is used to set the modeflags.
859 # define SETFLAGS() \
860 { int i = 0; while (modeflags[i] != INVALID_FLAG) { \
861 if (!flagcode_isModeFlag (modeflags[i])) \
862 { llbug (message ("not a mode flag: %s", \
863 flagcode_unparse (modeflags[i]))); } \
864 else { context_setFlag (modeflags[i], TRUE); } i++; }}
867 context_setMode (cstring s)
869 intSet setflags = intSet_new ();
873 if (flagcode_isModeFlag (code))
875 if (gc.setGlobally[code])
877 (void) intSet_insert (setflags, (int) code);
882 if (!intSet_isEmpty (setflags))
884 cstring rflags = cstring_undefined;
887 intSet_elements (setflags, el)
889 if (cstring_isUndefined (rflags))
891 rflags = cstring_copy (flagcode_unparse ((flagcode) (el)));
895 rflags = message ("%q, %s", rflags,
896 flagcode_unparse ((flagcode) el));
900 if (num > 4 && intSet_size (setflags) > 6)
902 rflags = message ("%q, (%d others) ...", rflags,
903 intSet_size (setflags) - num);
906 } end_intSet_elements ;
908 voptgenerror (FLG_WARNFLAGS,
909 message ("Setting mode %s after setting mode flags will "
910 "override set values of flags: %s",
914 cstring_free (rflags);
917 intSet_free (setflags);
919 context_resetModeFlags ();
921 if (cstring_equalLit (s, "standard"))
923 flagcode modeflags[] =
925 FLG_ENUMINT, FLG_MACROMATCHNAME,
926 FLG_MACROUNDEF, FLG_RELAXQUALS,
927 FLG_USEALLGLOBS, FLG_CHECKSTRICTGLOBALS,
928 FLG_CHECKSTRICTGLOBALIAS,
929 FLG_CHECKEDGLOBALIAS,
930 FLG_CHECKMODGLOBALIAS,
931 FLG_PREDBOOLOTHERS, FLG_PREDBOOLINT,
932 FLG_PARAMUNUSED, FLG_VARUNUSED, FLG_FUNCUNUSED,
934 FLG_CONSTUNUSED, FLG_ENUMMEMUNUSED, FLG_FIELDUNUSED,
935 FLG_PTRNUMCOMPARE, FLG_BOOLCOMPARE, FLG_MUTREP,
936 FLG_NOEFFECT, FLG_IMPTYPE,
937 FLG_RETVALOTHER, FLG_RETVALBOOL, FLG_RETVALINT,
938 FLG_SPECUNDEF, FLG_INCONDEFS, FLG_INCONDEFSLIB,
940 FLG_MACROPARAMS, FLG_MACROASSIGN, FLG_SEFPARAMS,
941 FLG_MACROSTMT, FLG_MACROPARENS,
944 FLG_MACROREDEF, FLG_INFLOOPS, FLG_UNREACHABLE,
945 FLG_NORETURN, FLG_CASEBREAK, FLG_MISSCASE, FLG_USEDEF,
949 /* memchecks flags */
951 FLG_NULLSTATE, FLG_NULLASSIGN,
952 FLG_NULLPASS, FLG_NULLRET,
954 FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF,
976 FLG_USERELEASED, FLG_ALIASUNIQUE, FLG_MAYALIASUNIQUE,
977 FLG_MUSTFREE, FLG_MUSTDEFINE, FLG_GLOBSTATE,
978 FLG_COMPDESTROY, FLG_MUSTNOTALIAS,
982 FLG_EVALORDER, FLG_SHADOW, FLG_READONLYSTRINGS,
984 FLG_IMPCHECKEDSPECGLOBALS,
985 FLG_MODGLOBS, FLG_WARNLINTCOMMENTS,
986 FLG_IFEMPTY, FLG_REALCOMPARE,
987 FLG_BOOLOPS, FLG_PTRNEGATE,
993 else if (cstring_equalLit (s, "weak"))
995 flagcode modeflags[] =
997 FLG_BOOLINT, FLG_CHARINT, FLG_FLOATDOUBLE,
998 FLG_ENUMINT, FLG_RELAXQUALS, FLG_FORWARDDECL,
999 FLG_CHARINDEX, FLG_ABSTVOIDP, FLG_USEALLGLOBS,
1000 FLG_CHARUNSIGNEDCHAR,
1002 FLG_VARUNUSED, FLG_FUNCUNUSED,
1004 FLG_CHECKSTRICTGLOBALS, FLG_MACROMATCHNAME,
1007 FLG_RETSTACK, FLG_PTRNEGATE,
1008 FLG_LONGUNSIGNEDINTEGRAL,
1009 FLG_LONGUNSIGNEDUNSIGNEDINTEGRAL,
1017 else if (cstring_equalLit (s, "checks"))
1019 flagcode modeflags[] =
1021 FLG_EXPORTLOCAL, FLG_IMPTYPE,
1022 FLG_CHECKSTRICTGLOBALIAS,
1023 FLG_CHECKEDGLOBALIAS,
1024 FLG_CHECKMODGLOBALIAS,
1025 FLG_UNCHECKEDGLOBALIAS,
1026 FLG_EXITARG, FLG_PTRNUMCOMPARE,
1027 FLG_BOOLCOMPARE, FLG_MACROUNDEF,
1028 FLG_MUSTMOD, FLG_ALLGLOBALS,
1029 FLG_PREDBOOLOTHERS, FLG_PREDBOOLPTR, FLG_PREDBOOLINT,
1030 FLG_USEALLGLOBS, FLG_MUTREP, FLG_RETALIAS,
1031 FLG_RETEXPOSE, FLG_ASSIGNEXPOSE, FLG_CASTEXPOSE,
1032 FLG_FUNCUNUSED, FLG_GLOBALSIMPMODIFIESNOTHING,
1033 FLG_TYPEUNUSED, FLG_FIELDUNUSED, FLG_PARAMUNUSED, FLG_VARUNUSED,
1034 FLG_CONSTUNUSED, FLG_ENUMMEMUNUSED,
1035 FLG_NOEFFECT, FLG_EXPORTHEADER, FLG_EXPORTHEADERVAR,
1036 FLG_RETVALOTHER, FLG_RETVALBOOL, FLG_RETVALINT,
1037 FLG_SPECUNDEF, FLG_IMPCHECKMODINTERNALS,
1038 FLG_DECLUNDEF, FLG_INCONDEFS, FLG_INCONDEFSLIB,
1045 FLG_SEFPARAMS, FLG_SEFUNSPEC, FLG_MACROSTMT, FLG_MACROPARENS,
1049 FLG_INFLOOPS, FLG_INFLOOPSUNCON,
1051 FLG_NORETURN, FLG_CASEBREAK, FLG_MISSCASE,
1052 FLG_EVALORDER, FLG_USEDEF,
1056 /* memchecks flags */
1058 FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
1059 FLG_NULLPASS, FLG_NULLRET,
1061 FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF, FLG_RETSTACK,
1063 /* memtrans flags */
1077 FLG_STATICINITTRANS,
1078 FLG_UNKNOWNINITTRANS,
1081 FLG_ONLYUNQGLOBALTRANS,
1082 FLG_USERELEASED, FLG_ALIASUNIQUE, FLG_MAYALIASUNIQUE,
1083 FLG_MUSTFREE, FLG_MUSTDEFINE, FLG_GLOBSTATE,
1084 FLG_COMPDESTROY, FLG_MUSTNOTALIAS,
1087 FLG_NULLPOINTERARITH,
1088 FLG_SHADOW, FLG_DEPARRAYS,
1089 FLG_REDECL, FLG_READONLYSTRINGS, FLG_READONLYTRANS,
1090 FLG_LOOPLOOPBREAK, FLG_SWITCHLOOPBREAK, FLG_MODGLOBS,
1091 FLG_CHECKSTRICTGLOBALS, FLG_IMPCHECKEDSPECGLOBALS,
1092 FLG_MACROMATCHNAME, FLG_WARNLINTCOMMENTS,
1093 FLG_INCLUDENEST, FLG_ANSIRESERVED, FLG_CPPNAMES,
1094 FLG_NOPARAMS, FLG_IFEMPTY, FLG_WHILEEMPTY, FLG_REALCOMPARE,
1095 FLG_BOOLOPS, FLG_SHIFTSIGNED,
1100 else if (cstring_equalLit (s, "strict"))
1102 flagcode modeflags[] =
1104 FLG_CHECKSTRICTGLOBALIAS,
1105 FLG_CHECKEDGLOBALIAS,
1106 FLG_CHECKMODGLOBALIAS,
1107 FLG_UNCHECKEDGLOBALIAS,
1110 FLG_MACROUNDEF, FLG_MUTREP, FLG_MUSTMOD,
1111 FLG_ALLGLOBALS, FLG_IMPTYPE,
1112 FLG_MODNOMODS, FLG_MODGLOBSUNSPEC, FLG_MODSTRICTGLOBSUNSPEC,
1113 FLG_GLOBUNSPEC, FLG_SIZEOFTYPE,
1114 FLG_EXPORTHEADER, FLG_EXPORTHEADERVAR,
1115 FLG_NOPARAMS, FLG_OLDSTYLE, FLG_EXITARG,
1118 FLG_ONLYUNQGLOBALTRANS,
1119 FLG_GLOBALSIMPMODIFIESNOTHING,
1120 FLG_PREDBOOLOTHERS, FLG_PREDBOOLPTR, FLG_PREDBOOLINT,
1121 FLG_INTERNALGLOBS, FLG_INTERNALGLOBSNOGLOBS,
1122 FLG_USEALLGLOBS, FLG_RETALIAS,
1123 FLG_MODGLOBS, FLG_MODGLOBSUNSPEC, FLG_MODGLOBSUNCHECKED,
1124 FLG_RETEXPOSE, FLG_ASSIGNEXPOSE, FLG_CASTEXPOSE,
1125 FLG_NOEFFECTUNCON, FLG_EVALORDERUNCON,
1127 FLG_EXPORTITER, FLG_EXPORTCONST,
1128 FLG_TYPEUNUSED, FLG_FIELDUNUSED, FLG_PARAMUNUSED, FLG_TOPUNUSED,
1129 FLG_CONSTUNUSED, FLG_ENUMMEMUNUSED,
1131 FLG_NULLPOINTERARITH, FLG_POINTERARITH,
1133 FLG_BOOLCOMPARE, FLG_NOEFFECT,
1134 FLG_RETVALINT, FLG_RETVALBOOL, FLG_RETVALOTHER,
1135 FLG_ANSIRESERVED, FLG_ANSIRESERVEDLOCAL, FLG_CPPNAMES,
1136 FLG_RETVALBOOL, FLG_RETVALINT, FLG_SPECUNDEF,
1137 FLG_DECLUNDEF, FLG_STRICTOPS, FLG_INCONDEFS,
1138 FLG_INCONDEFSLIB, FLG_MATCHFIELDS, FLG_EXPORTMACRO, FLG_EXPORTVAR,
1139 FLG_EXPORTFCN, FLG_EXPORTTYPE, FLG_EXPORTLOCAL, FLG_MACROPARAMS,
1141 FLG_SEFPARAMS, FLG_SEFUNSPEC, FLG_MACROSTMT, FLG_MACROPARENS,
1144 FLG_MACROREDEF, FLG_MACROEMPTY,
1145 FLG_INFLOOPS, FLG_INFLOOPSUNCON,
1147 FLG_NORETURN, FLG_CASEBREAK, FLG_MISSCASE, FLG_USEDEF,
1149 FLG_MODUNCON, FLG_MODUNCONNOMODS, FLG_MODINTERNALSTRICT,
1150 FLG_MODOBSERVERUNCON,
1155 /* memchecks flags */
1156 FLG_NULLSTATE, FLG_NULLDEREF, FLG_NULLASSIGN,
1157 FLG_NULLPASS, FLG_NULLRET,
1159 FLG_COMPDEF, FLG_COMPMEMPASS, FLG_UNIONDEF,
1161 /* memtrans flags */
1177 FLG_STATICINITTRANS,
1178 FLG_UNKNOWNINITTRANS,
1180 FLG_USERELEASED, FLG_ALIASUNIQUE, FLG_MAYALIASUNIQUE,
1181 FLG_MUSTFREE, FLG_MUSTDEFINE, FLG_GLOBSTATE,
1182 FLG_COMPDESTROY, FLG_MUSTNOTALIAS,
1186 FLG_DECLPARAMNAME, FLG_DECLPARAMMATCH,
1188 FLG_SHADOW, FLG_DEPARRAYS,
1189 FLG_STRICTDESTROY, FLG_STRICTUSERELEASED, FLG_STRICTBRANCHSTATE,
1190 FLG_REDECL, FLG_READONLYSTRINGS, FLG_READONLYTRANS,
1191 FLG_LOOPLOOPBREAK, FLG_LOOPSWITCHBREAK, FLG_SWITCHLOOPBREAK,
1192 FLG_SWITCHSWITCHBREAK, FLG_LOOPLOOPCONTINUE,
1193 FLG_CHECKSTRICTGLOBALS, FLG_IMPCHECKEDSPECGLOBALS,
1194 FLG_ALLGLOBALS, FLG_IMPCHECKEDSTRICTGLOBALS,
1195 FLG_IMPCHECKEDSTRICTSTATICS,
1196 FLG_IMPCHECKEDSTRICTSPECGLOBALS,
1197 FLG_IMPCHECKMODINTERNALS,
1198 FLG_WARNMISSINGGLOBALS, FLG_WARNMISSINGGLOBALSNOGLOBS,
1199 FLG_WARNLINTCOMMENTS, FLG_ANSIRESERVEDLOCAL,
1200 FLG_INCLUDENEST, FLG_STRINGLITERALLEN,
1201 FLG_NUMSTRUCTFIELDS, FLG_NUMENUMMEMBERS,
1202 FLG_CONTROLNESTDEPTH,
1203 FLG_FORBLOCK, FLG_WHILEBLOCK,
1204 FLG_FOREMPTY, FLG_WHILEEMPTY,
1205 FLG_IFEMPTY, FLG_IFBLOCK,
1207 FLG_REALCOMPARE, FLG_BOOLOPS,
1208 FLG_SYSTEMDIRERRORS, FLG_UNUSEDSPECIAL,
1210 FLG_SHIFTSIGNED, FLG_BITWISEOPS,
1217 llcontbug (message ("context_setMode: bad mode: %s", s));
1222 context_isSpecialFile (cstring fname)
1224 char *ext = filenameExtension (cstring_toCharsSafe (fname));
1226 return (mstring_equal (ext, ".y")
1227 || mstring_equal (ext, ".l")
1228 || cstring_equalLit (fname, "lex.yy.c"));
1232 context_isSystemDir (cstring dir)
1234 cstring sysDirs = context_exposeString (FLG_SYSTEMDIRS);
1235 char *thisdir = cstring_toCharsSafe (sysDirs);
1236 char *nextdir = strchr (thisdir, SEPCHAR);
1238 if (nextdir != NULL)
1244 while (thisdir != NULL)
1246 DPRINTF (("Test: %s / %s", dir, thisdir));
1248 if (cstring_equalCanonicalPrefix (dir, thisdir))
1250 if (nextdir != NULL)
1252 *(nextdir - 1) = SEPCHAR;
1258 if (nextdir != NULL)
1260 *(nextdir - 1) = SEPCHAR;
1263 if (nextdir != NULL)
1266 nextdir = strchr (thisdir, SEPCHAR);
1268 if (nextdir != NULL)
1280 DPRINTF (("Returns FALSE"));
1285 context_addFileAccessType (typeId t)
1289 if (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN
1290 || gc.kind == CX_UNKNOWNMACRO)
1292 gc.acct = typeIdSet_insert (gc.acct, t);
1295 gc.facct = typeIdSet_insert (gc.facct, t);
1297 base = fileloc_getBase (g_currentloc);
1298 insertModuleAccess (base, t);
1303 context_removeFileAccessType (typeId t)
1305 if (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN
1306 || gc.kind == CX_UNKNOWNMACRO)
1308 gc.acct = typeIdSet_removeFresh (gc.acct, t);
1311 gc.facct = typeIdSet_removeFresh (gc.facct, t);
1312 gc.nacct = typeIdSet_insert (gc.nacct, t);
1315 void context_enterFunctionDecl (void)
1317 llassert (gc.kind == CX_GLOBAL);
1318 gc.kind = CX_FCNDECL;
1321 void context_exitFunctionDecl (void)
1323 gc.kind = CX_GLOBAL;
1326 bool context_inFunctionDecl (void)
1328 return (gc.kind == CX_FCNDECL);
1332 context_enterMacro (/*@observer@*/ uentry e)
1334 context_enterFunction (e);
1335 gc.kind = CX_MACROFCN;
1339 context_enterUnknownMacro (/*@dependent@*/ uentry e)
1341 llassert (uentry_isFunction (e));
1342 context_enterFunction (e);
1343 gc.kind = CX_UNKNOWNMACRO;
1346 void context_enterAndClause (exprNode e)
1349 usymtab_trueBranch (guardSet_copy (exprNode_getGuards (e)));
1350 pushClause (ANDCLAUSE);
1353 void context_enterOrClause (exprNode e)
1355 usymtab_trueBranch (guardSet_invert (exprNode_getGuards (e)));
1356 pushClause (ORCLAUSE);
1359 bool context_inDeepLoop (void)
1361 bool inLoop = FALSE;
1363 clauseStack_elements (gc.clauses, el)
1365 if (clause_isLoop (el))
1374 } end_clauseStack_elements;
1379 bool context_inDeepSwitch (void)
1381 bool inLoop = FALSE;
1383 clauseStack_elements (gc.clauses, el)
1385 if (clause_isSwitch (el))
1394 } end_clauseStack_elements;
1399 bool context_inDeepLoopSwitch (void)
1401 bool inLoop = FALSE;
1403 clauseStack_elements (gc.clauses, el)
1405 if (clause_isBreakable (el))
1414 } end_clauseStack_elements;
1419 clause context_breakClause (void)
1421 clauseStack_elements (gc.clauses, el)
1423 if (clause_isSwitch (el))
1427 else if (clause_isLoop (el))
1435 } end_clauseStack_elements;
1440 clause context_nextBreakClause (void)
1442 bool hasOne = FALSE;
1444 clauseStack_elements (gc.clauses, el)
1446 if (clause_isBreakable (el))
1457 } end_clauseStack_elements;
1462 bool context_inConditional (void)
1464 clauseStack_elements (gc.clauses, el)
1467 ** Should also include TRUECLAUSE and FALSECLAUSE, but need
1468 ** to distinguish if from ? for this
1471 if (clause_isBreakable (el) && (el != DOWHILECLAUSE))
1475 } end_clauseStack_elements;
1480 void context_exitAndClause (exprNode pred, exprNode tbranch)
1482 context_setJustPopped ();
1484 llassert (gc.inclause == ANDCLAUSE);
1486 usymtab_popAndBranch (pred, tbranch);
1487 clauseStack_pop (gc.clauses);
1488 gc.inclause = topClause (gc.clauses);
1491 void context_exitOrClause (exprNode pred, exprNode tbranch)
1493 context_setJustPopped ();
1495 llassert (gc.inclause == ORCLAUSE);
1497 usymtab_popOrBranch (pred, tbranch);
1498 clauseStack_pop (gc.clauses);
1499 gc.inclause = topClause (gc.clauses);
1502 static void context_enterCondClauseAux (clause cl)
1508 static void context_enterTrueAux (exprNode e, clause cl)
1511 usymtab_trueBranch (guardSet_copy (exprNode_getGuards (e)));
1515 void context_enterIterClause (void)
1517 context_enterTrueAux (exprNode_undefined, ITERCLAUSE);
1520 void context_enterDoWhileClause (void)
1522 pushClause (DOWHILECLAUSE);
1525 void context_enterWhileClause (exprNode e)
1527 context_enterTrueAux (e, WHILECLAUSE);
1530 void context_enterForClause (exprNode e)
1532 context_enterTrueAux (e, FORCLAUSE);
1535 void context_enterTrueClause (exprNode e)
1537 context_enterTrueAux (e, TRUECLAUSE);
1540 void context_enterSwitch (exprNode e)
1543 usymtab_switchBranch (e);
1544 context_enterCondClauseAux (SWITCHCLAUSE);
1547 void context_exitSwitch (exprNode e, bool allpaths)
1549 usymtab_exitSwitch (e, allpaths);
1551 while (clause_isCase (clauseStack_top (gc.clauses)))
1553 clauseStack_pop (gc.clauses);
1556 context_exitClauseSimp ();
1559 void context_enterCaseClause (exprNode e)
1561 bool branch = FALSE;
1563 DPRINTF (("Enter case clause!"));
1565 branch = usymtab_newCase (exprNode_undefined, e);
1569 context_enterCondClauseAux (CASECLAUSE);
1573 static void context_enterFalseClauseAux (exprNode e, clause cl)
1576 usymtab_altBranch (guardSet_invert (exprNode_getGuards (e)));
1578 clauseStack_switchTop (gc.clauses, cl);
1581 void context_enterFalseClause (exprNode e)
1584 context_enterFalseClauseAux (e, FALSECLAUSE);
1588 context_enterConstantMacro (/*@exposed@*/ /*@dependent@*/ uentry e)
1590 gc.kind = CX_MACROCONST;
1592 gc.showfunction = context_getFlag (FLG_SHOWFUNC);
1594 gc.acct = typeIdSet_subtract (typeIdSet_union (gc.facct, uentry_accessType (e)),
1598 usymtab_enterScope ();
1599 sRef_enterFunctionScope ();
1601 gc.globs = globSet_undefined;
1602 globSet_clear (gc.globs_used);
1603 gc.mods = sRefSet_undefined;
1606 uentry context_getHeader (void)
1608 if (!(context_inFunctionLike () || (gc.kind == CX_MACROCONST)))
1610 llfatalbug (message ("context_getHeader: bad call: %q",
1611 context_unparse ()));
1614 return (gc.cont.fcn);
1618 context_setFunctionDefined (fileloc loc)
1622 case CX_UNKNOWNMACRO:
1625 uentry_setFunctionDefined (gc.cont.fcn, loc);
1628 /* (not a bug because of parse errors) */
1634 context_enterFunction (/*@exposed@*/ uentry e)
1636 gc.kind = CX_FUNCTION;
1639 if (uentry_hasAccessType (e))
1641 gc.acct = typeIdSet_subtract (typeIdSet_union (gc.facct, uentry_accessType (e)),
1649 gc.showfunction = context_getFlag (FLG_SHOWFUNC);
1651 gc.globs = uentry_getGlobs (e);
1652 globSet_clear (gc.globs_used);
1653 gc.mods = uentry_getMods (e);
1655 usymtab_enterFunctionScope (e);
1656 sRef_enterFunctionScope ();
1659 static bool context_checkStrictGlobals (void)
1661 return (context_getFlag (FLG_CHECKSTRICTGLOBALS));
1664 static bool context_hasGlobs (void)
1666 if (context_inFunctionLike ())
1668 return (uentry_hasGlobs (gc.cont.fcn));
1676 static bool context_checkCheckedGlobals (void)
1678 return (context_getFlag (FLG_GLOBALS)
1679 && (context_getFlag (FLG_GLOBUNSPEC)
1680 || context_hasGlobs ()));
1683 static bool context_checkUnknownGlobals (void)
1685 /* should be uentry_hasGlobs ? */
1687 return (context_getFlag (FLG_ALLGLOBALS)
1688 && (context_getFlag (FLG_GLOBUNSPEC)
1689 || context_hasGlobs ()));
1692 static bool context_checkUncheckedGlobals (void)
1698 context_checkExport (uentry e)
1700 if (!gc.anyExports) return FALSE;
1702 if (uentry_isFunction (e)
1703 || (uentry_isVariable (e) && ctype_isFunction (uentry_getType (e))))
1705 return context_maybeSet (FLG_EXPORTFCN);
1707 else if (uentry_isExpandedMacro (e))
1709 return context_maybeSet (FLG_EXPORTMACRO);
1711 else if (uentry_isVariable (e))
1713 return context_maybeSet (FLG_EXPORTVAR);
1715 else if (uentry_isEitherConstant (e))
1717 return context_maybeSet (FLG_EXPORTCONST);
1719 else if (uentry_isIter (e) || uentry_isEndIter (e))
1721 return context_maybeSet (FLG_EXPORTITER);
1723 else if (uentry_isDatatype (e))
1725 return context_maybeSet (FLG_EXPORTTYPE);
1734 context_checkGlobUse (uentry glob)
1737 if (uentry_isCheckedStrict (glob))
1739 return context_checkStrictGlobals ();
1741 else if (uentry_isChecked (glob))
1743 return context_checkCheckedGlobals ();
1745 else if (uentry_isCheckedUnknown (glob) || uentry_isCheckMod (glob))
1747 return context_checkUnknownGlobals ();
1751 llassert (uentry_isUnchecked (glob));
1753 return context_checkUncheckedGlobals ();
1758 context_checkAliasGlob (uentry glob)
1760 if (uentry_isCheckedStrict (glob))
1762 return gc.flags[FLG_CHECKSTRICTGLOBALIAS];
1764 else if (uentry_isChecked (glob))
1766 return gc.flags[FLG_CHECKEDGLOBALIAS];
1768 else if (uentry_isCheckMod (glob))
1770 return gc.flags[FLG_CHECKMODGLOBALIAS];
1774 llassert (uentry_isUnchecked (glob) || uentry_isCheckedUnknown (glob));
1776 return gc.flags[FLG_UNCHECKEDGLOBALIAS];
1780 bool context_checkInternalUse (void)
1782 if (context_hasGlobs ())
1784 return (gc.flags[FLG_INTERNALGLOBS]);
1788 return (gc.flags[FLG_INTERNALGLOBSNOGLOBS]);
1793 context_checkGlobMod (sRef el)
1795 uentry ue = sRef_getUentry (el);
1797 /* no: llassert (sRef_isGlobal (el)); also check local statics */
1799 if (uentry_isCheckedModify (ue)
1800 || (!uentry_isUnchecked (ue) && (gc.flags[FLG_ALLGLOBALS])))
1802 if (context_hasMods ())
1804 return (gc.flags[FLG_MODGLOBS]);
1808 if (uentry_isCheckedStrict (ue))
1810 return (gc.flags[FLG_MODGLOBSUNSPEC]);
1814 return (gc.flags[FLG_MODSTRICTGLOBSUNSPEC]);
1820 if (context_hasMods ())
1822 return (gc.flags[FLG_MODGLOBSUNCHECKED]);
1832 context_usedGlobal (sRef el)
1834 if (!globSet_member (gc.globs_used, el))
1837 ** The first time a global is used in a function, we need
1838 ** to clear the derived sRefs, since they were set for the
1839 ** previous function.
1842 sRef_clearDerived (el);
1843 gc.globs_used = globSet_insert (gc.globs_used, el);
1847 /*@observer@*/ sRefSet
1848 context_modList (void)
1854 context_globAccess (sRef s)
1856 llassert (sRef_isGlobal (s) || sRef_isKindSpecial (s));
1857 return (globSet_member (gc.globs, s));
1861 context_hasAccess (typeId t)
1863 if (context_inFunctionLike ())
1865 return (typeIdSet_member (gc.acct, t));
1869 return (context_hasFileAccess (t));
1874 context_hasFileAccess (typeId t)
1876 return (typeIdSet_member (gc.facct, t));
1880 context_unparseAccess (void)
1882 return (message ("%q / %q", typeIdSet_unparse (gc.acct),
1883 typeIdSet_unparse (gc.facct)));
1887 context_unparseClauses (void)
1889 return (clauseStack_unparse (gc.clauses));
1893 context_couldHaveAccess (typeId t)
1895 if (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN || gc.kind == CX_UNKNOWNMACRO)
1897 return (typeIdSet_member (gc.acct, t));
1901 return (typeIdSet_member (gc.facct, t));
1906 context_getRetType (void)
1908 ctype f = ctype_undefined;
1910 if (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN)
1912 f = uentry_getType (gc.cont.fcn);
1914 else if (gc.kind == CX_UNKNOWNMACRO)
1916 return ctype_unknown;
1920 llcontbuglit ("context_getRetType: not in a function context");
1921 return ctype_unknown;
1924 if (!ctype_isFunction (f))
1926 if (ctype_isKnown (f))
1928 llbuglit ("context_getRetType: not a function");
1931 return ctype_unknown;
1933 return (ctype_returnValue (f));
1937 context_hasMods (void)
1939 if (context_inFunctionLike ())
1941 return (uentry_hasMods (gc.cont.fcn));
1950 context_exitAllClauses (void)
1953 while (!clauseStack_isEmpty (gc.clauses))
1955 clause el = clauseStack_top (gc.clauses);
1959 if (clause_isNone (el))
1961 usymtab_quietExitScope (g_currentloc);
1962 clauseStack_pop (gc.clauses);
1966 context_exitClausePlain ();
1970 clauseStack_clear (gc.clauses);
1973 gc.inclause = NOCLAUSE;
1977 void context_exitClauseSimp (void)
1980 context_setJustPopped ();
1981 clauseStack_pop (gc.clauses);
1982 gc.inclause = topClause (gc.clauses);
1986 void context_exitCaseClause (void)
1988 context_setJustPopped ();
1989 usymtab_popCaseBranch ();
1990 clauseStack_pop (gc.clauses);
1991 gc.inclause = topClause (gc.clauses);
1995 void context_exitClauseAux (exprNode pred, exprNode tbranch)
1997 context_setJustPopped ();
1998 usymtab_popTrueBranch (pred, tbranch, gc.inclause);
1999 clauseStack_pop (gc.clauses);
2000 gc.inclause = topClause (gc.clauses);
2003 void context_exitTrueClause (exprNode pred, exprNode tbranch)
2005 if (gc.inclause != TRUECLAUSE)
2007 llparseerror (cstring_makeLiteral
2008 ("Likely parse error. Conditional clauses are inconsistent."));
2013 context_setJustPopped ();
2015 usymtab_popTrueBranch (pred, tbranch, TRUECLAUSE);
2016 clauseStack_pop (gc.clauses);
2017 gc.inclause = topClause (gc.clauses);
2021 void context_exitIterClause (exprNode body)
2023 llassert (gc.inclause == ITERCLAUSE);
2025 context_setJustPopped ();
2027 if (context_getFlag (FLG_LOOPEXEC))
2029 usymtab_popTrueExecBranch (exprNode_undefined, body, ITERCLAUSE);
2033 usymtab_popTrueBranch (exprNode_undefined, body, ITERCLAUSE);
2036 clauseStack_pop (gc.clauses);
2037 gc.inclause = topClause (gc.clauses);
2040 static void context_popCase (void) {
2042 ** If we are exiting an outer clause, sometimes still in a switch case.
2056 DPRINTF (("Popping case clause: %s",
2057 clauseStack_unparse (gc.clauses)));
2059 if (gc.inclause == CASECLAUSE) {
2060 context_exitCaseClause ();
2064 void context_exitWhileClause (exprNode pred, exprNode body)
2066 guardSet invGuards = guardSet_invert (exprNode_getGuards (pred));
2070 if (gc.inclause != WHILECLAUSE) {
2071 DPRINTF (("Clause: %s / %s", clause_unparse (gc.inclause),
2072 clauseStack_unparse (gc.clauses)));
2075 llassert (gc.inclause == WHILECLAUSE);
2077 context_setJustPopped ();
2081 ** predicate must be false after while loop (unless there are breaks)
2084 if (context_getFlag (FLG_LOOPEXEC))
2086 usymtab_popTrueExecBranch (pred, body, WHILECLAUSE);
2090 usymtab_popTrueBranch (pred, body, WHILECLAUSE);
2094 usymtab_addGuards (invGuards);
2095 guardSet_free (invGuards);
2097 clauseStack_pop (gc.clauses);
2098 gc.inclause = topClause (gc.clauses);
2101 void context_exitDoWhileClause (exprNode pred)
2103 guardSet invGuards = guardSet_invert (exprNode_getGuards (pred));
2105 if (gc.inclause == CASECLAUSE) {
2106 /* handle Duff's device */
2107 clauseStack_pop (gc.clauses);
2108 gc.inclause = topClause (gc.clauses);
2111 llassert (gc.inclause == DOWHILECLAUSE);
2113 context_setJustPopped ();
2116 usymtab_addGuards (invGuards);
2117 guardSet_free (invGuards);
2119 clauseStack_pop (gc.clauses);
2120 gc.inclause = topClause (gc.clauses);
2123 void context_exitForClause (exprNode forPred, exprNode body)
2125 guardSet invGuards = guardSet_invert (exprNode_getForGuards (forPred));
2127 llassert (gc.inclause == FORCLAUSE);
2128 context_setJustPopped ();
2131 ** predicate must be false after while loop (unless there are breaks)
2134 if (context_getFlag (FLG_LOOPEXEC))
2136 usymtab_popTrueExecBranch (forPred, body, FORCLAUSE);
2140 usymtab_popTrueBranch (forPred, body, FORCLAUSE);
2143 usymtab_addGuards (invGuards);
2144 guardSet_free (invGuards);
2145 clauseStack_pop (gc.clauses);
2146 gc.inclause = topClause (gc.clauses);
2149 static void context_exitClausePlain (void)
2151 llassert (gc.inclause != NOCLAUSE);
2153 if (gc.inclause == FALSECLAUSE)
2155 context_exitClause (exprNode_undefined, exprNode_undefined, exprNode_undefined);
2159 context_exitClauseAux (exprNode_undefined, exprNode_undefined);
2164 void context_exitClause (exprNode pred, exprNode tbranch, exprNode fbranch)
2167 context_setJustPopped ();
2169 if (gc.inclause == FALSECLAUSE)
2171 usymtab_popBranches (pred, tbranch, fbranch, FALSE, FALSECLAUSE);
2173 llassert (clauseStack_top (gc.clauses) == FALSECLAUSE);
2175 clauseStack_pop (gc.clauses);
2176 gc.inclause = topClause (gc.clauses);
2180 context_exitTrueClause (pred, tbranch);
2185 context_returnFunction (void)
2187 usymtab_checkFinalScope (TRUE);
2191 context_exitFunction (void)
2194 if (!context_inFunction () && !context_inMacroConstant ()
2195 && !context_inMacroUnknown ()
2196 && !context_inIterDef () && !context_inIterEnd ())
2199 ** not a bug because of parse errors
2204 if (context_inMacro () && usymtab_inFunctionScope ())
2206 usymtab_exitScope (exprNode_undefined);
2209 if (uentry_hasGlobs (gc.cont.fcn))
2211 exprChecks_checkUsedGlobs (gc.globs, gc.globs_used);
2215 if (uentry_hasMods (gc.cont.fcn))
2217 if (context_getFlag (FLG_MUSTMOD))
2219 exprNode_checkAllMods (gc.mods, gc.cont.fcn);
2224 ** clear file static modifies
2227 /* do this first to get unused error messages */
2229 usymtab_exitScope (exprNode_undefined);
2230 sRef_exitFunctionScope ();
2232 gc.showfunction = FALSE;
2233 gc.kind = CX_GLOBAL;
2234 gc.cont.glob = TRUE;
2236 gc.globs = globSet_new ();
2237 globSet_clear (gc.globs_used);
2238 gc.mods = sRefSet_new ();
2241 llassert (clauseStack_isEmpty (gc.clauses));
2242 llassert (gc.inclause == NOCLAUSE);
2246 context_quietExitFunction (void)
2248 while (gc.kind == CX_INNER)
2250 context_exitInnerPlain ();
2253 if (!context_inFunction () && !context_inMacroConstant () && !context_inMacroUnknown ()
2254 && !context_inIterDef () && !context_inIterEnd ())
2259 usymtab_quietExitScope (g_currentloc);
2261 gc.showfunction = FALSE;
2262 gc.kind = CX_GLOBAL;
2263 gc.cont.glob = TRUE;
2265 gc.globs = globSet_new ();
2266 globSet_clear (gc.globs_used);
2267 gc.mods = sRefSet_new ();
2269 sRef_exitFunctionScope ();
2273 /*@observer@*/ uentryList
2274 context_getParams (void)
2276 if (context_inFunctionLike ())
2278 return (uentry_getParams (gc.cont.fcn));
2282 llcontbug (message ("context_getParams: not in function: %q", context_unparse ()));
2283 return uentryList_undefined;
2287 /*@observer@*/ globSet
2288 context_getUsedGlobs (void)
2290 llassert (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN
2291 || gc.kind == CX_UNKNOWNMACRO || gc.kind == CX_ITERDEF);
2293 return (gc.globs_used);
2297 context_moduleName ()
2299 return (fileloc_getBase (g_currentloc));
2302 /*@observer@*/ globSet
2303 context_getGlobs (void)
2305 llassert (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN
2306 || gc.kind == CX_UNKNOWNMACRO || gc.kind == CX_ITERDEF);
2312 context_addBoolAccess (void)
2314 cstring bname = context_getString (FLG_BOOLTYPE);
2315 typeIdSet boolt = typeIdSet_single (usymtab_getTypeId (bname));
2317 addModuleAccess (cstring_copy (bname), boolt);
2319 /* for sys/types (perhaps, this is bogus!) */
2320 addModuleAccess (cstring_makeLiteral ("types"), boolt);
2324 context_canAccessBool (void)
2326 static typeId boolType = typeId_invalid;
2329 if (context_getFlag (FLG_ABSTRACTBOOL))
2331 if (typeId_isInvalid (boolType))
2333 boolType = usymtab_getTypeId (context_getBoolName ());
2335 return (typeIdSet_member (gc.acct, boolType));
2342 context_setMessageAnnote (/*@only@*/ cstring s)
2344 llassert (cstring_isUndefined (gc.msgAnnote));
2349 context_hasMessageAnnote (void)
2351 return (cstring_isDefined (gc.msgAnnote));
2355 context_clearMessageAnnote (void)
2357 if (cstring_isDefined (gc.msgAnnote))
2359 cstring_free (gc.msgAnnote);
2360 gc.msgAnnote = cstring_undefined;
2365 context_getMessageAnnote (void)
2367 cstring st = gc.msgAnnote;
2369 gc.msgAnnote = cstring_undefined;
2374 context_setAliasAnnote (/*@observer@*/ sRef s, /*@observer@*/ sRef t)
2376 llassert (sRef_isInvalid (gc.aliasAnnote));
2377 llassert (!sRef_sameName (s, t));
2379 gc.aliasAnnoteAls = t;
2383 context_hasAliasAnnote (void)
2385 return (sRef_isValid (gc.aliasAnnote));
2389 context_clearAliasAnnote (void)
2391 gc.aliasAnnote = sRef_undefined;
2395 context_getAliasAnnote (void)
2397 sRef ret = gc.aliasAnnote;
2398 sRef als = gc.aliasAnnoteAls;
2400 llassert (sRef_isValid (ret) && sRef_isValid (als));
2402 gc.aliasAnnote = sRef_undefined;
2403 return (message ("%q aliases %q", sRef_unparse (als), sRef_unparse (ret)));
2407 context_recordFileModifies (sRefSet mods)
2409 gc.modrecs = sRefSetList_add (gc.modrecs, mods);
2413 context_recordFileGlobals (globSet mods)
2415 /*@access globSet@*/ context_recordFileModifies (mods); /*@noaccess globSet@*/
2419 context_setCommentMarkerChar (char c)
2421 llassert (c != '\0');
2423 context_setValue (FLG_COMMENTCHAR, (int) c);
2427 context_getCommentMarkerChar (void)
2429 return ((char) context_getValue (FLG_COMMENTCHAR));
2433 context_setValue (flagcode flag, int val)
2435 int index = flagcode_valueIndex (flag);
2437 llassert (index >= 0 && index <= NUMVALUEFLAGS);
2443 case FLG_INCLUDENEST:
2444 case FLG_CONTROLNESTDEPTH:
2445 case FLG_STRINGLITERALLEN:
2446 case FLG_NUMSTRUCTFIELDS:
2447 case FLG_NUMENUMMEMBERS:
2450 cstring warn = message ("Value for %s must be a positive "
2451 "number (given %d)",
2452 flagcode_unparse (flag), val);
2455 cstring_free (warn);
2464 if (flag == FLG_LINELEN && val < MINLINELEN)
2466 cstring warn = message ("Value for %s must be at least %d (given %d)",
2467 flagcode_unparse (flag),
2470 cstring_free (warn);
2474 gc.values[index] = val;
2478 context_setValueAndFlag (flagcode flag, int val)
2480 gc.flags[flag] = TRUE;
2481 context_setValue (flag, val);
2485 context_getValue (flagcode flag)
2487 int index = flagcode_valueIndex (flag);
2489 llassert (index >= 0 && index <= NUMVALUEFLAGS);
2490 return (gc.values[index]);
2494 context_getCounter (flagcode flag)
2496 int index = flagcode_valueIndex (flag);
2498 llassert (index >= 0 && index <= NUMVALUEFLAGS);
2499 return (gc.counters[index]);
2503 context_incCounter (flagcode flag)
2505 int index = flagcode_valueIndex (flag);
2507 llassert (index >= 0 && index <= NUMVALUEFLAGS);
2509 gc.counters[index]++;
2513 context_decCounter (flagcode flag)
2515 int index = flagcode_valueIndex (flag);
2517 llassert (index >= 0 && index <= NUMVALUEFLAGS);
2518 gc.counters[index]--;
2521 bool context_showFunction (void)
2523 return (gc.showfunction);
2527 context_setString (flagcode flag, cstring val)
2529 int index = flagcode_stringIndex (flag);
2531 llassert (index >= 0 && index <= NUMSTRINGFLAGS);
2533 if (flag == FLG_SYSTEMDIRS)
2535 llassert (cstring_isDefined (val));
2537 if (cstring_firstChar (val) == '\"')
2540 cstring tval = cstring_copy (cstring_suffix (val, 1));
2542 if (cstring_lastChar (tval) != '\"')
2544 int n = cstring_length (tval) - 1;
2546 while (isspace ((int) cstring_getChar (tval, n)))
2551 if (cstring_getChar (tval, n) != '\"')
2553 cstring msg = message ("Setting -systemdirs to string with unmatching quotes: %s", val);
2559 cstring otval = tval;
2560 tval = cstring_prefix (tval, n);
2561 cstring_free (otval);
2565 val = cstring_copy (cstring_clip (tval, cstring_length (tval) - 1));
2566 DPRINTF (("val = %s", val));
2567 cstring_free (tval);
2568 cstring_free (oval);
2572 if (flag == FLG_TMPDIR)
2574 llassert (cstring_isDefined (val));
2576 if (cstring_length (val) == 0)
2579 val = message (".%s", cstring_makeLiteralTemp (CONNECTSTR));
2581 else if (cstring_lastChar (val) != CONNECTCHAR)
2583 val = cstring_appendChar (val, CONNECTCHAR);
2591 if (cstring_length (val) >= 1
2592 && cstring_firstChar (val) == '"')
2595 ("setting %s to string beginning with \". You probably "
2596 "don't meant to have the \"'s.",
2597 flagcode_unparse (flag));
2603 if (flag == FLG_BOOLTYPE)
2608 gc.strings[index] = val;
2611 static /*@exposed@*/ cstring
2612 context_exposeString (flagcode flag)
2614 int index = flagcode_stringIndex (flag);
2616 llassert (index >= 0 && index <= NUMSTRINGFLAGS);
2617 return (gc.strings[index]);
2621 context_getString (flagcode flag)
2623 return (context_exposeString (flag));
2627 context_resetErrors (void)
2632 void context_initMod (void)
2633 /*@globals undef gc; @*/
2635 gc.kind = CX_GLOBAL;
2636 gc.instandardlib = FALSE;
2639 gc.linesprocessed = 0;
2640 gc.speclinesprocessed = 0;
2641 gc.insuppressregion = FALSE;
2642 gc.macroMissingParams = FALSE;
2643 gc.preprocessing = FALSE;
2644 gc.incommandline = FALSE;
2645 gc.mc = macrocache_create ();
2647 gc.maxmods = DEFAULTMAXMODS;
2648 gc.moduleaccess = (maccesst *)
2649 dmalloc (sizeof (*gc.moduleaccess) * (gc.maxmods));
2651 gc.library = FLG_ANSILIB;
2653 gc.locstack = filelocStack_new ();
2654 gc.modrecs = sRefSetList_undefined;
2655 gc.anyExports = FALSE;
2657 gc.ftab = fileTable_create ();
2658 gc.msgLog = messageLog_new ();
2659 gc.inimport = FALSE;
2660 gc.inDerivedFile = FALSE;
2661 gc.inheader = FALSE;
2662 gc.markers = flagMarkerList_new ();
2663 gc.cont.glob = TRUE;
2664 gc.showfunction = FALSE;
2665 gc.msgAnnote = cstring_undefined;
2666 gc.aliasAnnote = sRef_undefined;
2667 gc.aliasAnnoteAls = sRef_undefined;
2668 gc.boolType = ctype_bool;
2669 gc.mods = sRefSet_new ();
2671 gc.saveloc = fileloc_undefined;
2673 gc.inmacrocache = FALSE;
2674 gc.inclause = NOCLAUSE;
2675 gc.clauses = clauseStack_new ();
2676 gc.globs = globSet_new ();
2677 gc.nacct = typeIdSet_emptySet ();
2678 gc.acct = typeIdSet_emptySet ();
2679 gc.facct = typeIdSet_emptySet ();
2680 gc.savedFlags = FALSE;
2681 gc.pushloc = fileloc_undefined;
2682 gc.protectVars = FALSE;
2683 gc.justpopped = FALSE;
2684 gc.isNullGuarded = NO;
2685 gc.globs_used = globSet_undefined;
2689 gc.setGlobally[code] = FALSE;
2690 gc.setLocally[code] = FALSE;
2691 } end_allFlagCodes ;
2695 context_resetAllFlags ();
2696 conext_resetAllCounters ();
2697 context_setMode (DEFAULT_MODE);
2701 context_typeofZero (void)
2703 ctype ct = ctype_int;
2705 if (context_getFlag (FLG_ZEROPTR))
2707 ct = ctype_makeConj (ct, ctype_voidPointer);
2710 if (!context_getFlag (FLG_ABSTRACTBOOL))
2712 ct = ctype_makeConj (ct, ctype_bool);
2719 context_typeofOne (void)
2721 ctype ct = ctype_int;
2723 /* 1 is on longer a bool (was before 2.4)
2724 if (!context_getFlag (FLG_ABSTRACTBOOL))
2726 ct = ctype_makeConj (ct, ctype_bool);
2734 context_unparse (void)
2741 s = message ("LCL File: %q", fileloc_unparse (g_currentloc));
2744 s = message ("LCL Lib File: %q", fileloc_unparse (g_currentloc));
2747 s = message ("Global Context:%q", fileloc_unparse (g_currentloc));
2750 s = message ("Inner Context:%q", fileloc_unparse (g_currentloc));
2753 s = message ("Function %q :%q \n\taccess %q\n\tmodifies %q",
2754 uentry_unparse (gc.cont.fcn),
2755 fileloc_unparse (g_currentloc),
2756 typeIdSet_unparse (gc.acct),
2757 sRefSet_unparse (gc.mods));
2760 s = message ("Function Macro %q", uentry_unparse (gc.cont.fcn));
2762 case CX_UNKNOWNMACRO:
2763 s = message ("Forward Specified Macro %q", uentry_unparse (gc.cont.fcn));
2766 s = message ("Constant Macro %q", uentry_unparse (gc.cont.fcn));
2769 s = message ("Iter definition %q", uentry_unparse (gc.cont.fcn));
2772 s = message ("Iter end %q", uentry_unparse (gc.cont.fcn));
2775 s = message ("Un-unparseable context: %d", (int) gc.kind);
2779 s = message ("%q\naccess: %q", s, context_unparseAccess ());
2784 context_currentFunctionType (void)
2786 if (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN)
2788 return (uentry_getType (gc.cont.fcn));
2790 else if (gc.kind == CX_INNER)
2792 llcontbuglit ("context_currentFunctionType: inner context");
2793 do { context_exitInnerPlain (); } while (gc.kind == CX_INNER);
2794 return (context_currentFunctionType ());
2798 llcontbuglit ("context_currentFunctionType: not in function");
2799 return (ctype_undefined);
2804 context_enterInnerContext (void)
2806 if (gc.kind == CX_GLOBAL)
2811 else if (gc.kind == CX_INNER)
2821 usymtab_enterScope ();
2822 pushClause (NOCLAUSE);
2826 context_exitInnerPlain (void) /*@modifies gc;@*/
2828 context_exitInner (exprNode_undefined);
2832 context_exitInner (exprNode exp)
2835 llassertprint (gc.inclause == NOCLAUSE || gc.inclause == CASECLAUSE,
2836 ("inclause = %s", clause_nameTaken (gc.inclause)));
2838 clauseStack_removeFirst (gc.clauses, NOCLAUSE);
2839 gc.inclause = topClause (gc.clauses);
2841 if (gc.kind == CX_INNER)
2843 if (--gc.cont.cdepth == 0)
2845 gc.kind = CX_GLOBAL;
2846 gc.cont.glob = TRUE;
2851 if (gc.kind == CX_GLOBAL)
2853 llcontbuglit ("Attempt to exit global context");
2858 usymtab_exitScope (exp);
2863 context_enterStructInnerContext (void)
2865 if (gc.kind == CX_GLOBAL)
2870 else if (gc.kind == CX_INNER)
2879 usymtab_enterScope ();
2883 context_exitStructInnerContext (void)
2885 if (gc.kind == CX_INNER)
2887 if (--gc.cont.cdepth == 0)
2889 gc.kind = CX_GLOBAL;
2890 gc.cont.glob = TRUE;
2895 if (gc.kind == CX_GLOBAL)
2897 llcontbuglit ("Attempt to exit global context");
2902 usymtab_exitScope (exprNode_undefined);
2906 context_exitInnerSafe (void)
2909 if (gc.kind == CX_INNER)
2911 if (--gc.cont.cdepth == 0)
2916 else if (gc.kind == CX_GLOBAL)
2918 llcontbuglit ("Attempt to exit global context");
2923 if (usymtab_inDeepScope ())
2925 usymtab_exitScope (exprNode_undefined);
2931 void setModuleAccess (void)
2933 gc.facct = typeIdSet_emptySet ();
2935 if (fileId_isValid (currentFile ()))
2937 cstring baseName = fileloc_getBase (g_currentloc);
2939 DPRINTF (("Access: %s", baseName));
2941 if (context_getFlag (FLG_ACCESSFILE))
2943 if (usymtab_existsType (baseName))
2945 gc.facct = typeIdSet_insert (gc.facct,
2946 usymtab_getTypeId (baseName));
2950 if (context_getFlag (FLG_ACCESSMODULE))
2953 bool hasaccess = FALSE;
2955 for (i = 0; i < gc.nmods; i++)
2957 if (cstring_equal (baseName, gc.moduleaccess[i].file))
2959 gc.facct = typeIdSet_union (gc.facct, gc.moduleaccess[i].daccess);
2968 gc.inheader = fileId_isHeader (currentFile ());
2972 llcontbuglit ("Current file not defined\n");
2973 gc.facct = typeIdSet_emptySet ();
2975 gc.inheader = FALSE;
2978 /* 17 Jan 1995: forgot to clear nacct */
2980 gc.nacct = typeIdSet_emptySet ();
2984 context_enterFileAux (void)
2990 context_enterFile (void)
2992 context_enterFileAux ();
2993 usymtab_enterFile ();
2997 context_enterMacroFile (void)
2999 context_enterFileAux ();
3003 context_inFunction (void)
3005 kcontext ck = gc.kind;
3007 return ((ck == CX_FUNCTION) || (ck == CX_MACROFCN) || (ck == CX_INNER));
3011 context_inFunctionLike (void)
3013 return (gc.kind == CX_FUNCTION || gc.kind == CX_MACROFCN
3014 || gc.kind == CX_UNKNOWNMACRO || gc.kind == CX_ITERDEF);
3018 context_inRealFunction (void)
3020 kcontext ck = gc.kind;
3022 return ((ck == CX_FUNCTION) || (ck == CX_MACROFCN));
3026 context_processAllMacros (void)
3028 usymtab_enterFile ();
3030 gc.inmacrocache = TRUE;
3031 macrocache_processUndefinedElements (gc.mc);
3033 usymtab_exitFile ();
3035 gc.inmacrocache = FALSE;
3036 macrocache_finalize ();
3040 ** this happens once at the end of each C file
3042 ** check each Macro that was defined in current file.c or current file.h
3047 context_processMacros (void)
3049 if (fileId_isValid (currentFile ()))
3052 cstring cbase = cstring_fromChars
3055 (cstring_toCharsSafe (fileName (currentFile ())))));
3057 gc.inmacrocache = TRUE;
3059 lastfl = macrocache_processFileElements (gc.mc, cbase);
3060 cstring_free (cbase);
3062 if (fileloc_isDefined (lastfl))
3064 g_currentloc = fileloc_update (g_currentloc, lastfl);
3068 gc.inmacrocache = FALSE;
3073 context_processingMacros (void)
3075 return (gc.inmacrocache);
3079 context_exitFile (void)
3081 if (gc.kind != CX_GLOBAL)
3084 (cstring_makeLiteral ("File ended outside global scope"));
3087 if (gc.insuppressregion)
3089 /* gack...don't reverse the order of these lines! ;-> */
3090 gc.insuppressregion = FALSE;
3091 llerrorlit (FLG_SYNTAX,
3092 "File ended in ignore errors region, "
3093 "possible missing /*@end*/");
3096 /* fix up parse errors */
3098 while (!usymtab_inFileScope ())
3100 usymtab_quietExitScope (g_currentloc);
3104 ** Clear the file-specific modifies information.
3107 sRefSetList_elements (gc.modrecs, mods)
3109 sRefSet_clearStatics (mods);
3110 } end_sRefSetList_elements ;
3112 sRefSetList_clear (gc.modrecs);
3114 context_processMacros ();
3117 usymtab_exitFile ();
3119 gc.inDerivedFile = FALSE;
3120 filelocStack_clear (gc.locstack);
3122 gc.nacct = typeIdSet_emptySet (); /* empty noaccess */
3124 gc.cont.glob = TRUE;
3128 context_restoreFlagSettings ();
3129 gc.savedFlags = FALSE;
3134 context_exitMacroCache (void)
3136 if (gc.kind != CX_GLOBAL)
3138 if (context_inMacro ()) /* this is okay, file could end without newline in macro */
3140 context_exitFunction ();
3144 llcontbug (message ("context_exitMacroCache: outside global scope: %q",
3145 context_unparse ()));
3146 gc.kind = CX_GLOBAL;
3151 ** no longer valid here
3152 ** if (gc.insuppressregion)
3154 ** gc.insuppressregion = FALSE;
3155 ** llerror ("File ended in ignore errors region, possible missing @");
3159 gc.cont.glob = TRUE;
3163 context_saveLocation (void)
3165 /* was llassert (fileloc_isUndefined (gc.saveloc)) */
3166 fileloc_free (gc.saveloc);
3169 gc.saveloc = fileloc_copy (g_currentloc);
3173 context_getSaveLocation (void)
3175 fileloc fl = gc.saveloc;
3177 gc.saveloc = fileloc_undefined;
3181 /*@observer@*/ cstring
3182 context_inFunctionName (void)
3184 if (gc.kind == CX_FUNCTION
3185 || gc.kind == CX_MACROFCN || gc.kind == CX_UNKNOWNMACRO
3186 || gc.kind == CX_MACROCONST
3187 || gc.kind == CX_ITERDEF || gc.kind == CX_ITEREND)
3189 return (uentry_rawName (gc.cont.fcn));
3193 llcontbuglit ("context_inFunctionName: not in function");
3194 return (cstring_undefined);
3199 context_userSetFlag (flagcode f, bool b)
3201 DPRINTF (("set flag: %s", flagcode_name (f)));
3203 if (f == FLG_NEVERINCLUDE && b)
3205 if (gc.flags[FLG_EXPORTHEADER])
3207 flagWarning (cstring_makeLiteralTemp
3208 ("setting +neverinclude after +exportheader. "
3209 "Turning off exportheader, since headers are not checked "
3210 "when +neverinclude is used."));
3212 gc.flags[FLG_EXPORTHEADER] = FALSE;
3217 if (f == FLG_EXPORTHEADER && b)
3219 if (gc.flags[FLG_NEVERINCLUDE])
3221 flagWarning (cstring_makeLiteralTemp
3222 ("setting +exportheader after +neverinclude. "
3223 "Not setting exportheader, since headers are not checked "
3224 "when +neverinclude is used."));
3225 gc.flags[FLG_EXPORTHEADER] = FALSE;
3231 if (context_getFlag (FLG_WARNFLAGS) && f != FLG_NOF && f != FLG_OPTF)
3233 bool lastsetting = context_getFlag (f);
3235 if (bool_equal (lastsetting, b)
3236 && !flagcode_isSpecialFlag (f)
3237 && !flagcode_isIdemFlag (f)
3238 && !flagcode_hasArgument (f))
3240 cstring warn = message ("setting %s%s redundant with current value",
3241 cstring_makeLiteralTemp (b ? "+" : "-"),
3244 cstring_free (warn);
3248 if (flagcode_isLibraryFlag (f))
3250 if (gc.library != FLG_ANSILIB
3253 cstring warn = message ("selecting library %s after library %s was "
3254 "selected (only one library may be used)",
3256 flagcode_name (gc.library));
3258 cstring_free (warn);
3261 if (f == FLG_UNIXLIB)
3263 if (context_getFlag (FLG_WARNUNIXLIB))
3265 flagWarning (cstring_makeLiteralTemp
3266 ("selecting unix library. Unix library is "
3267 "ad hoc addition to POSIX library. Recommend "
3268 "use +posixlib to select POSIX library instead. "
3269 "Use -warnunixlib to suppress this message."));
3276 gc.setGlobally[f] = TRUE;
3277 context_setFlag (f, b);
3281 context_fileSetFlag (flagcode f, ynm set)
3285 context_saveFlagSettings ();
3288 if (ynm_isOff (set))
3290 context_setFlagAux (f, FALSE, TRUE, FALSE);
3292 else if (ynm_isOn (set))
3294 context_setFlagAux (f, TRUE, TRUE, FALSE);
3295 gc.setLocally[f] = TRUE;
3299 context_restoreFlag (f);
3304 context_restoreFlag (flagcode f)
3311 message ("Attempt to restore flag %s when no file scope flags "
3313 flagcode_unparse (f)),
3318 context_addFlagMarker (f, MAYBE);
3319 context_setFlagAux (f, gc.saveflags[f], FALSE, TRUE);
3325 context_setFlag (flagcode f, bool b)
3327 context_setFlagAux (f, b, FALSE, FALSE);
3331 context_setFlagTemp (flagcode f, bool b)
3333 DPRINTF (("Set flag temp: %s / %s", flagcode_unparse (f), bool_unparse (b)));
3338 # define DOSET(ff,b) \
3339 do { if (inFile) { gc.setLocally[ff] = TRUE; \
3340 context_addFlagMarker (ff, ynm_fromBool (b)); } \
3341 DPRINTF (("set flag: %s / %s", flagcode_name (ff), bool_unparse (b))); \
3342 gc.flags[ff] = b; } while (FALSE)
3345 context_setFlagAux (flagcode f, bool b, bool
3346 inFile, /*@unused@*/ bool isRestore)
3348 DPRINTF (("set flag: %s / %s", flagcode_unparse (f), bool_unparse (b)));
3350 if (f == FLG_USESTDERR)
3353 g_msgstream = stderr;
3355 g_msgstream = stdout;
3359 if (flagcode_isSpecialFlag (f))
3367 DOSET (FLG_ALLEMPTY, b);
3368 DOSET (FLG_IFEMPTY, b);
3369 DOSET (FLG_WHILEEMPTY, b);
3370 DOSET (FLG_FOREMPTY, b);
3373 DOSET (FLG_PREDBOOL, b);
3374 DOSET (FLG_PREDBOOLINT, b);
3375 DOSET (FLG_PREDBOOLPTR, b);
3376 DOSET (FLG_PREDBOOLOTHERS, b);
3379 DOSET (FLG_CHECKSTRICTGLOBALIAS, b);
3380 DOSET (FLG_CHECKEDGLOBALIAS, b);
3381 DOSET (FLG_CHECKMODGLOBALIAS, b);
3382 DOSET (FLG_UNCHECKEDGLOBALIAS, b);
3385 DOSET (FLG_ALLBLOCK, b);
3386 DOSET (FLG_IFBLOCK, b);
3387 DOSET (FLG_WHILEBLOCK, b);
3388 DOSET (FLG_FORBLOCK, b);
3400 DOSET (FLG_GRAMMAR, b);
3402 case FLG_CODEIMPONLY:
3403 DOSET (FLG_CODEIMPONLY, b);
3404 DOSET (FLG_GLOBIMPONLY, b);
3405 DOSET (FLG_RETIMPONLY, b);
3406 DOSET (FLG_STRUCTIMPONLY, b);
3408 case FLG_SPECALLIMPONLY:
3409 DOSET (FLG_SPECALLIMPONLY, b);
3410 DOSET (FLG_SPECGLOBIMPONLY, b);
3411 DOSET (FLG_SPECRETIMPONLY, b);
3412 DOSET (FLG_SPECSTRUCTIMPONLY, b);
3414 case FLG_ALLIMPONLY:
3415 DOSET (FLG_ALLIMPONLY, b);
3416 DOSET (FLG_GLOBIMPONLY, b);
3417 DOSET (FLG_RETIMPONLY, b);
3418 DOSET (FLG_STRUCTIMPONLY, b);
3419 DOSET (FLG_SPECGLOBIMPONLY, b);
3420 DOSET (FLG_SPECRETIMPONLY, b);
3421 DOSET (FLG_SPECSTRUCTIMPONLY, b);
3423 case FLG_ANSILIMITS:
3424 DOSET (FLG_ANSILIMITS, b);
3425 DOSET (FLG_CONTROLNESTDEPTH, b);
3426 DOSET (FLG_STRINGLITERALLEN, b);
3427 DOSET (FLG_INCLUDENEST, b);
3428 DOSET (FLG_NUMSTRUCTFIELDS, b);
3429 DOSET (FLG_NUMENUMMEMBERS, b);
3433 context_setValue (FLG_CONTROLNESTDEPTH, DEFAULT_CONTROLNESTDEPTH);
3434 context_setValue (FLG_STRINGLITERALLEN, DEFAULT_STRINGLITERALLEN);
3435 context_setValue (FLG_INCLUDENEST, DEFAULT_INCLUDENEST);
3436 context_setValue (FLG_NUMSTRUCTFIELDS, DEFAULT_NUMSTRUCTFIELDS);
3437 context_setValue (FLG_NUMENUMMEMBERS, DEFAULT_NUMENUMMEMBERS);
3440 case FLG_EXTERNALNAMELEN:
3441 DOSET (FLG_DISTINCTEXTERNALNAMES, TRUE);
3442 DOSET (FLG_EXTERNALNAMELEN, TRUE);
3444 case FLG_INTERNALNAMELEN:
3445 DOSET (FLG_DISTINCTINTERNALNAMES, TRUE);
3446 DOSET (FLG_INTERNALNAMELEN, TRUE);
3448 case FLG_EXTERNALNAMECASEINSENSITIVE:
3449 DOSET (FLG_EXTERNALNAMECASEINSENSITIVE, b);
3451 if (b && !gc.flags[FLG_DISTINCTEXTERNALNAMES])
3453 DOSET (FLG_DISTINCTEXTERNALNAMES, TRUE);
3454 context_setValue (FLG_EXTERNALNAMELEN, 0);
3457 case FLG_INTERNALNAMECASEINSENSITIVE:
3458 DOSET (FLG_INTERNALNAMECASEINSENSITIVE, b);
3460 if (b && !gc.flags[FLG_DISTINCTINTERNALNAMES])
3462 DOSET (FLG_DISTINCTINTERNALNAMES, TRUE);
3463 context_setValue (FLG_INTERNALNAMELEN, 0);
3466 case FLG_INTERNALNAMELOOKALIKE:
3467 DOSET (FLG_INTERNALNAMELOOKALIKE, b);
3469 if (b && !gc.flags[FLG_DISTINCTINTERNALNAMES])
3471 DOSET (FLG_DISTINCTINTERNALNAMES, TRUE);
3472 context_setValue (FLG_INTERNALNAMELEN, 0);
3476 DOSET (FLG_MODNOMODS, b);
3477 DOSET (FLG_MODGLOBSUNSPEC, b);
3478 DOSET (FLG_MODSTRICTGLOBSUNSPEC, b);
3481 DOSET (FLG_EXPORTVAR, b);
3482 DOSET (FLG_EXPORTFCN, b);
3483 DOSET (FLG_EXPORTTYPE, b);
3484 DOSET (FLG_EXPORTMACRO, b);
3485 DOSET (FLG_EXPORTCONST, b);
3486 gc.anyExports = TRUE;
3489 DOSET (FLG_RETEXPOSE, b);
3490 DOSET (FLG_ASSIGNEXPOSE, b);
3491 DOSET (FLG_CASTEXPOSE, b);
3494 DOSET (FLG_RETVALBOOL, b);
3495 DOSET (FLG_RETVALINT, b);
3496 DOSET (FLG_RETVALOTHER, b);
3501 DOSET (FLG_EXPORTLOCAL, FALSE);
3502 DOSET (FLG_DECLUNDEF, FALSE);
3503 DOSET (FLG_SPECUNDEF, FALSE);
3504 DOSET (FLG_TOPUNUSED, FALSE);
3508 DOSET (FLG_LOOPLOOPBREAK, b);
3509 DOSET (FLG_LOOPSWITCHBREAK, b);
3510 DOSET (FLG_SWITCHLOOPBREAK, b);
3511 DOSET (FLG_SWITCHSWITCHBREAK, b);
3512 DOSET (FLG_LOOPLOOPCONTINUE, b);
3513 DOSET (FLG_DEEPBREAK, b);
3516 DOSET (FLG_ACCESSMODULE, b);
3517 DOSET (FLG_ACCESSFILE, b);
3518 DOSET (FLG_ACCESSCZECH, b);
3521 DOSET (FLG_ALLMACROS, b);
3522 DOSET (FLG_FCNMACROS, b);
3523 DOSET (FLG_CONSTMACROS, b);
3526 if (b) { DOSET (FLG_ACCESSCZECH, b); }
3527 DOSET (FLG_CZECHFUNCTIONS, b);
3528 DOSET (FLG_CZECHVARS, b);
3529 DOSET (FLG_CZECHCONSTANTS, b);
3530 DOSET (FLG_CZECHTYPES, b);
3533 if (b) { DOSET (FLG_ACCESSSLOVAK, b); }
3534 DOSET (FLG_SLOVAKFUNCTIONS, b);
3535 DOSET (FLG_SLOVAKVARS, b);
3536 DOSET (FLG_SLOVAKCONSTANTS, b);
3537 DOSET (FLG_SLOVAKTYPES, b);
3539 case FLG_CZECHOSLOVAK:
3540 if (b) { DOSET (FLG_ACCESSCZECHOSLOVAK, b); }
3541 DOSET (FLG_CZECHOSLOVAKFUNCTIONS, b);
3542 DOSET (FLG_CZECHOSLOVAKVARS, b);
3543 DOSET (FLG_CZECHOSLOVAKCONSTANTS, b);
3544 DOSET (FLG_CZECHOSLOVAKTYPES, b);
3547 DOSET (FLG_NULLSTATE, b);
3548 DOSET (FLG_NULLDEREF, b);
3549 DOSET (FLG_NULLASSIGN, b);
3550 DOSET (FLG_NULLPASS, b);
3551 DOSET (FLG_NULLRET, b);
3554 DOSET (FLG_NULLSTATE, b);
3555 DOSET (FLG_NULLDEREF, b);
3556 DOSET (FLG_NULLASSIGN, b);
3557 DOSET (FLG_NULLPASS, b);
3558 DOSET (FLG_NULLRET, b);
3559 DOSET (FLG_COMPDEF, b);
3560 DOSET (FLG_COMPMEMPASS, b);
3561 DOSET (FLG_UNIONDEF, b);
3562 DOSET (FLG_MEMTRANS, b);
3563 DOSET (FLG_USERELEASED, b);
3564 DOSET (FLG_ALIASUNIQUE, b);
3565 DOSET (FLG_MAYALIASUNIQUE, b);
3566 DOSET (FLG_MUSTFREE, b);
3567 DOSET (FLG_MUSTDEFINE, b);
3568 DOSET (FLG_GLOBSTATE, b);
3569 DOSET (FLG_COMPDESTROY, b);
3570 DOSET (FLG_MUSTNOTALIAS, b);
3571 DOSET (FLG_MEMIMPLICIT, b);
3572 DOSET (FLG_BRANCHSTATE, b);
3573 /*@fallthrough@*/ /* also sets memtrans flags */
3575 DOSET (FLG_MEMTRANS, b);
3576 DOSET (FLG_EXPOSETRANS, b);
3577 DOSET (FLG_OBSERVERTRANS, b);
3578 DOSET (FLG_DEPENDENTTRANS, b);
3579 DOSET (FLG_NEWREFTRANS, b);
3580 DOSET (FLG_ONLYTRANS, b);
3581 DOSET (FLG_OWNEDTRANS, b);
3582 DOSET (FLG_FRESHTRANS, b);
3583 DOSET (FLG_SHAREDTRANS, b);
3584 DOSET (FLG_TEMPTRANS, b);
3585 DOSET (FLG_KEPTTRANS, b);
3586 DOSET (FLG_REFCOUNTTRANS, b);
3587 DOSET (FLG_STATICTRANS, b);
3588 DOSET (FLG_UNKNOWNTRANS, b);
3589 DOSET (FLG_KEEPTRANS, b);
3590 DOSET (FLG_IMMEDIATETRANS, b);
3594 llcontbug (message ("Unhandled special flag: %s",
3595 flagcode_unparse (f)));
3601 if (flagcode_isIdemFlag (f))
3607 if (b && !gc.anyExports
3608 && (f == FLG_EXPORTVAR || f == FLG_EXPORTFCN
3609 || f == FLG_EXPORTTYPE || f == FLG_EXPORTMACRO
3610 || f == FLG_EXPORTCONST
3611 || f == FLG_EXPORTANY))
3613 gc.anyExports = TRUE;
3622 context_maybeSet (flagcode d)
3624 return (gc.flags[d] || gc.setLocally[d]);
3628 context_getFlag (flagcode d)
3630 return (gc.flags[d]);
3633 static void context_saveFlagSettings (void)
3635 gc.savedFlags = TRUE;
3636 llassert (sizeof (gc.saveflags) == sizeof (gc.flags));
3637 memcpy (gc.saveflags, gc.flags, sizeof (gc.flags));
3640 static void context_restoreFlagSettings (void)
3642 llassert (sizeof (gc.saveflags) == sizeof (gc.flags));
3643 memcpy (gc.flags, gc.saveflags, sizeof (gc.flags));
3644 gc.savedFlags = FALSE;
3647 void context_setFilename (fileId fid, int lineno)
3648 /*@globals fileloc g_currentloc;@*/
3649 /*@modifies g_currentloc@*/
3651 if (fileId_baseEqual (currentFile (), fid))
3658 fileloc_setColumn (g_currentloc, 0);
3660 if (fileloc_isSpecialFile (g_currentloc))
3662 gc.inDerivedFile = TRUE;
3665 if (filelocStack_popPushFile (gc.locstack, g_currentloc))
3667 int maxdepth = context_getValue (FLG_INCLUDENEST);
3669 if (filelocStack_size (gc.locstack) > maxdepth)
3671 int depth = filelocStack_includeDepth (gc.locstack);
3673 if (depth > maxdepth)
3677 message ("Maximum include nesting depth "
3678 "(%d, current depth %d) exceeded",
3681 filelocStack_nextTop (gc.locstack)))
3683 filelocStack_printIncludes (gc.locstack);
3689 g_currentloc = fileloc_create (fid, lineno, 1);
3690 gc.inheader = fileId_isHeader (currentFile ());
3692 context_enterFileAux ();
3696 void context_enterIterDef (/*@observer@*/ uentry le)
3698 context_enterMacro (le);
3699 gc.acct = typeIdSet_subtract (gc.facct, gc.nacct);
3700 gc.kind = CX_ITERDEF;
3703 void context_enterIterEnd (/*@observer@*/ uentry le)
3705 context_enterMacro (le);
3706 gc.kind = CX_ITEREND;
3710 context_destroyMod (void)
3711 /*@globals killed gc@*/
3714 ctype_destroyMod ();
3718 fileTable_free (gc.ftab);
3719 filelocStack_free (gc.locstack);
3721 gc.ftab = fileTable_undefined;
3723 macrocache_free (gc.mc);
3724 sfree (gc.moduleaccess);
3727 fileloc_free (gc.saveloc); gc.saveloc = fileloc_undefined;
3728 fileloc_free (gc.pushloc); gc.pushloc = fileloc_undefined;
3731 sRefSetList_free (gc.modrecs);
3733 flagMarkerList_free (gc.markers);
3735 messageLog_free (gc.msgLog);
3737 clauseStack_free (gc.clauses);
3740 cstring_free (gc.msgAnnote);
3741 globSet_free (gc.globs_used);
3748 bool context_msgBoolInt (void)
3750 return gc.flags [FLG_BOOLINT];
3753 bool context_msgCharInt (void)
3755 return gc.flags [FLG_CHARINT];
3758 bool context_msgEnumInt (void)
3760 return gc.flags [FLG_ENUMINT];
3763 bool context_msgPointerArith (void)
3765 return gc.flags [FLG_POINTERARITH];
3768 bool context_msgStrictOps (void)
3770 return gc.flags [FLG_STRICTOPS];
3774 bool context_msgLh (void)
3776 return gc.flags [FLG_DOLH];
3780 void context_pushLoc (void)
3782 fileloc_free (gc.pushloc);
3783 gc.pushloc = gc.saveloc;
3784 gc.saveloc = fileloc_undefined;
3787 void context_popLoc (void)
3789 gc.saveloc = fileloc_update (gc.saveloc, gc.pushloc);
3792 bool context_inGlobalScope (void)
3794 return (usymtab_inFileScope() || usymtab_inGlobalScope ());
3797 bool context_inInnerScope (void)
3799 return (gc.kind == CX_INNER);
3802 void context_setProtectVars (void)
3804 gc.protectVars = TRUE;
3807 bool context_anyErrors (void)
3809 return (gc.numerrors > 0);
3812 void context_hasError (void)
3817 int context_numErrors (void)
3819 return gc.numerrors;
3822 bool context_neednl (void)
3827 void context_setNeednl (void)
3832 int context_getExpect (void)
3834 return (context_getValue (FLG_EXPECT));
3838 int context_getLCLExpect (void)
3840 return (context_getValue (FLG_LCLEXPECT));
3844 int context_getLimit (void)
3846 return (context_getValue (FLG_LIMIT));
3849 bool context_unlimitedMessages (void)
3851 return (context_getLimit () < 0);
3854 void context_releaseVars (void)
3856 llassert (gc.protectVars);
3857 gc.protectVars = FALSE;
3860 void context_sizeofReleaseVars (void)
3862 /* If there is a nested sizeof, this might not hold:
3863 llassert (gc.protectVars);
3866 gc.protectVars = FALSE;
3869 bool context_inProtectVars (void)
3871 return (gc.protectVars);
3874 void context_hideShowscan (void)
3876 gc.flags[FLG_SHOWSCAN] = FALSE;
3879 void context_unhideShowscan (void)
3881 gc.flags[FLG_SHOWSCAN] = TRUE;
3884 bool context_inHeader (void)
3886 return (gc.inheader);
3889 fileTable context_fileTable (void)
3894 cstring context_tmpdir (void)
3896 return (context_getString (FLG_TMPDIR));
3899 messageLog context_messageLog (void)
3904 bool context_inMacroFunction (void)
3906 return (gc.kind == CX_MACROFCN);
3909 bool context_inMacroConstant (void)
3911 return (gc.kind == CX_MACROCONST);
3914 bool context_inMacroUnknown (void)
3916 return (gc.kind == CX_UNKNOWNMACRO);
3919 void context_setShownFunction (void)
3921 gc.showfunction = FALSE;
3924 bool context_doDump (void)
3926 return cstring_isNonEmpty (context_getString (FLG_DUMP));
3929 bool context_doMerge (void)
3931 return cstring_isNonEmpty (context_getString (FLG_MERGE));
3934 cstring context_getDump (void)
3936 return context_getString (FLG_DUMP);
3939 cstring context_getMerge (void)
3941 return context_getString (FLG_MERGE);
3945 bool context_inLCLLib (void)
3947 return (gc.kind == CX_LCLLIB);
3950 bool context_inImport (void)
3952 return (gc.inimport);
3955 void context_enterImport (void)
3960 void context_leaveImport (void)
3962 gc.inimport = FALSE;
3966 bool context_inMacro (void)
3968 return (gc.kind == CX_MACROFCN || gc.kind == CX_MACROCONST
3969 || gc.kind == CX_UNKNOWNMACRO
3970 || gc.kind == CX_ITERDEF || gc.kind == CX_ITEREND);
3973 bool context_inIterDef (void)
3975 return (gc.kind == CX_ITERDEF);
3978 bool context_inIterEnd (void)
3980 return (gc.kind == CX_ITEREND);
3983 int context_getLinesProcessed (void)
3985 return (gc.linesprocessed);
3988 int context_getSpecLinesProcessed (void)
3990 return (gc.speclinesprocessed);
3994 void context_processedSpecLine (void)
3996 gc.speclinesprocessed++;
3999 void context_resetSpecLines (void)
4001 gc.speclinesprocessed = 0;
4005 bool context_inGlobalContext (void)
4007 return (gc.kind == CX_GLOBAL);
4010 void context_setFileId (fileId s)
4012 g_currentloc = fileloc_updateFileId (g_currentloc, s);
4015 bool context_setBoolName (void)
4017 return (!cstring_equalLit (context_getString (FLG_BOOLTYPE),
4021 cstring context_printBoolName (void)
4023 if (context_setBoolName ())
4025 return context_getBoolName ();
4029 return cstring_makeLiteralTemp ("boolean");
4033 cstring context_getBoolName (void)
4035 return (context_getString (FLG_BOOLTYPE));
4038 cstring context_getFalseName (void)
4040 return (context_getString (FLG_BOOLFALSE));
4043 cstring context_getTrueName (void)
4045 return (context_getString (FLG_BOOLTRUE));
4048 cstring context_getLarchPath (void)
4050 return (context_getString (FLG_LARCHPATH));
4053 cstring context_getLCLImportDir (void)
4055 return (context_getString (FLG_LCLIMPORTDIR));
4058 static void context_setJustPopped (void)
4060 gc.justpopped = TRUE;
4063 void context_clearJustPopped (void)
4065 gc.justpopped = FALSE;
4068 bool context_justPopped (void)
4070 return (gc.justpopped);
4073 void context_setMacroMissingParams (void)
4075 gc.macroMissingParams = TRUE;
4078 void context_resetMacroMissingParams (void)
4080 gc.macroMissingParams = FALSE;
4083 bool context_isMacroMissingParams (void)
4085 return (gc.macroMissingParams);