Auditing gfortran's intrinsic procedures


As Steve Kargl summarizes the current status of gfortran's intrinsic procedures:

{{{[...] You're looking at a merging of different novice contributions to gfortran. I wrote some of the g77 intrinsics to cut my teeth, and then FX wrote several more g77 intrinsics as his introduction to gfortran. Others contributed intrinsics in the dark ages when gfortran only worried about integer(4) and (8).}}}

Thus, a thorough audition of the intrinsic procedures seems to be in order. To aid this process, I proposed a framework to generate full testsuite coverage in a semi-automatic way.


Based on simple definitions, as many testcases as possible shall be generated. Please consider: {{{subroutine = {

};}}} Above block describes the intrinsic subroutine EXIT, complete with dummy argument name and a list of calls that are assumed to be valid. The Automated Program Generator (autogen) translates this block into a set of testcases, ready to be used in the GCC testsuite:

  1. compile-time tests where the subroutine is called with all possible types
  2. link tests where each call is placed in a file of its own, compiled and linked

Please note that autogen does not introduce a new dependency in GCC, as it is already used to fix the system headers (fixincludes).

Reporting Problems

Details on the list items will be given in the Implementation section.

Reporter, to audit procedure 'X':

  1. Check whether there already is a PR for 'X'
  2. Create a new definition similar to that shown above
  3. Create a set of testcases
  4. Run the testsuite
  5. If no problems are found, submit the block. Open a new PR otherwise, include the definition block created in item 1.

Assignee, to fix procedure 'X':

  1. Recreate testcases from the definition block given in the PR
  2. Fix the PR
  3. Include the definition block as well as the generated testcases in your patch

Please note that there is a meta-bug for intrinsics: PR30932


File Location

The patch adds the directories intrinsics, intrinsics/compile and intrinsics/link to gcc/testsuite/gfortran.dg.

The definition file (intrinsics.def) shall reside, together with the autogen template (intrinsics.tpl) in the intrinsics directory, while the generated testcases shall be placed in compile, link and maybe later, run. Also in top directory, the dejagnu driver file (intrinsics.exp).


The definitions file follows the syntax rules of autogen files. For a general introduction see the docs of autogen.

Each definition block shall be identified as either subroutine or function. The field name shall be defined only once per block while arg and call may appear zero, one or multiple times. Each arg names a dummy argument, each call a valid call of the subroutine. The list of calls shall always include the respective argument names to distinguish ambiguous calls for routines with multiple optional arguments.

The definition of the subroutine EXIT: {{{subroutine = {


Generating Testcases

In gcc/testsuite/gfortran.dg/intrinsics run: {{{autogen intrinsics.def }}}

Alternatively, use the convenience script (

For each definition block, this will create a single file name_subroutine.f90 or name_function.f90 in compile and as many files name_[1-9].f90 in link as there are calls listed in the definition block.

Running testcases

To run all intrinsic-related testcases: {{{make check-gfortran RUNTESTFLAGS="intrinsics.exp" }}}

To test only a specific intrinsic procedure, e. g. 'X': {{{make check-gfortran RUNTESTFLAGS="intrinsics.exp=X_*.f90" }}}

To Do

Things missing and to do (intrinsics.tpl):

None: GFortranTestsuiteIntrinsics (last edited 2008-01-10 19:38:52 by localhost)