[Bug fortran/66605] -Wunused-parameter causes internal compiler error with gfortran 5.1.0

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Jun 20 16:50:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66605

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-20
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
The problem is that 
0x6b9191 gfc_generate_function_code(gfc_namespace*)
        /home/manuel/test1/pristine/gcc/fortran/trans-decl.c:6021

invokes code that may generate warnings from the middle-end (like
-Wunused-parameter), however, gfc_diagnostics_finish has not been called yet.

I don't know the Fortran FE well enough to decide whether
gfc_diagnostics_finish should be called earlier (or are fortran diagnostics
expected after this point?), or we should special case this call by using
something like:

Index: error.c
===================================================================
--- error.c     (revision 224467)
+++ error.c     (working copy)
@@ -1461,21 +1461,27 @@ gfc_errors_to_warnings (bool f)
 {
   warnings_not_errors = f;
 }

 void
-gfc_diagnostics_init (void)
+gfc_diagnostics_defaults (void)
 {
   diagnostic_starter (global_dc) = gfc_diagnostic_starter;
   diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
   diagnostic_format_decoder (global_dc) = gfc_format_decoder;
   global_dc->caret_chars[0] = '1';
   global_dc->caret_chars[1] = '2';
+}
+
+void
+gfc_diagnostics_init (void)
+{
   pp_warning_buffer = new (XNEW (output_buffer)) output_buffer ();
   pp_warning_buffer->flush_p = false;
   pp_error_buffer = &(error_buffer.buffer);
   pp_error_buffer->flush_p = false;
+  gfc_diagnostics_defaults ();
 }

 void
 gfc_diagnostics_finish (void)
 {
Index: trans-decl.c
===================================================================
--- trans-decl.c        (revision 224467)
+++ trans-decl.c        (working copy)
@@ -6016,11 +6016,15 @@ gfc_generate_function_code (gfc_namespac
         the cgraph node for this function.  */
       if (!has_coarray_vars || flag_coarray != GFC_FCOARRAY_LIB)
        (void) cgraph_node::create (fndecl);
     }
   else
-    cgraph_node::finalize_function (fndecl, true);
+    {
+      gfc_diagnostics_finish ();
+      cgraph_node::finalize_function (fndecl, true);
+      gfc_diagnostics_defaults ();
+    }

   gfc_trans_use_stmts (ns);
   gfc_traverse_ns (ns, gfc_emit_parameter_debug_info);

   if (sym->attr.is_main_program)


More information about the Gcc-bugs mailing list