lintfor(1)
NAME
lintfor − FORTRAN inter-procedural checker
SYNOPSIS
lintfor [-p] [-u] [-V] [-lx] [-x exclusions] [-T] [-f flistfile] [-c] [-o lib] [f77_options] file ...
DESCRIPTION
lintfor detects erroneous, non-portable, or wasteful use of the FORTRAN language. It pays particular attention to mismatches between calls and definitions of FUNCTIONs and SUBROUTINEs, COMMON block differences, and the use of uninitialized variables.
The following are problems that lintfor detects:
• Unused variables (declared but never referenced).
• Variables uninitialized (undefined) at the time of reference.
• Unreferenced labels.
• Mismatches in the number and types of formal and actual arguments to FUNCTIONs and SUBROUTINEs.
• Mismatches in the expected and actual return value of FUNCTIONs.
• CALLs of FUNCTIONs, and the use of SUBROUTINEs in expressions.
• COMMON block layout differences
lintfor can also generate the following information:
• Call graph (which procedures call which procedures).
• List of procedures referenced but not defined in the source made available to lintfor.
Arguments whose names end with .f are interpreted as FORTRAN source files. Arguments whose names end with .ln are interpreted as the result of an earlier invocation of lintfor -c or lintfor -o. In addition, the -f flistfile option can be used to name a file containing a list of file names (one per line) to check. lintfor produces a warning if a file with any other suffix is specified.
lintfor takes all .f, .ln, and fllib-lx.ln files (specified by -lx) and processes them in their command-line order. If the -c option is not used, the second pass of lintfor checks this list of files for mutual compatibility. When the -c option is used, the .ln and fllib-lx.ln files are ignored.
Any number of lintfor options can be used, in any order, intermixed with file name arguments.
Options
The following options are used to change the type of output produced by lintfor:
-x exclusions Prevent pass 2 from reporting the listed errors and warnings. lintfor assigns an error number to each error and warning that it generates. To suppress the reporting of an error or warning, list its error number in a -x option. For example,
lintfor -x 1010,5001 file.f
does not report error number 1010 or warning number 5001 during interprocedural checking. Note that the final statistics about the number of errors and warnings found are reported as if the -x option were unspecified.
-T Prevent pass 2 from displaying the text of errors and warnings. lintfor usually displays an error indication on one line followed by a textual explanation of the error message on the next line. The -T option suppresses the display of the textual message.
-p Print a call graph of the program. The call graph consists of a list of those procedures called by each procedure and a list of those procedures which call that procedure.
-u Suppress complaints about FUNCTIONs and SUBROUTINEs that are defined but not used, or used but not defined. This option is useful when running lintfor on a subset of files of a larger program.
-V Suppress complaints about uninitialized variables. Detection of uninitialized variables takes considerable time and space. This option is useful for “quick checks” of FORTRAN programs.
The following arguments alter lintfor’s behavior:
-lx Add a predefined lintfor library fllib-lx.ln. For example, to include a version of the lintfor math library fllib-lm.ln, specify -lm on the command line.
-f flistfile Check the files listed in the file named flistfile. The file names in flistfile must be specified one per line, and can be either .f or .ln files.
-c Cause lintfor to produce a .ln file for every .f file on the command line. These .ln files are the product of lintfor’s first pass only, and are not checked for inter-procedural compatibility or uninitialized variables.
-o lib Cause lintfor to produce a lintfor library named fllib-llib.ln. The -c option nullifies any use of the -o option. The lintfor library produced is the input that would be given to lintfor’s second pass. The -o option simply causes this file to be saved in the named lintfor library. In order to reduce the size of the lintfor libraries, the data required for uninitialized variable detection is not written if the -o option is given.
The f77 -a, -A, -C, -D, -g, -G, -I, -K, -L, -n, -N, -O, -q, -Q, -R, -s, -S, -v, -w, -W, and all +opt options are also recognized as separate arguments; however, the f77 -C, -g, -G, -K, -n, -N, -O, +O, -q, -Q, and -s options are ignored. This makes lintfor’s option list similar to that of the f77 command, facilitating the use of lintfor instead of f77 in makefiles (see f77(1)).
lintfor is a two-pass process. The first pass operates on a per-source-file basis. Syntax and other compiler errors are produced at this point. If all source files are processed without error and the -c and -o options are not specified, lintfor starts the second pass. It prints the message Beginning inter-procedural checking and performs the desired inter-procedural checks. The behavior of the -c and -o options allows for incremental use of lintfor on a set of FORTRAN source files.
Generally, lintfor is invoked once for each source file with the -c option. Each invocation produces a .ln file corresponding to the .f file, and prints diagnostics for that source file. After all source files have been run separately through lintfor, lintfor should be invoked again without the -c option, listing all of the .ln files to detect all of the inter-procedural inconsistencies. This scheme works well with make; it allows make to use lintfor on only those source files that have been modified since the set of source files were last run through lintfor (see make(1)).
WARNINGS
The algorithm that lintfor uses to detect uninitialized variables does not recognize EQUIVALENCE statements, nor can it follow assigned GOTO statements; therefore, lintfor might occasionally make the incorrect claim that a variable is uninitialized. lintfor also does not attempt to decipher variable FORMAT expressions; uninitialized variables used in variable FORMAT expressions are not detected.
DEPENDENCIES
The TMPDIR environment variable specifies a directory for temporary files to be used instead of the default directories /tmp and /usr/tmp.
FILES
/usr/lib/fllib-lx.ln lintfor libraries that may be specified by the -lx option
/usr/lib/lintfor1 First pass of lintfor
/usr/lib/lintfor2 Actual inter-procedural checking program
/usr/tmp/*lint* Temporary files
SEE ALSO
Hewlett-Packard Company — HP-UX Release 9.0: August 1992