Hello world,
the attatched patch (this time for real!) implements
-Wextra for the Fortran front end, and adds -fcompare-reals
to -Wextra.
@manu: In the PR, you mentioned that it would be nice if
LangEnabledBy was used in the opt files. I tried adding that
to the common.opt file for Wextra, but that led to the following
regressions:
FAIL: 17_intro/headers/c++1998/all_c++200x_compatibility.cc (test for
excess errors)
FAIL: 17_intro/headers/c++1998/all.cc (test for excess errors)
FAIL: 17_intro/headers/c++1998/all_pedantic_errors.cc (test for excess
errors)
FAIL: 17_intro/headers/c++1998/stdc++.cc (test for excess errors)
FAIL: 17_intro/headers/c++1998/stdc++_multiple_inclusion.cc (test for
excess errors)
FAIL: 17_intro/headers/c++200x/stdc++.cc (test for excess errors)
FAIL: 17_intro/headers/c++200x/stdc++_multiple_inclusion.cc (test for
excess errors)
so I left this part out.
Regression-tested. OK for trunk?
Thomas
2012-09-23 Thomas König <tkoe...@gcc.gnu.org>
PR fortran/54465
* lang.opt (Wextra): Add.
* invoke.texi: Document that -Wc-binding-type, -Wconversion
and -Wline-truncation are implied by -Wall. Document that
-Wcompare-reals is implied by -Wextra.
* options.c (set_Wextra): New function.
(gfc_handle_option): Handle -Wextra.
2012-09-23 Thomas König <tkoe...@gcc.gnu.org>
PR fortran/54465
* gfortran.dg/wextra_1.f: New test.
Index: fortran/lang.opt
===================================================================
--- fortran/lang.opt (Revision 191649)
+++ fortran/lang.opt (Arbeitskopie)
@@ -230,6 +230,10 @@ Wconversion-extra
Fortran Warning
Warn about most implicit conversions
+Wextra
+Fortran Warning
+Print extra (possibly unwanted) warnings
+
Wfunction-elimination
Fortran Warning
Warn about function call elimination
Index: fortran/invoke.texi
===================================================================
--- fortran/invoke.texi (Revision 191649)
+++ fortran/invoke.texi (Arbeitskopie)
@@ -778,7 +778,8 @@ avoid such temporaries.
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} module.
+intrinsic @code{ISO_C_Binding} module. This option is implied by
+@option{-Wall}.
@item -Wcharacter-truncation
@opindex @code{Wcharacter-truncation}
@@ -788,7 +789,8 @@ Warn when a character assignment will truncate the
@item -Wline-truncation
@opindex @code{Wline-truncation}
@cindex warnings, line truncation
-Warn when a source code line will be truncated.
+Warn when a source code line will be truncated. This option is
+implied by @option{-Wall}.
@item -Wconversion
@opindex @code{Wconversion}
@@ -884,7 +886,7 @@ encountered, which yield an UNDERFLOW during compi
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} or
@code{INTRINSIC} declaration might be needed to get calls later resolved to
-the desired intrinsic/procedure.
+the desired intrinsic/procedure. This option is implied by @option{-Wall}.
@item -Wunused-dummy-argument
@opindex @code{Wunused-dummy-argument}
@@ -939,6 +941,7 @@ allocatable variable; this includes scalars and de
@item -Wcompare-reals
@opindex @code{Wcompare-reals}
Warn when comparing real or complex types for equality or inequality.
+This option is implied by @option{-Wextra}.
@item -Wtarget-lifetime
@opindex @code{Wtargt-lifetime}
Index: fortran/options.c
===================================================================
--- fortran/options.c (Revision 191649)
+++ fortran/options.c (Arbeitskopie)
@@ -483,8 +483,15 @@ set_Wall (int setting)
warn_maybe_uninitialized = setting;
}
+/* Set the options for -Wextra. */
static void
+set_Wextra (int setting)
+{
+ gfc_option.warn_compare_reals = setting;
+}
+
+static void
gfc_handle_module_path_options (const char *arg)
{
@@ -653,6 +660,15 @@ gfc_handle_option (size_t scode, const char *arg,
gfc_option.warn_conversion_extra = value;
break;
+ case OPT_Wextra:
+ handle_generated_option (&global_options, &global_options_set,
+ OPT_Wunused_parameter, NULL, value,
+ gfc_option_lang_mask (), kind, loc,
+ handlers, global_dc);
+ set_Wextra (value);
+
+ break;
+
case OPT_Wfunction_elimination:
gfc_option.warn_function_elimination = value;
break;
! { dg-do compile }
! { dg-options "-Wextra" }
program main
integer, parameter :: x=3 ! { dg-warning "Unused parameter" }
real :: a
read (*,*) a
if (a .eq. 3.14) a=2. ! { dg-warning "Equality comparison" }
print *,a
end