public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/97687] New: -Wfatal-errors prints some notes but not others
@ 2020-11-03  4:01 nick at ludocode dot com
  2024-06-26 10:06 ` [Bug c/97687] " egallager at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: nick at ludocode dot com @ 2020-11-03  4:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97687
           Summary: -Wfatal-errors prints some notes but not others
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nick at ludocode dot com
  Target Milestone: ---

In file a.c:

    #define FOO foo
    typedef int FOO;
    typedef short FOO;


gcc a.c

    a.c:1:13: error: conflicting types for ‘foo’
        1 | #define FOO foo
        |             ^~~
    a.c:3:15: note: in expansion of macro ‘FOO’
        3 | typedef short FOO;
        |               ^~~
    a.c:1:13: note: previous declaration of ‘foo’ was here
        1 | #define FOO foo
        |             ^~~
    a.c:2:13: note: in expansion of macro ‘FOO’
        2 | typedef int FOO;
        |             ^~~


gcc -Wfatal-errors a.c

    a.c:1:13: error: conflicting types for ‘foo’
        1 | #define FOO foo
        |             ^~~
    a.c:3:15: note: in expansion of macro ‘FOO’
        3 | typedef short FOO;
        |               ^~~
    compilation terminated due to -Wfatal-errors.


-Wfatal-errors is printing some notes but not others. It would be much more
useful (to me) if it printed all of them, although in bugs #33952 and #37773
you claim that -Wfatal-errors is not for users, so I'm not really sure what you
want it to do here.

For what it's worth -fmax-errors=1 does the right thing and prints all three
notes, which I assume is what you want me to use. Unfortunately -fmax-errors=1
isn't supported by Clang so this makes my build system more complicated. Clang
supports -Wfatal-errors and prints all three notes.


$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib
--libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
@ 2024-06-26 10:06 ` egallager at gcc dot gnu.org
  2024-06-26 20:23 ` dmalcolm at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: egallager at gcc dot gnu.org @ 2024-06-26 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |dmalcolm at gcc dot gnu.org,
                   |                            |egallager at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-06-26

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
Confirmed, I've seen this too. I think some of David's work with auto
diagnostic groups might help here?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
  2024-06-26 10:06 ` [Bug c/97687] " egallager at gcc dot gnu.org
@ 2024-06-26 20:23 ` dmalcolm at gcc dot gnu.org
  2024-06-26 20:41 ` dmalcolm at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-06-26 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Nicholas Fraser from comment #0)

Behavior confirmed on Compiler Explorer with trunk (for GCC 15); URLs as
follows:

> 
> gcc a.c

  https://godbolt.org/z/rxbz5eWMd

> gcc -Wfatal-errors a.c
> 

  https://godbolt.org/z/e86nPefdM

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
  2024-06-26 10:06 ` [Bug c/97687] " egallager at gcc dot gnu.org
  2024-06-26 20:23 ` dmalcolm at gcc dot gnu.org
@ 2024-06-26 20:41 ` dmalcolm at gcc dot gnu.org
  2024-06-26 20:43 ` dmalcolm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-06-26 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
The "in expansion of macro ‘FOO’" notes (messages 2 and 4) are coming from the
diagnostic finalizer, and so they are effectively printed as part of the first
"error" (message 1) and the "previous declaration of ‘foo’ was here" note
(message 3).

Messages 1 and 3 are both coming from within gcc/c/c-decl.cc: duplicate_decls. 
There is an auto_diagnostic_group.

Perhaps -Wfatal-errors should delay bailing out if an auto_diagnostic_group is
still "in flight", but immediately bail out if it's about to emit another
non-"note" diagnostic?

That might give less surprising behavior, but probably has some nasty
interactions with existing code.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
                   ` (2 preceding siblings ...)
  2024-06-26 20:41 ` dmalcolm at gcc dot gnu.org
@ 2024-06-26 20:43 ` dmalcolm at gcc dot gnu.org
  2024-06-26 21:20 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-06-26 20:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
In particular, consider e.g. the cases of SARIF and json output.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
                   ` (3 preceding siblings ...)
  2024-06-26 20:43 ` dmalcolm at gcc dot gnu.org
@ 2024-06-26 21:20 ` dmalcolm at gcc dot gnu.org
  2024-06-26 21:21 ` dmalcolm at gcc dot gnu.org
  2024-06-26 21:23 ` dmalcolm at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-06-26 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Created attachment 58523
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58523&action=edit
WIP patch to try to print all notes for an error with -Wfatal-errors

Am attaching an experimental patch for this that keeps the compiler around on
-Wfatal-errors if there's an active diagnostic_group until after the
diagnostic_group ends, or a non-note follows.

Unfinished, as it would need:
- ChangeLog
- docs update
- test cases (for text, sarif and json output); possibly via a test plugin to
synthesize the case of a followup error within the same diagnostic_group

But the main thing is, are we comfortable not bailing out immediately on the
error in -Wfatal-errors?  There could be non-trivial work being done in the
scope of the auto_diagnostic_context.  Perhaps something to discuss on mailing
list.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
                   ` (4 preceding siblings ...)
  2024-06-26 21:20 ` dmalcolm at gcc dot gnu.org
@ 2024-06-26 21:21 ` dmalcolm at gcc dot gnu.org
  2024-06-26 21:23 ` dmalcolm at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-06-26 21:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--- Comment #6 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #5)
[...]

> Unfinished, as it would need:

also: fixing the typo "m_handing_fatal_error" -> "m_handling_fatal_error"

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/97687] -Wfatal-errors prints some notes but not others
  2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
                   ` (5 preceding siblings ...)
  2024-06-26 21:21 ` dmalcolm at gcc dot gnu.org
@ 2024-06-26 21:23 ` dmalcolm at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2024-06-26 21:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #5)
> scope of the auto_diagnostic_context.
               ^^^^^^^^^^^^^^^^^^^^^^^
               auto_diagnostic_group

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-06-26 21:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03  4:01 [Bug c/97687] New: -Wfatal-errors prints some notes but not others nick at ludocode dot com
2024-06-26 10:06 ` [Bug c/97687] " egallager at gcc dot gnu.org
2024-06-26 20:23 ` dmalcolm at gcc dot gnu.org
2024-06-26 20:41 ` dmalcolm at gcc dot gnu.org
2024-06-26 20:43 ` dmalcolm at gcc dot gnu.org
2024-06-26 21:20 ` dmalcolm at gcc dot gnu.org
2024-06-26 21:21 ` dmalcolm at gcc dot gnu.org
2024-06-26 21:23 ` dmalcolm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).