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

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-06-12

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
With the default diagnostic output format, for this error it looks like
gfc_error_opt uses a "buffered_p" global; the message is written to a
pp_error_buffer, rather than the diagnostic context's regular pretty printer.

The buffering is enabled here:

(gdb) bt
#0  gfc_buffer_error (flag=true) at ../../src/gcc/fortran/error.cc:120
#1  0x0000000000b725f7 in next_statement () at
../../src/gcc/fortran/parse.cc:1611
#2  0x0000000000b7af20 in gfc_parse_file () at
../../src/gcc/fortran/parse.cc:6738
#3  0x0000000000be3143 in gfc_be_parse_file () at
../../src/gcc/fortran/f95-lang.cc:229
#4  0x0000000001523847 in compile_file () at ../../src/gcc/toplev.cc:452
#5  0x0000000001527367 in do_compile (no_backend=false) at
../../src/gcc/toplev.cc:2144
#6  0x00000000015277f9 in toplev::main (this=0x7fffffffde6a, argc=14,
argv=0x7fffffffdf78) at ../../src/gcc/toplev.cc:2296
#7  0x0000000002e4ab76 in main (argc=14, argv=0x7fffffffdf78) at
../../src/gcc/main.cc:39




#1  0x0000000000b725f7 in next_statement () at
../../src/gcc/fortran/parse.cc:1611
1611          gfc_buffer_error (true);
(gdb) list
1606      gfc_current_ns->old_equiv = gfc_current_ns->equiv;
1607      gfc_current_ns->old_data = gfc_current_ns->data;
1608      for (;;)
1609        {
1610          gfc_statement_label = NULL;
1611          gfc_buffer_error (true);     <<<<<< BUFFERING ENABLED HERE
1612    
1613          if (gfc_at_eol ())
1614            gfc_advance_line ();
1615    
1616          gfc_skip_comments ();
1617    
1618          if (gfc_at_end ())
1619            {
1620              st = ST_NONE;
1621              break;
1622            }
1623    
1624          if (gfc_define_undef_line ())
1625            continue;
1626    
1627          old_locus = gfc_current_locus;
1628    
1629          st = (gfc_current_form == FORM_FIXED) ? next_fixed () : next_free
();
1630    
1631          if (st != ST_NONE)
1632            break;
1633        }
1634    
1635      gfc_buffer_error (false);   <<<<<< BUFFERING DISABLED HERE


The output handling for json/sarif doesn't know about this fortran-specific
buffered_p thing, hence these buffered errors get erroneously added to the
JSON/SARIF output.

Reply via email to