123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <!-- Copyright (C) 1999-2017 Free Software Foundation, Inc.
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.3 or
- any later version published by the Free Software Foundation; with the
- Invariant Sections being "Funding Free Software", the Front-Cover
- Texts being (a) (see below), and with the Back-Cover Texts being (b)
- (see below). A copy of the license is included in the section entitled
- "GNU Free Documentation License".
- (a) The FSF's Front-Cover Text is:
- A GNU Manual
- (b) The FSF's Back-Cover Text is:
- You have freedom to copy and modify this GNU Manual, like GNU
- software. Copies published by the Free Software Foundation raise
- funds for GNU development. -->
- <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
- <head>
- <title>The GNU Fortran Compiler: Error and Warning Options</title>
- <meta name="description" content="The GNU Fortran Compiler: Error and Warning Options">
- <meta name="keywords" content="The GNU Fortran Compiler: Error and Warning Options">
- <meta name="resource-type" content="document">
- <meta name="distribution" content="global">
- <meta name="Generator" content="makeinfo">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link href="index.html#Top" rel="start" title="Top">
- <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
- <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
- <link href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" rel="up" title="Invoking GNU Fortran">
- <link href="Debugging-Options.html#Debugging-Options" rel="next" title="Debugging Options">
- <link href="Preprocessing-Options.html#Preprocessing-Options" rel="prev" title="Preprocessing Options">
- <style type="text/css">
- <!--
- a.summary-letter {text-decoration: none}
- blockquote.smallquotation {font-size: smaller}
- div.display {margin-left: 3.2em}
- div.example {margin-left: 3.2em}
- div.indentedblock {margin-left: 3.2em}
- div.lisp {margin-left: 3.2em}
- div.smalldisplay {margin-left: 3.2em}
- div.smallexample {margin-left: 3.2em}
- div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
- div.smalllisp {margin-left: 3.2em}
- kbd {font-style:oblique}
- pre.display {font-family: inherit}
- pre.format {font-family: inherit}
- pre.menu-comment {font-family: serif}
- pre.menu-preformatted {font-family: serif}
- pre.smalldisplay {font-family: inherit; font-size: smaller}
- pre.smallexample {font-size: smaller}
- pre.smallformat {font-family: inherit; font-size: smaller}
- pre.smalllisp {font-size: smaller}
- span.nocodebreak {white-space:nowrap}
- span.nolinebreak {white-space:nowrap}
- span.roman {font-family:serif; font-weight:normal}
- span.sansserif {font-family:sans-serif; font-weight:normal}
- ul.no-bullet {list-style: none}
- -->
- </style>
- </head>
- <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <a name="Error-and-Warning-Options"></a>
- <div class="header">
- <p>
- Next: <a href="Debugging-Options.html#Debugging-Options" accesskey="n" rel="next">Debugging Options</a>, Previous: <a href="Preprocessing-Options.html#Preprocessing-Options" accesskey="p" rel="prev">Preprocessing Options</a>, Up: <a href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" accesskey="u" rel="up">Invoking GNU Fortran</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
- </div>
- <hr>
- <a name="Options-to-request-or-suppress-errors-and-warnings"></a>
- <h3 class="section">2.4 Options to request or suppress errors and warnings</h3>
- <a name="index-options_002c-warnings"></a>
- <a name="index-options_002c-errors"></a>
- <a name="index-warnings_002c-suppressing"></a>
- <a name="index-messages_002c-error"></a>
- <a name="index-messages_002c-warning"></a>
- <a name="index-suppressing-warnings"></a>
- <p>Errors are diagnostic messages that report that the GNU Fortran compiler
- cannot compile the relevant piece of source code. The compiler will
- continue to process the program in an attempt to report further errors
- to aid in debugging, but will not produce any compiled output.
- </p>
- <p>Warnings are diagnostic messages that report constructions which
- are not inherently erroneous but which are risky or suggest there is
- likely to be a bug in the program. Unless <samp>-Werror</samp> is specified,
- they do not prevent compilation of the program.
- </p>
- <p>You can request many specific warnings with options beginning <samp>-W</samp>,
- for example <samp>-Wimplicit</samp> to request warnings on implicit
- declarations. Each of these specific warning options also has a
- negative form beginning <samp>-Wno-</samp> to turn off warnings;
- for example, <samp>-Wno-implicit</samp>. This manual lists only one of the
- two forms, whichever is not the default.
- </p>
- <p>These options control the amount and kinds of errors and warnings produced
- by GNU Fortran:
- </p>
- <dl compact="compact">
- <dt><code>-fmax-errors=<var>n</var></code></dt>
- <dd><a name="index-fmax_002derrors_003dn"></a>
- <a name="index-errors_002c-limiting"></a>
- <p>Limits the maximum number of error messages to <var>n</var>, at which point
- GNU Fortran bails out rather than attempting to continue processing the
- source code. If <var>n</var> is 0, there is no limit on the number of error
- messages produced.
- </p>
- </dd>
- <dt><code>-fsyntax-only</code></dt>
- <dd><a name="index-fsyntax_002donly"></a>
- <a name="index-syntax-checking"></a>
- <p>Check the code for syntax errors, but do not actually compile it. This
- will generate module files for each module present in the code, but no
- other output file.
- </p>
- </dd>
- <dt><code>-Wpedantic</code></dt>
- <dt><code>-pedantic</code></dt>
- <dd><a name="index-pedantic"></a>
- <a name="index-Wpedantic"></a>
- <p>Issue warnings for uses of extensions to Fortran 95.
- <samp>-pedantic</samp> also applies to C-language constructs where they
- occur in GNU Fortran source files, such as use of ‘<samp>\e</samp>’ in a
- character constant within a directive like <code>#include</code>.
- </p>
- <p>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.
- </p>
- <p>Some users try to use <samp>-pedantic</samp> 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 GNU Fortran in this area are welcome.
- </p>
- <p>This should be used in conjunction with <samp>-std=f95</samp>,
- <samp>-std=f2003</samp> or <samp>-std=f2008</samp>.
- </p>
- </dd>
- <dt><code>-pedantic-errors</code></dt>
- <dd><a name="index-pedantic_002derrors"></a>
- <p>Like <samp>-pedantic</samp>, except that errors are produced rather than
- warnings.
- </p>
- </dd>
- <dt><code>-Wall</code></dt>
- <dd><a name="index-Wall"></a>
- <a name="index-all-warnings"></a>
- <a name="index-warnings_002c-all"></a>
- <p>Enables commonly used warning options pertaining to usage that
- we recommend avoiding and that we believe are easy to avoid.
- This currently includes <samp>-Waliasing</samp>, <samp>-Wampersand</samp>,
- <samp>-Wconversion</samp>, <samp>-Wsurprising</samp>, <samp>-Wc-binding-type</samp>,
- <samp>-Wintrinsics-std</samp>, <samp>-Wtabs</samp>, <samp>-Wintrinsic-shadow</samp>,
- <samp>-Wline-truncation</samp>, <samp>-Wtarget-lifetime</samp>,
- <samp>-Winteger-division</samp>, <samp>-Wreal-q-constant</samp>, <samp>-Wunused</samp>
- and <samp>-Wundefined-do-loop</samp>.
- </p>
- </dd>
- <dt><code>-Waliasing</code></dt>
- <dd><a name="index-Waliasing"></a>
- <a name="index-aliasing"></a>
- <a name="index-warnings_002c-aliasing"></a>
- <p>Warn about possible aliasing of dummy arguments. Specifically, it warns
- if the same actual argument is associated with a dummy argument with
- <code>INTENT(IN)</code> and a dummy argument with <code>INTENT(OUT)</code> in a call
- with an explicit interface.
- </p>
- <p>The following example will trigger the warning.
- </p><div class="smallexample">
- <pre class="smallexample"> interface
- subroutine bar(a,b)
- integer, intent(in) :: a
- integer, intent(out) :: b
- end subroutine
- end interface
- integer :: a
- call bar(a,a)
- </pre></div>
- </dd>
- <dt><code>-Wampersand</code></dt>
- <dd><a name="index-Wampersand"></a>
- <a name="index-warnings_002c-ampersand"></a>
- <a name="index-_0026"></a>
- <p>Warn about missing ampersand in continued character constants. The warning is
- given with <samp>-Wampersand</samp>, <samp>-pedantic</samp>, <samp>-std=f95</samp>,
- <samp>-std=f2003</samp> and <samp>-std=f2008</samp>. Note: With no ampersand
- given in a continued character constant, GNU Fortran assumes continuation
- at the first non-comment, non-whitespace character after the ampersand
- that initiated the continuation.
- </p>
- </dd>
- <dt><code>-Wargument-mismatch</code></dt>
- <dd><a name="index-Wargument_002dmismatch"></a>
- <a name="index-warnings_002c-argument-mismatch"></a>
- <a name="index-warnings_002c-parameter-mismatch"></a>
- <a name="index-warnings_002c-interface-mismatch"></a>
- <p>Warn about type, rank, and other mismatches between formal parameters and actual
- arguments to functions and subroutines. These warnings are recommended and
- thus enabled by default.
- </p>
- </dd>
- <dt><code>-Warray-temporaries</code></dt>
- <dd><a name="index-Warray_002dtemporaries"></a>
- <a name="index-warnings_002c-array-temporaries"></a>
- <p>Warn about array temporaries generated by the compiler. The information
- generated by this warning is sometimes useful in optimization, in order to
- avoid such temporaries.
- </p>
- </dd>
- <dt><code>-Wc-binding-type</code></dt>
- <dd><a name="index-Wc_002dbinding_002dtype"></a>
- <a name="index-warning_002c-C-binding-type"></a>
- <p>Warn if the a variable might not be C interoperable. In particular, warn if
- the variable has been declared using an intrinsic type with default kind
- instead of using a kind parameter defined for C interoperability in the
- intrinsic <code>ISO_C_Binding</code> module. This option is implied by
- <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wcharacter-truncation</code></dt>
- <dd><a name="index-Wcharacter_002dtruncation"></a>
- <a name="index-warnings_002c-character-truncation"></a>
- <p>Warn when a character assignment will truncate the assigned string.
- </p>
- </dd>
- <dt><code>-Wline-truncation</code></dt>
- <dd><a name="index-Wline_002dtruncation"></a>
- <a name="index-warnings_002c-line-truncation"></a>
- <p>Warn when a source code line will be truncated. This option is
- implied by <samp>-Wall</samp>. For free-form source code, the default is
- <samp>-Werror=line-truncation</samp> such that truncations are reported as
- error.
- </p>
- </dd>
- <dt><code>-Wconversion</code></dt>
- <dd><a name="index-Wconversion"></a>
- <a name="index-warnings_002c-conversion"></a>
- <a name="index-conversion"></a>
- <p>Warn about implicit conversions that are likely to change the value of
- the expression after conversion. Implied by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wconversion-extra</code></dt>
- <dd><a name="index-Wconversion_002dextra"></a>
- <a name="index-warnings_002c-conversion-1"></a>
- <a name="index-conversion-1"></a>
- <p>Warn about implicit conversions between different types and kinds. This
- option does <em>not</em> imply <samp>-Wconversion</samp>.
- </p>
- </dd>
- <dt><code>-Wextra</code></dt>
- <dd><a name="index-Wextra"></a>
- <a name="index-extra-warnings"></a>
- <a name="index-warnings_002c-extra"></a>
- <p>Enables some warning options for usages of language features which
- may be problematic. This currently includes <samp>-Wcompare-reals</samp>
- and <samp>-Wunused-parameter</samp>.
- </p>
- </dd>
- <dt><code>-Wimplicit-interface</code></dt>
- <dd><a name="index-Wimplicit_002dinterface"></a>
- <a name="index-warnings_002c-implicit-interface"></a>
- <p>Warn if a procedure is 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.
- </p>
- </dd>
- <dt><code>-Wimplicit-procedure</code></dt>
- <dd><a name="index-Wimplicit_002dprocedure"></a>
- <a name="index-warnings_002c-implicit-procedure"></a>
- <p>Warn if a procedure is called that has neither an explicit interface
- nor has been declared as <code>EXTERNAL</code>.
- </p>
- </dd>
- <dt><code>-Winteger-division</code></dt>
- <dd><a name="index-Winteger_002ddivision"></a>
- <a name="index-warnings_002c-integer-division"></a>
- <a name="index-warnings_002c-division-of-integers"></a>
- <p>Warn if a constant integer division truncates it result.
- As an example, 3/5 evaluates to 0.
- </p>
- </dd>
- <dt><code>-Wintrinsics-std</code></dt>
- <dd><a name="index-Wintrinsics_002dstd"></a>
- <a name="index-warnings_002c-non_002dstandard-intrinsics"></a>
- <a name="index-warnings_002c-intrinsics-of-other-standards"></a>
- <p>Warn if <code>gfortran</code> finds a procedure named like an intrinsic not
- available in the currently selected standard (with <samp>-std</samp>) and treats
- it as <code>EXTERNAL</code> procedure because of this. <samp>-fall-intrinsics</samp> can
- be used to never trigger this behavior and always link to the intrinsic
- regardless of the selected standard.
- </p>
- </dd>
- <dt><code>-Wreal-q-constant</code></dt>
- <dd><a name="index-Wreal_002dq_002dconstant"></a>
- <a name="index-warnings_002c-q-exponent_002dletter"></a>
- <p>Produce a warning if a real-literal-constant contains a <code>q</code>
- exponent-letter.
- </p>
- </dd>
- <dt><code>-Wsurprising</code></dt>
- <dd><a name="index-Wsurprising"></a>
- <a name="index-warnings_002c-suspicious-code"></a>
- <p>Produce a warning when “suspicious” code constructs are encountered.
- While technically legal these usually indicate that an error has been made.
- </p>
- <p>This currently produces a warning under the following circumstances:
- </p>
- <ul>
- <li> An INTEGER SELECT construct has a CASE that can never be matched as its
- lower value is greater than its upper value.
- </li><li> A LOGICAL SELECT construct has three CASE statements.
- </li><li> A TRANSFER specifies a source that is shorter than the destination.
- </li><li> The type of a function result is declared more than once with the same type. If
- <samp>-pedantic</samp> or standard-conforming mode is enabled, this is an error.
- </li><li> A <code>CHARACTER</code> variable is declared with negative length.
- </li></ul>
- </dd>
- <dt><code>-Wtabs</code></dt>
- <dd><a name="index-Wtabs"></a>
- <a name="index-warnings_002c-tabs"></a>
- <a name="index-tabulators"></a>
- <p>By default, tabs are accepted as whitespace, but tabs are not members
- of the Fortran Character Set. For continuation lines, a tab followed
- by a digit between 1 and 9 is supported. <samp>-Wtabs</samp> will cause
- a warning to be issued if a tab is encountered. Note, <samp>-Wtabs</samp>
- is active for <samp>-pedantic</samp>, <samp>-std=f95</samp>, <samp>-std=f2003</samp>,
- <samp>-std=f2008</samp>, <samp>-std=f2008ts</samp> and <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wundefined-do-loop</code></dt>
- <dd><a name="index-Wundefined_002ddo_002dloop"></a>
- <a name="index-warnings_002c-undefined-do-loop"></a>
- <p>Warn if a DO loop with step either 1 or -1 yields an underflow or an overflow
- during iteration of an induction variable of the loop.
- This option is implied by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wunderflow</code></dt>
- <dd><a name="index-Wunderflow"></a>
- <a name="index-warnings_002c-underflow"></a>
- <a name="index-underflow"></a>
- <p>Produce a warning when numerical constant expressions are
- encountered, which yield an UNDERFLOW during compilation. Enabled by default.
- </p>
- </dd>
- <dt><code>-Wintrinsic-shadow</code></dt>
- <dd><a name="index-Wintrinsic_002dshadow"></a>
- <a name="index-warnings_002c-intrinsic"></a>
- <a name="index-intrinsic"></a>
- <p>Warn if a user-defined procedure or module procedure has the same name as an
- intrinsic; in this case, an explicit interface or <code>EXTERNAL</code> or
- <code>INTRINSIC</code> declaration might be needed to get calls later resolved to
- the desired intrinsic/procedure. This option is implied by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wuse-without-only</code></dt>
- <dd><a name="index-Wuse_002dwithout_002donly"></a>
- <a name="index-warnings_002c-use-statements"></a>
- <a name="index-intrinsic-1"></a>
- <p>Warn if a <code>USE</code> statement has no <code>ONLY</code> qualifier and
- thus implicitly imports all public entities of the used module.
- </p>
- </dd>
- <dt><code>-Wunused-dummy-argument</code></dt>
- <dd><a name="index-Wunused_002ddummy_002dargument"></a>
- <a name="index-warnings_002c-unused-dummy-argument"></a>
- <a name="index-unused-dummy-argument"></a>
- <a name="index-dummy-argument_002c-unused"></a>
- <p>Warn about unused dummy arguments. This option is implied by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wunused-parameter</code></dt>
- <dd><a name="index-Wunused_002dparameter"></a>
- <a name="index-warnings_002c-unused-parameter"></a>
- <a name="index-unused-parameter"></a>
- <p>Contrary to <code>gcc</code>’s meaning of <samp>-Wunused-parameter</samp>,
- <code>gfortran</code>’s implementation of this option does not warn
- about unused dummy arguments (see <samp>-Wunused-dummy-argument</samp>),
- but about unused <code>PARAMETER</code> values. <samp>-Wunused-parameter</samp>
- is implied by <samp>-Wextra</samp> if also <samp>-Wunused</samp> or
- <samp>-Wall</samp> is used.
- </p>
- </dd>
- <dt><code>-Walign-commons</code></dt>
- <dd><a name="index-Walign_002dcommons"></a>
- <a name="index-warnings_002c-alignment-of-COMMON-blocks"></a>
- <a name="index-alignment-of-COMMON-blocks"></a>
- <p>By default, <code>gfortran</code> warns about any occasion of variables being
- padded for proper alignment inside a <code>COMMON</code> block. This warning can be turned
- off via <samp>-Wno-align-commons</samp>. See also <samp>-falign-commons</samp>.
- </p>
- </dd>
- <dt><code>-Wfunction-elimination</code></dt>
- <dd><a name="index-Wfunction_002delimination"></a>
- <a name="index-function-elimination"></a>
- <a name="index-warnings_002c-function-elimination"></a>
- <p>Warn if any calls to functions are eliminated by the optimizations
- enabled by the <samp>-ffrontend-optimize</samp> option.
- </p>
- </dd>
- <dt><code>-Wrealloc-lhs</code></dt>
- <dd><a name="index-Wrealloc_002dlhs"></a>
- <a name="index-Reallocate-the-LHS-in-assignments_002c-notification"></a>
- <p>Warn when the compiler might insert code to for allocation or reallocation of
- an allocatable array variable of intrinsic type in intrinsic assignments. In
- hot loops, the Fortran 2003 reallocation feature may reduce the performance.
- If the array is already allocated with the correct shape, consider using a
- whole-array array-spec (e.g. <code>(:,:,:)</code>) for the variable on the left-hand
- side to prevent the reallocation check. Note that in some cases the warning
- is shown, even if the compiler will optimize reallocation checks away. For
- instance, when the right-hand side contains the same variable multiplied by
- a scalar. See also <samp>-frealloc-lhs</samp>.
- </p>
- </dd>
- <dt><code>-Wrealloc-lhs-all</code></dt>
- <dd><a name="index-Wrealloc_002dlhs_002dall"></a>
- <p>Warn when the compiler inserts code to for allocation or reallocation of an
- allocatable variable; this includes scalars and derived types.
- </p>
- </dd>
- <dt><code>-Wcompare-reals</code></dt>
- <dd><a name="index-Wcompare_002dreals"></a>
- <p>Warn when comparing real or complex types for equality or inequality.
- This option is implied by <samp>-Wextra</samp>.
- </p>
- </dd>
- <dt><code>-Wtarget-lifetime</code></dt>
- <dd><a name="index-Wtargt_002dlifetime"></a>
- <p>Warn if the pointer in a pointer assignment might be longer than the its
- target. This option is implied by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Wzerotrip</code></dt>
- <dd><a name="index-Wzerotrip"></a>
- <p>Warn if a <code>DO</code> loop is known to execute zero times at compile
- time. This option is implied by <samp>-Wall</samp>.
- </p>
- </dd>
- <dt><code>-Werror</code></dt>
- <dd><a name="index-Werror"></a>
- <a name="index-warnings_002c-to-errors"></a>
- <p>Turns all warnings into errors.
- </p></dd>
- </dl>
- <p>See <a href="http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options">Options to Request or Suppress Errors and
- Warnings</a> in <cite>Using the GNU Compiler Collection (GCC)</cite>, for information on
- more options offered by the GBE shared by <code>gfortran</code>, <code>gcc</code>
- and other GNU compilers.
- </p>
- <p>Some of these have no effect when compiling programs written in Fortran.
- </p>
- <hr>
- <div class="header">
- <p>
- Next: <a href="Debugging-Options.html#Debugging-Options" accesskey="n" rel="next">Debugging Options</a>, Previous: <a href="Preprocessing-Options.html#Preprocessing-Options" accesskey="p" rel="prev">Preprocessing Options</a>, Up: <a href="Invoking-GNU-Fortran.html#Invoking-GNU-Fortran" accesskey="u" rel="up">Invoking GNU Fortran</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
- </div>
- </body>
- </html>
|