[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-12 Thread doko at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #17 from Matthias Klose doko at gcc dot gnu.org ---
patch posted at
http://gcc.gnu.org/ml/gcc-patches/2014-05/msg00785.html


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

Dominique d'Humieres dominiq at lps dot ens.fr changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-05-09
 CC||doko at cs dot tu-berlin.de
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres dominiq at lps dot ens.fr ---
Likely caused by r210246 (see
http://gcc.gnu.org/ml/gcc-regression/2014-05/msg00091.html).


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread doko at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

Matthias Klose doko at gcc dot gnu.org changed:

   What|Removed |Added

 CC||doko at gcc dot gnu.org,
   ||manu at gcc dot gnu.org

--- Comment #2 from Matthias Klose doko at gcc dot gnu.org ---
-Wunused-parameter is enabled by -Wall. I'm surprised that -Wextra is used
without -Wall, but it happens in the testsuite in more places.


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread fweimer at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #3 from Florian Weimer fweimer at redhat dot com ---
(In reply to Matthias Klose from comment #2)
 -Wunused-parameter is enabled by -Wall. I'm surprised that -Wextra is used
 without -Wall, but it happens in the testsuite in more places.

This is not what the documentation says:

@item -Wextra
@opindex @code{Wextra}
@cindex extra warnings
@cindex warnings, extra
Enables some warning options for usages of language features which
may be problematic. This currently includes @option{-Wcompare-reals}
and @option{-Wunused-parameter}.


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

 CC||burnus at gcc dot gnu.org

--- Comment #4 from Tobias Burnus burnus at gcc dot gnu.org ---
(In reply to Matthias Klose from comment #2)
 -Wunused-parameter is enabled by -Wall.

No, according to the manual it isn't. I think one reason for confusion is the
naming of things in the different languages.

Named constants are called in Fortran PARAMETER and the thing you pass to a
procedure (function, subroutine) are called (actual) arguments - those get
associated with dummy arguments/formal arguments.

In C, you call arguments parameters. Thus, taking about parameter is highly
confusing. I think it neither really fits to named constants nor to arguments,
but since languages have chosen the term ...

From the gfortran man page:

-Wunused-parameter
Contrary to gcc’s meaning of -Wunused-parameter, gfortran’s implementation of
this option does not warn about unused dummy arguments (see
-Wunused-dummy-argument), but about unused PARAMETER values.
-Wunused-parameter is not included in -Wall but is implied by -Wall -Wextra.

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread doko at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #5 from Matthias Klose doko at gcc dot gnu.org ---
-Wunused-parameter is not included in -Wall but is implied by -Wall -Wextra
would mean that the test case assumes that it it is implied by -Wextra only.


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #6 from Tobias Burnus burnus at gcc dot gnu.org ---
(In reply to Florian Weimer from comment #3)
 (In reply to Matthias Klose from comment #2)
  -Wunused-parameter is enabled by -Wall. I'm surprised that -Wextra is used
  without -Wall, but it happens in the testsuite in more places.

Actually, looking at gcc/common.opt, one finds:
  Wunused-parameter
  Common Var(warn_unused_parameter) Warning EnabledBy(Wunused  Wextra)

Thus, in GCC - whether Fortran or C - it is enabled with -Wextra, but only if
also -Wunused is used. The latter is implied by -Wall.


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #7 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Florian Weimer from comment #0)
 The gfortran.dg/wextra_1.f test case assumes that -Wextra enables
 -Wununused-parameter, but this does not happen.  No warning is printed on
 line 4, leading to a test failure.

I don't understand how it was working before. What is exactly the command-line
passed to that testcase?

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #8 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Tobias Burnus from comment #6)
 Thus, in GCC - whether Fortran or C - it is enabled with -Wextra, but only
 if also -Wunused is used. The latter is implied by -Wall.

This is not necessarily true for gfortran, since it doesn't use the common
options machinery and it fiddles with the options directly. I'm not sure if
this is the case or not for this particular option, but it could be a
possibility (one more reason to move gfortran to use the common machinery).

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread doko at ubuntu dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #9 from Matthias Klose doko at ubuntu dot com ---
Am 09.05.2014 18:02, schrieb manu at gcc dot gnu.org:
 I don't understand how it was working before. What is exactly the
 command-line passed to that testcase?

the test passes just -Wextra, adding either a -Wunused or a -Wall lets the
warning re-appear.


[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #10 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #7)
 (In reply to Florian Weimer from comment #0)
  The gfortran.dg/wextra_1.f test case assumes that -Wextra enables
  -Wununused-parameter, but this does not happen.  No warning is printed on
  line 4, leading to a test failure.
 
 I don't understand how it was working before. What is exactly the
 command-line passed to that testcase?

I think in Fortran, -Wextra just generates -Wunused-parameter because of this:

Index: options.c
===
--- options.c   (revision 209347)
+++ options.c   (working copy)
@@ -672,16 +672,11 @@ gfc_handle_option (size_t scode, const c
 case OPT_Wconversion_extra:
   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;

If you want to have the same behavior in Fortran as in the rest of GCC, then
delete the above. The above was enabling -Wunused-parameter just with -Wextra
(only in Fortran), and because of the existing bug fixed by r210246, this was
never overriden by the general machinery.

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #11 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
Note that the above code is broken in other ways:

-Wno-unused-parameter -Wextra will enable -Wunused-parameter, which is not what
should happen.

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

Manuel López-Ibáñez manu at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jsm28 at gcc dot gnu.org

--- Comment #12 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #10)
 If you want to have the same behavior in Fortran as in the rest of GCC, then
 delete the above. The above was enabling -Wunused-parameter just with
 -Wextra (only in Fortran), and because of the existing bug fixed by r210246,
 this was never overriden by the general machinery.

On the other hand, if you want to have a different behavior, then in the ideal
case this should work:


Index: lang.opt
===
--- lang.opt(revision 210292)
+++ lang.opt(working copy)
@@ -299,10 +299,14 @@ Warn if a user-procedure has the same na

 Wunused-dummy-argument
 Fortran Warning
 Warn about unused dummy arguments.

+Wunused-parameter
+LangEnabledBy(Fortran,Wextra)
+; Documented in common.opt
+
 Wzerotrip
 Fortran Warning
 Warn about zero-trip DO loops

 cpp


Unfortunately, the handlers for the options are set up such that the language
specific handlers are executed before the common_handler (which is executed
before the target-specific handler). 

Joseph, why is that so? I think it makes sense that the FEs can override the
common settings, like the targets can.

The alternative is to duplicate the option in every FE and remove it from
common.opt. That seems quite ugly to me.

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #13 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
This builds gfortran and fixes the testcase, but I haven't tested it beyond
that.


Index: lang.opt
===
--- lang.opt(revision 210292)
+++ lang.opt(working copy)
@@ -299,10 +299,14 @@ Warn if a user-procedure has the same na

 Wunused-dummy-argument
 Fortran Warning
 Warn about unused dummy arguments.

+Wunused-parameter
+LangEnabledBy(Fortran,Wextra)
+; Documented in common.opt
+
 Wzerotrip
 Fortran Warning
 Warn about zero-trip DO loops

 cpp
Index: opts-global.c
===
--- opts-global.c   (revision 210292)
+++ opts-global.c   (working copy)
@@ -271,14 +271,14 @@ void
 set_default_handlers (struct cl_option_handlers *handlers)
 {
   handlers-unknown_option_callback = unknown_option_callback;
   handlers-wrong_lang_callback = complain_wrong_lang;
   handlers-num_handlers = 3;
-  handlers-handlers[0].handler = lang_handle_option;
-  handlers-handlers[0].mask = initial_lang_mask;
-  handlers-handlers[1].handler = common_handle_option;
-  handlers-handlers[1].mask = CL_COMMON;
+  handlers-handlers[0].handler = common_handle_option;
+  handlers-handlers[0].mask = CL_COMMON;
+  handlers-handlers[1].handler = lang_handle_option;
+  handlers-handlers[1].mask = initial_lang_mask;
   handlers-handlers[2].handler = target_handle_option;
   handlers-handlers[2].mask = CL_TARGET;
 }

 /* Parse command line options and set default flag values.  Do minimal

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread manu at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #14 from Manuel López-Ibáñez manu at gcc dot gnu.org ---
(In reply to Manuel López-Ibáñez from comment #13)
 This builds gfortran and fixes the testcase, but I haven't tested it beyond
 that.

Together with the patch in comment #10, of course.

[Bug fortran/61126] gfortran does not enable -Wununused-parameter with -Wextra

2014-05-09 Thread joseph at codesourcery dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61126

--- Comment #15 from joseph at codesourcery dot com joseph at codesourcery dot 
com ---
I think that if the order in which the handlers are executed matters, 
something is too fragile in those handlers.