Next: , Previous: Fortran Dialect Options, Up: Invoking GFORTRAN


4.3 Options to Request or Suppress Warnings

Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there might have been an error.

You can request many specific warnings with options beginning -W, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning -Wno- to turn off warnings; for example, -Wno-implicit. This manual lists only one of the two forms, whichever is not the default.

These options control the amount and kinds of warnings produced by GNU Fortran:

-fsyntax-only
Check the code for syntax errors, but don't do anything beyond that.


-pedantic
Issue warnings for uses of extensions to FORTRAN 95. -pedantic also applies to C-language constructs where they occur in GNU Fortran source files, such as use of `\e' in a character constant within a directive like `#include'.

Valid FORTRAN 95 programs should compile properly with or without this option. However, without this option, certain GNU extensions and traditional Fortran features are supported as well. With this option, many of them are rejected.

Some users try to use -pedantic to check programs for conformance. They soon find that it does not do quite what they want—it finds some nonstandard practices, but not all. However, improvements to gfortran in this area are welcome.

This should be used in conjunction with -std=std.


-pedantic-errors
Like -pedantic, except that errors are produced rather than warnings.


-w
Inhibit all warning messages.


-Wall
Enables commonly used warning options pertaining to usage that we recommend avoiding and that we believe are easy to avoid. This currently includes -Wunused-labels, -Waliasing, -Wampersand, -Wsurprising, -Wnonstd-intrinsic, and -Wline-truncation.


-Waliasing
Warn about possible aliasing of dummy arguments. Specifically, it warns if the same actual argument is associated with a dummy argument with intent(in) and a dummy argument with intent(out) in a call with an explicit interface.

The following example will trigger the warning.

            interface
              subroutine bar(a,b)
                integer, intent(in) :: a
                integer, intent(out) :: b
              end subroutine
            end interface
            integer :: a
          
            call bar(a,a)
     


-Wampersand
Warn about missing ampersand in continued character literals. The warning is given with -Wampersand, -pedantic, and -std=f95. Note: With no ampersand given in a continued character literal, gfortran assumes continuation at the first non-comment, non-whitespace character.


-Wconversion
Warn about implicit conversions between different types.


-Wimplicit-interface
Warn about when procedure are called without an explicit interface. Note this only checks that an explicit interface is present. It does not check that the declared interfaces are consistent across program units.


-Wnonstd-intrinsic
Warn if the user tries to use an intrinsic that does not belong to the standard the user has chosen via the -std option.


-Wsurprising
Produce a warning when “suspicious” code constructs are encountered. While technically legal these usually indicate that an error has been made.

This currently produces a warning under the following circumstances:


-Wunderflow
Produce a warning when numerical constant expressions are encountered, which yield an UNDERFLOW during compilation.


-Wunused-labels
Warn whenever a label is defined but never referenced.


-Werror
Turns all warnings into errors.


-W
Turns on “extra warnings” and, if optimization is specified via -O, the -Wuninitialized option. (This might change in future versions of gfortran

See Options to Request or Suppress Warnings, for information on more options offered by the GBE shared by gfortran, gcc and other GNU compilers.

Some of these have no effect when compiling programs written in Fortran.