home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchk294s.zip / ftnchek-2.9.4 / ftnchek.h < prev    next >
C/C++ Source or Header  |  1996-09-13  |  32KB  |  927 lines

  1. /* ftnchek.h:
  2.  
  3.     Common definitions for Fortran Program Checker
  4.  
  5.     Copyright (C) 1994 by Robert K. Moniot.
  6.     This program is free software.  Permission is granted to
  7.     modify it and/or redistribute it, retaining this notice.
  8.     No guarantees accompany this software.
  9.  
  10. */
  11.  
  12. #define COPYRIGHT_DATE \
  13. "Copyright (C) 1994, 1995, 1996 by Robert K. Moniot"
  14. #define COPYRIGHT_NOTICE \
  15. "This program is free software.  Permission is granted to\n\
  16. modify it and/or redistribute it, retaining this notice.\n\
  17. No guarantees accompany this software."
  18. #define VERSION_NUMBER        "FTNCHEK Version 2.9 April 1996"
  19. #define PATCHLEVEL        "Patch Level 4"
  20. #define PROJECT_VERSION        "P2" /* Project file format version number */
  21.  
  22.         /* Define macro PROTO for declaring function prototypes.  If
  23.            compiler doesn't accept prototypes, use -DNO_PROTOTYPES.
  24.            The args in macro must be enclosed in parentheses.
  25.            Define macro VOID for declaring functions without
  26.            args.  Also define HAVE_STDC for declaring functions
  27.            in ANSI form or Kernighan-Ritchie form.  Each function
  28.            defn is in both forms, with #ifdef HAVE_STDC to select
  29.            between them.
  30.          */
  31.  
  32. #ifdef NO_PROTOTYPES
  33. #define PROTO(TYPE_AND_NAME,ARGS) TYPE_AND_NAME()
  34. #define VOID
  35. #define HAVE_STDC    0
  36. #else
  37. #define PROTO(TYPE_AND_NAME,ARGS) TYPE_AND_NAME ARGS
  38. #define VOID        void
  39. #define HAVE_STDC    1
  40. #endif
  41.  
  42.     /* The following system defines should be defined with the -D
  43.        (for UNIX) or /DEFINE (for VMS) compiler options in the makefile,
  44.        not here.  They are shown here so you know what to define.
  45.     */
  46.  
  47. /*#define VMS*/        /* Set flag for VAX/VMS   system-dependent defns. */
  48. /*#define UNIX*/    /* Set flag for UNIX (ATT or BSD) defns. */
  49. #ifdef __TURBOC__
  50. #define MSDOS        /* Set flag for MSDOS (IBM PC) */
  51. #define T_ALLOC        /* Specify workaround for malloc limits */
  52. #endif
  53.  
  54. #ifdef MSDOS
  55. #define NO_FLOATING_POINT    /* No need for floating point coprocessor */
  56. #endif
  57.             /* For portability, declare standard routines here. */
  58. #if defined(__STDC__) || defined(__osf__)
  59. #include <stdlib.h>
  60. #else
  61. PROTO(char *getenv,(char *));
  62. PROTO(char *malloc,(unsigned));
  63. PROTO(char *calloc,(unsigned,unsigned));
  64. PROTO(void exit,(int));
  65. #endif
  66.  
  67.  
  68. /*************************************************************************
  69.      Begin section of defines for system-dependent configuration.
  70. **************************************************************************/
  71.  
  72.  
  73.     /* set flag to allow options to start with '/' */
  74. #ifndef OPTION_PREFIX_SLASH
  75. #ifndef NO_OPTION_PREFIX_SLASH
  76. #ifdef VMS
  77. #define OPTION_PREFIX_SLASH
  78. #endif
  79. #ifdef MSDOS
  80. #define OPTION_PREFIX_SLASH
  81. #endif
  82. #endif
  83. #endif
  84.  
  85.             /* Define standard home directory for VMS.  This
  86.                is one place it looks for rc file.  You can
  87.                also define SPECIAL_HOMEDIR for other systems
  88.                such as MSDOS or Mac. */
  89. #ifdef VMS
  90. #ifndef SPECIAL_HOMEDIR
  91. #define SPECIAL_HOMEDIR "SYS$DISK:[]"
  92. #endif
  93. #endif
  94.  
  95.     /* Define the Unix-style startup file name and a non-Unix-style
  96.        alternate.  Both are looked for on all systems. */
  97.  
  98. #ifndef UNIX_RC_FILE
  99. #define UNIX_RC_FILE    ".ftnchekrc"
  100. #endif
  101. #ifndef NONUNIX_RC_FILE
  102. #define NONUNIX_RC_FILE    "ftnchek.ini"
  103. #endif
  104.  
  105.         /* Define default source and output file extensions.  These
  106.          * can be overridden by defines on compiler commandline.
  107.          */
  108. #ifndef DEF_SRC_EXTENSION
  109. #ifdef VMS
  110. #define DEF_SRC_EXTENSION ".for"        /* VMS default extension */
  111. #endif
  112. #ifdef MSDOS
  113. #define DEF_SRC_EXTENSION ".for"        /* IBM PC default extension */
  114. #endif
  115. #endif /* DEF_SRC_EXTENSION */
  116.  
  117. #ifndef DEF_SRC_EXTENSION
  118. #define DEF_SRC_EXTENSION ".f"        /* Unix and all others */
  119. #endif
  120.         /* define default list-file extension */
  121. #ifndef DEF_LIST_EXTENSION
  122. #define DEF_LIST_EXTENSION ".lis"
  123. #endif
  124.         /* define default project-file extension */
  125. #ifndef DEF_PROJ_EXTENSION
  126. #define DEF_PROJ_EXTENSION ".prj"
  127. #endif
  128.         /* define default declaration-file extension */
  129. #ifndef DEF_DCL_EXTENSION
  130. #define DEF_DCL_EXTENSION ".dcl"
  131. #endif
  132.         /* define default include-file extension */
  133. #ifndef DEF_INC_EXTENSION
  134. #define DEF_INC_EXTENSION DEF_SRC_EXTENSION
  135. #endif
  136.         /* define default declaration-file extension */
  137. #ifndef DEF_VCG_EXTENSION
  138. #define DEF_VCG_EXTENSION ".vcg"
  139. #endif
  140.         /* define project-file name for case of input from stdin */
  141. #ifndef STDIN_PROJ_FILENAME
  142. #define STDIN_PROJ_FILENAME "ftnchek.prj"
  143. #endif
  144.  
  145. #ifndef ENV_PREFIX        /* prefix for option environment variables */
  146. #define ENV_PREFIX "FTNCHEK_"
  147. #endif
  148.  
  149. #ifndef ENV_INCLUDE_VAR
  150. #define ENV_INCLUDE_VAR "INCLUDE" /* name of env variable for include dir */
  151. #endif
  152.  
  153. #ifndef DEFAULT_INCLUDE_DIR
  154. #ifdef UNIX
  155. #define DEFAULT_INCLUDE_DIR "/usr/include"
  156. #endif
  157. #ifdef VMS
  158. #define DEFAULT_INCLUDE_DIR "SYS$LIBRARY:"
  159. #endif
  160. #ifdef MSDOS
  161. #define DEFAULT_INCLUDE_DIR "\\include"
  162. #endif
  163. #endif
  164.  
  165. /*************************************************************************
  166.      End of section of defines for system-dependent configuration.
  167.  
  168.     Begin section of defines to control ftnchek's behavior
  169.           (syntax accepted, options supported, etc.)
  170. **************************************************************************/
  171.  
  172.  
  173.  
  174.  
  175.                 /* The following macros define the default
  176.                    value of the -source setting */
  177.  
  178. #ifndef DEC_TABS    /* DEC-style ugly tabbed source is off by default */
  179. #define DEC_TABS 0
  180. #endif
  181.             /* VMS-style INCLUDE supports defaulting
  182.                extension, /NOLIST feature.  It is default
  183.                for VMS, not for other systems. */
  184. #ifndef VMS_INCLUDE
  185. #ifdef VMS
  186. #define VMS_INCLUDE 1
  187. #else
  188. #define VMS_INCLUDE 0
  189. #endif
  190. #endif
  191.  
  192. #ifndef UNIX_BACKSLASH    /* UNIX backslash escape sequences in strings */
  193. #define UNIX_BACKSLASH 0
  194. #endif
  195.  
  196.             /* This is the default -source value */
  197. #define DEF_SOURCE_FORMAT (DEC_TABS+2*VMS_INCLUDE+4*UNIX_BACKSLASH)
  198.  
  199.  
  200.     /* VCG support is now standard. If you don't want it, you can
  201.        eliminate it by defining NO_VCG_SUPPORT.  You can customize
  202.        the graph options by changing the macro VCG_GRAPH_OPTIONS.
  203.        Include \n between options and after the last option.
  204.        (These options affect the graph as a whole.)  */
  205.  
  206. #ifndef NO_VCG_SUPPORT
  207. #define VCG_SUPPORT
  208. #ifndef VCG_GRAPH_OPTIONS
  209. #define VCG_GRAPH_OPTIONS "color: lightgray\n"
  210. #endif
  211. #endif
  212.  
  213.     /* The following defines control the default status of
  214.        warnings controlled by -f77, -port, -pretty, and -trunc.
  215.      */
  216.  
  217.             /* -f77 options default to F77_ALL.  Define
  218.                STRICT_SYNTAX to make -f77=all the default.
  219.                Otherwise -f77=none is default.
  220.             */
  221. #ifdef STRICT_SYNTAX
  222. #define F77_ALL 1
  223. #else
  224. #define F77_ALL 0
  225. #endif
  226.  
  227.             /* -portability options default to PORT_ALL.  Define
  228.                STRICT_PORTABILITY to make -port=all the default.
  229.                Otherwise -port=none is default.
  230.             */
  231. #ifdef STRICT_PORTABILITY
  232. #define PORT_ALL TRUE
  233. #else
  234. #define PORT_ALL FALSE
  235. #endif
  236.  
  237.             /* -pretty options default to PRETTY_ALL.  Define
  238.                UGLY_IS_OK to make -pretty=none the default.
  239.                Otherwise -pretty=all is default.
  240.             */
  241. #ifdef UGLY_IS_OK
  242. #define PRETTY_ALL FALSE
  243. #else
  244. #define PRETTY_ALL TRUE
  245. #endif
  246.  
  247.             /* -truncation options default to TRUNC_ALL.  Define
  248.                LAX_TRUNCATION to make -trunc=none the default.
  249.                Otherwise -trunc=all is default.
  250.             */
  251. #ifdef LAX_TRUNCATION
  252. #define TRUNC_ALL FALSE
  253. #else
  254. #define TRUNC_ALL TRUE
  255. #endif
  256.  
  257.  
  258.         /* If STANDARD_INTRINSICS is defined, only F77
  259.            standard intrinsic functions (plus double complex
  260.            flavors of standard ones) will be known to ftnchek.
  261.            Otherwise there are three classes of nonstandard
  262.            intrinsics: common, Unix flavor, and VMS flavor.
  263.            Common ones will be recognized if -intrinsic=
  264.            nonzero.  -intrinsic= 2 or 3 specify UNIX or VMS
  265.            rsptly, unless suppressed with NO_UNIX_INTRINSICS
  266.            or NO_VMS_INTRINSICS.  */
  267.  
  268. #ifndef STANDARD_INTRINSICS
  269.  
  270. #define NONSTD_INTRINSICS    /* Common nonstandard intrinsic functions */
  271.  
  272. #ifndef NO_UNIX_INTRINSICS
  273. #define UNIX_INTRINSICS        /* UNIX intrinsic functions */
  274. #endif
  275.     /* Note: RAND syntax varies.  Define RAND_NO_ARG to make ftnchek
  276.        expect X=RAND(). By default ftnchek expects X=RAND(ISEED).
  277.      */
  278.  
  279. #ifndef NO_VMS_INTRINSICS
  280. #define VMS_INTRINSICS        /* VMS intrinsic functions */
  281. #endif
  282.  
  283. #endif /* not STANDARD_INTRINSICS */
  284.  
  285.             /* Define the default -intrinsic setting */
  286.  
  287.                 /* Define which set to use */
  288. #ifdef UNIX    /* Unix default: accept Unix intrinsics */
  289. #define DEF_INTRINSIC_SET 2
  290. #endif
  291.  
  292. #ifdef VMS    /* VMS default: accept VMS intrinsics */
  293. #define DEF_INTRINSIC_SET 3
  294. #endif
  295.  
  296. #ifndef DEF_INTRINSIC_SET    /* Neither one: use only common set */
  297. #define DEF_INTRINSIC_SET 1
  298. #endif
  299.  
  300.                 /* Define which RAND form to use */
  301. #ifdef RAND_NO_ARG    /*RAND() form*/
  302. #define DEF_INTRINSIC_RAND 0
  303. #else
  304. #ifdef RAND_ONE_ARG    /*RAND(ISEED) form*/
  305. #define DEF_INTRINSIC_RAND 1
  306. #else                /* Allow either form */
  307. #define DEF_INTRINSIC_RAND 2
  308. #endif
  309. #endif
  310.  
  311.                 /* Define which IARGC form to use */
  312. #ifdef IARGC_NO_ARG
  313. #define DEF_INTRINSIC_IARG 0
  314. #else
  315. #ifdef IARGC_ONE_ARG
  316. #define DEF_INTRINSIC_IARG 1
  317. #else  /* default is to allow 0 or 1 */
  318. #define DEF_INTRINSIC_IARG 2
  319. #endif
  320. #endif
  321.                 /* Now define the default setting from
  322.                    the above choices. */
  323. #define DEF_INTRINSIC_OPT (DEF_INTRINSIC_IARG*100 + DEF_INTRINSIC_RAND*10 \
  324.                + DEF_INTRINSIC_SET)
  325.  
  326.  
  327.  
  328. /*  Default BpW = 4 bytes per word, which matches many machines.
  329.     This macro serves as the default value for -wordsize.
  330.     If the Fortran code does not declare explicit sizes of
  331.     numeric variables (e.g. REAL*8), then the value of -wordsize will
  332.     not matter, since the table conforms to the standard in that
  333.     sizeof(INTEGER)=sizeof(REAL), and sizeof(DOUBLE)=sizeof(COMPLEX)
  334.     =2*sizeof(REAL).  If the code does declare explicit sizes of
  335.     numeric types, then the value of -wordsize will matter if explicit
  336.     and default sizes are expected to match.  If you want to
  337.     suppress warnings of this kind, you may use the -wordsize setting
  338.     or, to make it the default, change BpW to match
  339.     your hardware.  Under the -portability option, explicit and
  340.     default sizes never match: e.g. passing REAL*8 where DOUBLE
  341.     PRECISION expected.  None of this applies to CHARACTER data:
  342.     the default size (1) is well-defined, and the standard does
  343.     not specify the ratio of sizeof(CHARACTER) to sizeof(REAL). */
  344.  
  345. #ifndef BpW
  346. #define BpW 4    /* Bytes per Word: might want to use sizeof(float) instead */
  347. #endif
  348.  
  349.         /* Define to tolerate embedded blanks in numeric consts unless
  350.            feature turned off by defining NO_BLANKS_IN_NUMBERS. */
  351. #ifndef NO_BLANKS_IN_NUMBERS
  352. #define BLANKS_IN_NUMBERS
  353. #endif
  354.  
  355.                 /* Default value of -wrap option */
  356. #ifndef WRAP_COLUMN
  357. #define WRAP_COLUMN 79        /* When to wrap error messages to next line */
  358. #endif
  359.  
  360.         /* The following defines used to be optional, now they
  361.            are standard. If these defines are removed or
  362.            undef'd, the corresponding syntax will not be
  363.            recognized (resulting in parse errors).  I don't
  364.            recommend undefining them.  They are all warned about
  365.            by -f77 */
  366.  
  367. #define ALLOW_CRAY_POINTERS 1
  368. #define ALLOW_DOLLARSIGNS 1
  369. #define ALLOW_DO_ENDDO 1
  370. #define ALLOW_INCLUDE 1
  371. #define ALLOW_QUOTEMARKS 1
  372. #define ALLOW_TYPELESS_CONSTANTS 1
  373. #define ALLOW_UNDERSCORES 1
  374. #define ALLOW_UNIX_BACKSLASH 1
  375. #define ALLOW_UNIX_CPP 1
  376. #define ALLOW_VMS_IO 1
  377.  
  378.     /* If INLINE_COMMENT_CHAR is not defined, ! comments will cause
  379.        ftnchek to choke.  F77_INLINE_COMMENT controls whether it
  380.        is handled but warned about.
  381.     */
  382. #ifndef NO_INLINE_COMMENT
  383. #define INLINE_COMMENT_CHAR '!' /* Inline comments starting with '!' */
  384. #endif
  385.  
  386. #define KEEP_ARG_NAMES 1    /* option was formerly experimental */
  387.  
  388. /*************************************************************************
  389.      End section of defines to control ftnchek's behavior
  390.  
  391.       Begin section to define limits, table sizes, etc.
  392. **************************************************************************/
  393.  
  394.  
  395.  
  396.  
  397. #ifndef MAXLINE
  398. #define MAXLINE 132    /* Maximum input line length.  Ignores past this. */
  399. #endif
  400. #ifndef MAXIDSIZE
  401. #define MAXIDSIZE 31    /* Longest identifier allowed */
  402. #endif
  403. #ifndef MAX_SRC_TEXT
  404. #define MAX_SRC_TEXT (20*66) /* Longest text string of a token */
  405. #endif
  406. #ifndef MAX_CHAR_CODE
  407. #define MAX_CHAR_CODE 255 /* Largest possible value of a char (8 bits here) */
  408. #endif
  409. #ifndef MAX_INCLUDE_DEPTH
  410. #define MAX_INCLUDE_DEPTH 16    /* Max nesting depth of include files */
  411. #endif
  412. #ifndef MAXEXPRTEXT
  413. #define MAXEXPRTEXT 15        /* length of expr text saved in arg lists */
  414. #endif
  415. #ifndef MAX_RC_LINE
  416. #define MAX_RC_LINE 500        /* Max length of line in rc file */
  417. #endif
  418. #ifndef RC_COMMENT_CHAR
  419. #define RC_COMMENT_CHAR '#'    /* Comments start with this or space  */
  420. #endif
  421.         /* Definitions of table sizes
  422.              Constraints:
  423.             STRSPACESZ > 20*72 so max f77 statement will fit
  424.             LOCSYMTABSZ+GLOBSYMTABSZ < HASHSZ so hashtab never full
  425.          */
  426.  
  427. #define KEYHASHSZ 195    /* Size of keyword hashtable -- do not change */
  428. #define INTRINS_HASHSZ 433 /* Chosen to give few clashes -- change with care */
  429.  
  430. #ifdef SMALL_MACHINE        /* Use these for e.g. IBM PC */
  431. #ifndef HASHSZ            /* Hint: pick one with no square factors */
  432. #define HASHSZ 798     /* SMALL_MACHINE Size of symbol hashtable */
  433. #endif
  434. #ifndef STRSPACESZ
  435. #define STRSPACESZ 4000 /* SMALL_MACHINE chunk size of string space */
  436. #endif
  437. #ifndef LOCSYMTABSZ
  438. #define LOCSYMTABSZ 300 /* SMALL_MACHINE Size of local symbol table */
  439. #endif
  440. #ifndef GLOBSYMTABSZ
  441. #define GLOBSYMTABSZ 400 /* SMALL_MACHINE Size of global symbol table */
  442. #endif
  443. #ifndef PARAMINFOSPACESZ
  444. #define PARAMINFOSPACESZ 20 /* SMALL_MACHINE ParamInfo structs per chunk */
  445. #endif
  446. #ifndef TOKHEADSPACESZ
  447. #define TOKHEADSPACESZ 50 /* SMALL_MACHINE TokenListHeaders per chunk */
  448. #endif
  449. #ifndef TOKENSPACESZ
  450. #define TOKENSPACESZ 200 /* SMALL_MACHINE tokens per token space chunk */
  451. #endif
  452. #ifndef ARGLISTHEADSZ
  453. #define ARGLISTHEADSZ    300 /* SMALL_MACHINE argument headers per chunk */
  454. #endif
  455. #ifndef ARGLISTELTSZ
  456. #define ARGLISTELTSZ    1000 /* SMALL_MACHINE argument list elts per chunk */
  457. #endif
  458. #ifndef COMLISTHEADSZ
  459. #define COMLISTHEADSZ    200 /* SMALL_MACHINE common list headers per chunk */
  460. #endif
  461. #ifndef COMLISTELTSZ
  462. #define COMLISTELTSZ    1000 /* SMALL_MACHINE common elts per chunk */
  463. #endif
  464. #ifndef PTRSPACESZ
  465. #define PTRSPACESZ    200  /* SMALL_MACHINE ptrs-to-arraydim per chunk */
  466. #endif
  467.  
  468. #else  /* end if SMALL_MACHINE */
  469.  
  470. #ifdef LARGE_MACHINE        /* use these if space is no problem */
  471. #ifndef HASHSZ        /* must be <= max int  */
  472. #define HASHSZ 20930     /* LARGE_MACHINE Size of symbol hashtable */
  473. #endif
  474. #ifndef STRSPACESZ
  475. #define STRSPACESZ 10000 /* LARGE_MACHINE chunk size of string space */
  476. #endif
  477. #ifndef LOCSYMTABSZ
  478. #define LOCSYMTABSZ 8000 /* LARGE_MACHINE Size of local symbol table */
  479. #endif
  480. #ifndef GLOBSYMTABSZ
  481. #define GLOBSYMTABSZ 12000 /* LARGE_MACHINE Size of global symbol table */
  482. #endif
  483. #ifndef PARAMINFOSPACESZ
  484. #define PARAMINFOSPACESZ 200 /* LARGE_MACHINE ParamInfo structs per chunk */
  485. #endif
  486. #ifndef TOKHEADSPACESZ
  487. #define TOKHEADSPACESZ 500 /* LARGE_MACHINE TokenListHeaders per chunk */
  488. #endif
  489. #ifndef TOKENSPACESZ
  490. #define TOKENSPACESZ 10000 /* LARGE_MACHINE tokens per token space chunk */
  491. #endif
  492. #ifndef ARGLISTHEADSZ
  493. #define ARGLISTHEADSZ    15000 /* LARGE_MACHINE argument headers per chunk */
  494. #endif
  495. #ifndef ARGLISTELTSZ
  496. #define ARGLISTELTSZ    50000    /* LARGE_MACHINE argument list elts per chunk */
  497. #endif
  498. #ifndef COMLISTHEADSZ
  499. #define COMLISTHEADSZ    10000 /* LARGE_MACHINE common list headers per chunk */
  500. #endif
  501. #ifndef COMLISTELTSZ
  502. #define COMLISTELTSZ    50000 /* LARGE_MACHINE common elts per chunk */
  503. #endif
  504. #ifndef PTRSPACESZ
  505. #define PTRSPACESZ    2000 /* LARGE_MACHINE Max number of ptrs to arraydim */
  506. #endif
  507.  
  508. #else        /* Defaults: Use these for average-size applications */
  509.  
  510. #ifndef HASHSZ
  511. #define HASHSZ 2002    /* Default Size of symbol hashtable */
  512. #endif
  513. #ifndef STRSPACESZ
  514. #define STRSPACESZ 10000 /* Default chunk size of string space */
  515. #endif
  516. #ifndef LOCSYMTABSZ
  517. #define LOCSYMTABSZ 800 /* Default Size of local symbol table */
  518. #endif
  519. #ifndef GLOBSYMTABSZ
  520. #define GLOBSYMTABSZ 1200 /* Default Size of global symbol table */
  521. #endif
  522. #ifndef PARAMINFOSPACESZ
  523. #define PARAMINFOSPACESZ 50 /* Default ParamInfo structs per chunk */
  524. #endif
  525. #ifndef TOKHEADSPACESZ
  526. #define TOKHEADSPACESZ 200 /* Default TokenListHeaders per chunk */
  527. #endif
  528. #ifndef TOKENSPACESZ
  529. #define TOKENSPACESZ 1000 /* Default tokens per token space chunk */
  530. #endif
  531. #ifndef ARGLISTHEADSZ
  532. #define ARGLISTHEADSZ    1500 /* Default argument headers per chunk */
  533. #endif
  534. #ifndef ARGLISTELTSZ
  535. #define ARGLISTELTSZ    5000    /* Default argument list elts per chunk */
  536. #endif
  537. #ifndef COMLISTHEADSZ
  538. #define COMLISTHEADSZ    1000 /* Default common list headers per chunk */
  539. #endif
  540. #ifndef COMLISTELTSZ
  541. #define COMLISTELTSZ    4000 /* Default common elts per chunk */
  542. #endif
  543. #ifndef PTRSPACESZ
  544. #define PTRSPACESZ    400 /* Default Max number of ptrs to arraydim */
  545. #endif
  546.  
  547. #endif /* end if LARGE_MACHINE else */
  548.  
  549. #endif/*end if SMALL_MACHINE else*/
  550.  
  551. /*************************************************************************
  552.       End of section to define limits, table sizes, etc.
  553.  
  554.         From here down should not be altered.
  555. **************************************************************************/
  556.  
  557.  
  558.  
  559. #define FALSE 0
  560. #define TRUE 1
  561.  
  562. #define NO_COL_NUM ((unsigned)999)/* Impossible column number to suppress
  563.                  * printing in error messages
  564.                  */
  565. #define NO_LINE_NUM ((unsigned)0)/* Ditto for line number to suppress flushing
  566.                  * of line if error not in local context
  567.                  */
  568.  
  569. #define OOPS_NONFATAL 0        /* Severity of "oops" messages */
  570. #define OOPS_FATAL 1
  571.  
  572. /*************************************************************************
  573.         Shared variable and function defns start here
  574. **************************************************************************/
  575.  
  576. #ifdef MAIN
  577. #define SHARED        /* (nothing) */
  578. #else
  579. #define SHARED extern    /* Non-main routines declare shared vars extern */
  580. #endif
  581.  
  582. #define PRIVATE static    /* For non-shared functions */
  583.  
  584.         /* Ftnchek has no need of floating-point calculations,
  585.            so to allow it to run on machines without coprocessor,
  586.            we neutralize the few floating-point operations.
  587.         */
  588. #ifdef NO_FLOATING_POINT
  589. typedef long DBLVAL;
  590. #else
  591. typedef double DBLVAL;
  592. #endif
  593.  
  594. SHARED FILE
  595.             *input_fd,  /* Input file */
  596.             *list_fd,    /* Output file for listing */
  597.         *dcl_fd,    /* Output type declaration file */
  598. #ifdef VCG_SUPPORT
  599.         *vcg_fd,    /* Output VCG graph description file */
  600. #endif
  601.         *project_fd;/* Project file for symtab info summary */
  602.  
  603. SHARED char *current_filename,    /* name of current input file */
  604.         *top_filename;    /* name of toplevel parent input file */
  605. SHARED int incdepth;
  606.  
  607. #ifdef VCG_SUPPORT
  608. SHARED char *main_filename;    /* name of file containing main program */
  609. #endif
  610.  
  611.  
  612.         /* Declare variables for command line options */
  613. #ifdef MAIN
  614. #define OPT(Type,Name,Value) Type Name=Value
  615. #else
  616. #define OPT(Type,Name,Value) extern Type Name
  617. #endif
  618.  
  619.                 /* Define flag bits for call_tree_options */
  620.                     /* First three are a 2-bit option */
  621. #define CALLTREE_PRINT        0x0001
  622. #define CALLTREE_REFLIST    0x0002
  623. #define CALLTREE_VCG        0x0003
  624.  
  625. #define CALLTREE_NOPRUNE    0x0004 /* expand each node, not "see above" */
  626. #define CALLTREE_NOSORT        0x0008 /* program order, not alphabetized */
  627. #define CALLTREE_WITHARGS    0x0010 /* include args of calls */
  628.  
  629.         /* These options are controlled by -f77 */
  630. OPT(int,f77_20_continue,F77_ALL);
  631. OPT(int,f77_accept_type,F77_ALL);
  632. OPT(int,f77_byte,F77_ALL);
  633. OPT(int,f77_cray_pointers,F77_ALL);
  634. OPT(int,f77_common_subprog_name,F77_ALL);
  635. OPT(int,f77_d_comment,F77_ALL);
  636. OPT(int,f77_dec_tabs,F77_ALL);
  637. OPT(int,f77_do_enddo,F77_ALL);
  638. OPT(int,f77_dollarsigns,F77_ALL);
  639. OPT(int,f77_double_complex,F77_ALL);
  640. OPT(int,f77_format_dollarsigns,F77_ALL);
  641. OPT(int,f77_format_extensions,F77_ALL);
  642. OPT(int,f77_function_noparen,F77_ALL);
  643. OPT(int,f77_implicit_none,F77_ALL);
  644. OPT(int,f77_include,F77_ALL);
  645. OPT(int,f77_inline_comment,F77_ALL);
  646. OPT(int,f77_internal_list_io,F77_ALL);
  647. OPT(int,f77_intrinsics,F77_ALL);
  648. OPT(int,f77_long_names,F77_ALL);
  649. OPT(int,f77_mixed_common,F77_ALL);
  650. OPT(int,f77_mixed_expr,F77_ALL);
  651. OPT(int,f77_namelist,F77_ALL);
  652. OPT(int,f77_overlength,F77_ALL);
  653. OPT(int,f77_param_intrinsic,F77_ALL);
  654. OPT(int,f77_param_noparen,F77_ALL);
  655. OPT(int,f77_quad_constants,F77_ALL);
  656. OPT(int,f77_quotemarks,F77_ALL);
  657. OPT(int,f77_stmt_order,F77_ALL);
  658. OPT(int,f77_typeless_constants,F77_ALL);
  659. OPT(int,f77_typesize,F77_ALL);
  660. OPT(int,f77_underscores,F77_ALL);
  661. OPT(int,f77_unix_backslash,F77_ALL);
  662. OPT(int,f77_unix_cpp,F77_ALL);
  663. OPT(int,f77_variable_format,F77_ALL);
  664. OPT(int,f77_vms_io,F77_ALL);
  665.         /* End of -f77 options */
  666.  
  667.         /* These options are controlled by -portability */
  668. OPT(int,port_common_alignment,PORT_ALL);/* Common not in desc size order */
  669. OPT(int,port_backslash,PORT_ALL);     /* Backslash used in standard way */
  670. OPT(int,port_real_do,PORT_ALL);        /* Non-integer DO loop bounds */
  671. OPT(int,port_long_string,PORT_ALL);    /* Char string > 255 in length */
  672. OPT(int,port_hollerith,PORT_ALL);    /* Hollerith (except in FORMAT) */
  673. OPT(int,port_mixed_equiv,PORT_ALL);    /* Different types equivalenced */
  674. OPT(int,port_mixed_size,PORT_ALL);    /* sized, nonsized types mixed */
  675. OPT(int,port_tabs,PORT_ALL);        /* Tabs in source */
  676.         /* End of -portability options */
  677.  
  678.  
  679.         /* These options are controlled by -pretty */
  680. OPT(int,pretty_multiple_common,PRETTY_ALL);/* COMMON decl in multiple stmts */
  681. OPT(int,pretty_multiple_namelist,PRETTY_ALL);/* NAMELIST decl in multiple stmts */
  682. OPT(int,pretty_parens,PRETTY_ALL);    /* Parentheses around a variable */
  683. OPT(int,pretty_overlength,PRETTY_ALL);    /* Lines over 72 columns */
  684. OPT(int,pretty_extra_space,PRETTY_ALL);    /* Spaces in identifiers */
  685. OPT(int,pretty_no_space,PRETTY_ALL);    /* Space missing btw id and keyword */
  686. OPT(int,pretty_contin,PRETTY_ALL);    /* Continuation mark after comment */
  687.         /* End of -pretty options */
  688.  
  689.         /* These options are controlled by -truncation */
  690. OPT(int,trunc_int_div_real,TRUNC_ALL);    /* Int/int --> real */
  691. OPT(int,trunc_int_div_exponent,TRUNC_ALL);/* Int/int as exponentl */
  692. OPT(int,trunc_int_div_zero,TRUNC_ALL);    /* Int/int const = 0 */
  693. OPT(int,trunc_int_neg_power,TRUNC_ALL);    /* Int**(-int) */
  694. OPT(int,trunc_real_subscript,TRUNC_ALL);/* Real array subscript */
  695. OPT(int,trunc_real_do_index,TRUNC_ALL);    /* Real DO index with int bounds */
  696. OPT(int,trunc_type_demotion,TRUNC_ALL);    /* High --> low precision */
  697. OPT(int,trunc_size_demotion,TRUNC_ALL);    /* High --> low precision */
  698. OPT(int,trunc_promotion,TRUNC_ALL);    /* Low --> high precision */
  699. OPT(int,trunc_sigfigs,TRUNC_ALL);    /* Sngl const overspecified */
  700.                 /* truncation warnings related to precision */
  701. #define trunc_precision (trunc_promotion||trunc_type_demotion||trunc_size_demotion)
  702.  
  703.         /* End of -truncation options */
  704.  
  705.     /* The following flag is for warnings not covered by other flags,
  706.        so that all warnings can be turned off by -nocheck. */
  707. OPT(int,misc_warn,TRUE);
  708.  
  709.     /* The following variables are controlled by command line options */
  710.  
  711. OPT(int,print_call_tree,FALSE);    /* Print the call tree */
  712. OPT(int,do_check,TRUE);        /* For -nocheck option */
  713. OPT(int,print_xref_list,FALSE);    /* Print subprogram cross-references */
  714. OPT(int,decls_required,FALSE);    /* List all undeclared identifiers */
  715. OPT(int,div_check,FALSE);    /* Check for possible division by zero */
  716. OPT(int,ext_def_check,TRUE);    /* Check defined status of externals*/
  717. OPT(int,help_screen,FALSE);    /* Print out help screen */
  718. OPT(int,library_mode,FALSE);    /* Set used-flag for all modules in file */
  719.  
  720. #ifdef EOLSKIP
  721. OPT(int,eol_is_space,TRUE);    /* Treat contd stmt linebreaks as space */
  722. #endif
  723.  
  724. OPT(int,do_list,FALSE);        /* Listing flag */
  725. OPT(int,novice_help,TRUE);    /* Extra help for novices */
  726. OPT(int,make_project_file,FALSE);/* Save symtab defns in .prj file */
  727. OPT(int,pure_functions,TRUE);    /* Assume functions are pure */
  728. OPT(int,print_ref_list,FALSE);    /* Print reference (who-calls-who) list */
  729. OPT(int,quiet,FALSE);        /* Less verbose output format */
  730. OPT(int,sixclash,FALSE);    /* To check if names unique in 1st 6 chars */
  731. OPT(int,print_topo_sort,FALSE);    /* Topological sort of modules */
  732. OPT(int,do_symtab,FALSE);    /* For symbol table printout */
  733. #ifdef VCG_SUPPORT
  734. OPT(int,print_vcg_list,FALSE);    /* Print call graph in vcg format */
  735. #endif
  736. OPT(int,print_version,FALSE);    /* Print version number and quit */
  737. OPT(int,volatile_flag,FALSE);    /* Assume volatile vars and comblocks */
  738.         /* Debugging flags */
  739. OPT(int,debug_latest,FALSE);    /* debug the latest addition */
  740. OPT(int,debug_glob_symtab,FALSE);/* global symtab contents */
  741. OPT(int,debug_parser,FALSE);    /* grammar debug via DBG statements */
  742. OPT(int,debug_hashtab,FALSE);    /* hash table contents */
  743. OPT(int,debug_loc_symtab,FALSE); /* local symtab contents */
  744. OPT(int,show_resources,FALSE);    /* space avail and used */
  745. OPT(int,debug_lexer,FALSE);    /* list of tokens as scanned */
  746. #ifdef MAIN
  747. extern int yydebug;        /* grammar debug via yydebug */
  748. #endif
  749.         /* Declare variables for commandline settings */
  750. OPT(int,argcheck_strictness,3);    /* Strictness for checking args */
  751. OPT(int,array_arg_check,3);/* Check array argument dims & size  */
  752. OPT(int,call_tree_options,0);    /* Sum of: 1 (print it), */
  753.                 /* 2 (who-calls-who form), 4 (don't prune) */
  754.                 /* 8 (program order), 16 (VCG format) */
  755. OPT(int,intrinsic_opt,DEF_INTRINSIC_OPT);/* 0=std, 1=common, 2=unix, 3=vms */
  756. OPT(int,max_stmt_col,72);    /* End of statement field ( <= MAXLINE )*/
  757. OPT(int,comcheck_strictness,3);    /* 0 (no check) to 3 (exact type & size) */
  758. OPT(int,make_dcls,0);        /* sum of: 0 (none), 1 (all), */
  759.                 /* 2 (undeclared), 4 (compact), 8 (keywords */
  760.                 /* lowercase), 16 (variables and constants */
  761.                 /* lowercase), 32 (exclude sf3 internal */
  762.                 /* variables), 64 (use * comment starter), */
  763.                 /* 128 (use 'c' comment starter). */
  764. OPT(int,source_format,DEF_SOURCE_FORMAT);/* Sum of: 1=DEC tabs, */
  765.                 /*   2=VMS style INCLUDE, 4=Unix backslash */
  766. OPT(int,usage_check,333);    /* Print set/used/notset checks */
  767. OPT(int,local_wordsize,BpW);    /* Bytes per word to use for default sizes */
  768. OPT(int,given_wordsize,BpW);    /* User's request as per -wordsize=n  */
  769. OPT(int,wrap_column,WRAP_COLUMN);/* For wrapping error messages */
  770.  
  771.             /* Secondary control vars based on usage_check */
  772. OPT(int,var_usage_check,3);
  773. OPT(int,com_usage_check,3);
  774. OPT(int,ext_usage_check,3);
  775.  
  776.         /* Secondary variable for selecting intrinsic function set */
  777. OPT(int,intrinsic_set,DEF_INTRINSIC_OPT%10);
  778.  
  779.             /* Shorthands for checking control settings */
  780. #define check_args_off    (argcheck_strictness == 0)
  781. #define check_args_number (argcheck_strictness&01)
  782. #define check_args_type    (argcheck_strictness&02)
  783. #define check_args_all    (argcheck_strictness == 3)
  784. #define check_array_dims (array_arg_check&01) /* levels 1 and 3 */
  785. #define check_array_size (array_arg_check&02) /* levels 2 and 3 */
  786.  
  787. #define check_var_set_used    (var_usage_check&01) /* levels 1 and 3 */
  788. #define check_var_unused    (var_usage_check&02) /* levels 2 and 3 */
  789. #define check_com_set_used    (com_usage_check&01) /* levels 1 and 3 */
  790. #define check_com_unused    (com_usage_check&02) /* levels 2 and 3 */
  791. #define check_ext_set_used    (ext_usage_check&01) /* levels 1 and 3 */
  792. #define check_ext_unused    (ext_usage_check&02) /* levels 2 and 3 */
  793.  
  794. #define check_com_off    (comcheck_strictness == 0) /* no checking common */
  795. #define check_com_lengths (comcheck_strictness >= 2) /* match lengths */
  796. #define check_com_byname (comcheck_strictness == 3) /* match var by var */
  797. #define check_com_tree (volatile_flag&&check_com_set_used) /* Check undef errors */
  798. #define check_volatile_com (volatile_flag)/* Check not saved */
  799.  
  800.         /* Define macros for source format options */
  801. #define dec_tabs    (source_format&0x1)    /* DEC-style tabbed source */
  802. #define vms_include    (source_format&0x2)    /* VMS-style INCLUDE */
  803. #define unix_backslash    (source_format&0x4)    /* Treat backslash as escape */
  804.  
  805.  
  806.         /* Declare variables for commandline StrSettings */
  807. OPT(char,*out_fname,(char *)NULL);    /* Output filename */
  808. #ifdef ALLOW_INCLUDE
  809. OPT(char,*include_path,(char *)NULL);    /* An include-file directory */
  810. #endif
  811. OPT(char,*f77_warn_list,(char *)NULL); /* Non F77 extensions to warn about */
  812. OPT(char,*port_warn_list,(char *)NULL); /* Nonportable things to warn about */
  813. OPT(char,*pretty_warn_list,(char *)NULL); /* Misleading things to warn about */
  814. OPT(char,*trunc_warn_list,(char *)NULL); /* Truncation pitfalls to warn about */
  815.  
  816. SHARED unsigned
  817.     line_num,        /* line num of current char */
  818.     col_num,        /* column num of current char */
  819.     next_line_num,    /* line num of lookahead char */
  820.     next_col_num;    /* column num of lookahead char */
  821.  
  822. SHARED unsigned
  823.     error_count,    /* Count of syntax error messages per file */
  824.     warning_count;    /* Count of warning messages per file */
  825.  
  826. SHARED char *
  827.     tab_filename;    /* Filename where there are tabs for -port */
  828.  
  829.         /* Resource usage information: */
  830. SHARED unsigned long
  831.     tot_line_count,    /* total source lines (stmts + comments) */
  832.     tot_stmt_line_count,/* total source stmt lines  */
  833.     tot_exec_stmt_count,/* count of executable stmts in program */
  834.     tot_module_count,    /* count of modules in program */
  835.     exec_stmt_count,    /* count of executable stmts in module */
  836.     max_exec_stmt_count,/* max number of executable stmts in any module */
  837.     max_loc_symtab,    /* number of local symtab entries used */
  838.     max_glob_symtab,    /* number of global symtab entries used */
  839.     max_loc_strings,    /* chars of local stringspace used */
  840.     max_srctextspace,    /* chars of source text space used */
  841.     max_paraminfo,    /* number of param info structs used */
  842.     max_tokenlists,    /* number of tokenlists constructed */
  843.     max_token_space,    /* number of tokens used */
  844.     max_ptrspace,    /* number of pointers used */
  845.  
  846.     glob_strings_used,        /* chars of global stringspace used */
  847.     arglist_element_used,    /* arg array elements used */
  848.     arglist_head_used,        /* arg heads used (1 per call) */
  849.     comlist_element_used,    /* com array elements used */
  850.     comlist_head_used;        /* com heads used (1 per defn) */
  851.  
  852. SHARED int
  853.     equivalence_flag,   /* true while parsing EQUIVALENCE statement */
  854.     initial_flag,    /* true while only label or initial keywords read */
  855.     implicit_flag,    /* true while parsing IMPLICIT statement */
  856.     implicit_letter_flag, /* true while getting letters in IMPLICIT list */
  857.     implicit_type_given,/* true if IMPLICIT type statement found */
  858.     implicit_none,    /* true if IMPLICIT NONE statement found */
  859.     prev_token_class,    /* token class of last-returned token */
  860.     curr_stmt_class;    /* Token class of current stmt's leading token */
  861.  
  862.         /* Define linked-list structure for include-path list */
  863. #ifdef ALLOW_INCLUDE
  864. typedef struct IPNode {
  865.   struct IPNode *link;        /* next path on the list */
  866.   char *include_path;        /* one path (full directory name) */
  867. } IncludePathNode;
  868.  
  869. SHARED IncludePathNode *include_path_list; /* header to the list */
  870. #endif
  871.  
  872.         /* Declare routines shared with main module ftnchek.c */
  873.  
  874.  
  875.     /* in exprtype.c */
  876. PROTO(void init_typesizes, ( void ));
  877.  
  878.     /* in forlex.c */
  879. PROTO(void finish_scan, ( void ));
  880. PROTO(int flush_line_out, ( unsigned n ));
  881. PROTO(void init_keyhashtab, ( void ));
  882. PROTO(void init_scan, ( void ));
  883. PROTO(void open_include_file, ( char *fname, unsigned include_line_num ));
  884.  
  885.     /* in fortran.y/fortran.c */
  886. PROTO(void init_parser, ( void ));
  887. PROTO(int yyparse,  ( void ));
  888.  
  889.     /* in ftnchek.c */
  890. PROTO(void msg_tail, ( char *s ));
  891. PROTO(void nonportable, ( unsigned lineno, unsigned colno, char *s ));
  892. PROTO(void nonstandard, ( unsigned lineno, unsigned colno ));
  893. PROTO(void oops_message, ( int severity, unsigned lineno, unsigned colno, char *s ));
  894. PROTO(void oops_tail, ( char *s ));
  895. PROTO(void print_a_line, ( FILE *fd, char *line, unsigned num ));
  896. PROTO(void  syntax_error, ( unsigned lineno, unsigned colno, char *s ));
  897. PROTO(void ugly_code, ( unsigned lineno, unsigned colno, char *s ));
  898. PROTO(void warning, ( unsigned lineno, unsigned colno, char *s ));
  899. PROTO(void yyerror, ( char *s ));
  900.  
  901.     /* in pgsymtab.c */
  902. PROTO(void check_arglists, ( void ));
  903. PROTO(void check_comlists, ( void ));
  904. PROTO(void check_com_usage, ( void ));
  905. PROTO(void visit_children, ( void ));
  906.  
  907.     /* in plsymtab.c */
  908. PROTO(void debug_symtabs, ( void ));
  909.  
  910.     /* in project.c */
  911. PROTO(void proj_file_out, ( FILE *fd ));
  912. PROTO(void proj_file_in, ( FILE *fd ));
  913.  
  914.     /* in symtab.c */
  915. PROTO(void init_tables, ( void ));
  916. PROTO(void init_globals, ( void ));
  917. PROTO(unsigned long init_intrins_hashtab, ( void ));
  918. PROTO(void init_symtab, ( void ));
  919. PROTO(void note_filename, ( char *s ));
  920. PROTO(void set_intrinsic_options, ( int option ));
  921.  
  922. #ifdef DEBUG_SIZES
  923. PROTO(void print_sizeofs, ( void ));
  924. #endif
  925.  
  926.  
  927.