public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/104289] New: -fdiagnostics-parseable-fixits doesn't always generate fixit notes
@ 2022-01-30 13:06 eric.pouech at orange dot fr
  2022-01-30 20:46 ` [Bug c/104289] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: eric.pouech at orange dot fr @ 2022-01-30 13:06 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104289
           Summary: -fdiagnostics-parseable-fixits doesn't always generate
                    fixit notes
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.pouech at orange dot fr
  Target Milestone: ---

[eric]$ cat b2.c
#include <stdio.h>

#define foo(x...) printf(x);

int main(void)
{
    long l = 0;
    foo("this is a"
        "long line: %d\n", l);              
    return 0;
}
[eric]$ LC_ALL=C gcc -Wall -fdiagnostics-parseable-fixits -c b2.c
b2.c: In function 'main':
b2.c:8:9: warning: format '%d' expects argument of type 'int', but argument 2
has type 'long int' [-Wformat=]
    8 |     foo("this is a"
      |         ^~~~~~~~~~~
    9 |         "long line: %d\n", l);
      |                            ~
      |                            |
      |                            long int
b2.c:3:26: note: in definition of macro 'foo'
    3 | #define foo(x...) printf(x);
      |                          ^

I'm expecting a fixit note to be present.
Note: the same snipnet without the multi line string, or the macro work as
expected.

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

* [Bug c/104289] -fdiagnostics-parseable-fixits doesn't always generate fixit notes
  2022-01-30 13:06 [Bug c/104289] New: -fdiagnostics-parseable-fixits doesn't always generate fixit notes eric.pouech at orange dot fr
@ 2022-01-30 20:46 ` pinskia at gcc dot gnu.org
  2022-01-31 15:08 ` dmalcolm at gcc dot gnu.org
  2022-02-02 10:12 ` eric.pouech at orange dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-30 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

* [Bug c/104289] -fdiagnostics-parseable-fixits doesn't always generate fixit notes
  2022-01-30 13:06 [Bug c/104289] New: -fdiagnostics-parseable-fixits doesn't always generate fixit notes eric.pouech at orange dot fr
  2022-01-30 20:46 ` [Bug c/104289] " pinskia at gcc dot gnu.org
@ 2022-01-31 15:08 ` dmalcolm at gcc dot gnu.org
  2022-02-02 10:12 ` eric.pouech at orange dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-01-31 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |WONTFIX

--- Comment #1 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Thanks for filing this bug.

I think you'll see the fix-its appear/disappear under similar situations if you
look at the output of -fdiagnostics-format=json.

GCC only generates fix-it hints in sufficiently simple situations, but gives up
in some cases involving macros, or where the locations appear unsuitable.  The
specifics are in:
  https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libcpp/line-map.cc
where various rich_location::add_fixit_* methods can fail and call
rich_location::stop_supporting_fixits, which has many ways in which the
locations of a fix-it hint can be sufficiently "awkward" for the hints in that
rich_location to be rejected.

I'm going to mark this as WONTFIX as I don't intend to try to handle these
awkward cases (macros, in particular), but if it's failing on something else
you think is reasonable to support, feel free to reopen.

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

* [Bug c/104289] -fdiagnostics-parseable-fixits doesn't always generate fixit notes
  2022-01-30 13:06 [Bug c/104289] New: -fdiagnostics-parseable-fixits doesn't always generate fixit notes eric.pouech at orange dot fr
  2022-01-30 20:46 ` [Bug c/104289] " pinskia at gcc dot gnu.org
  2022-01-31 15:08 ` dmalcolm at gcc dot gnu.org
@ 2022-02-02 10:12 ` eric.pouech at orange dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: eric.pouech at orange dot fr @ 2022-02-02 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from eric.pouech at orange dot fr ---
Thx for looking into it.
For sake of completeness, clang supports it flawlessly.

[eric]$ clang -fdiagnostics-parseable-fixits -c b2.c
b2.c:9:28: warning: format specifies type 'int' but the argument has type
'long' [-Wformat]
        "long line: %d\n", l);              
                    ~~     ^
                    %ld
fix-it:"b2.c":{9:21-9:23}:"%ld"
b2.c:3:26: note: expanded from macro 'foo'
#define foo(x...) printf(x);
                         ^
1 warning generated.

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

end of thread, other threads:[~2022-02-02 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-30 13:06 [Bug c/104289] New: -fdiagnostics-parseable-fixits doesn't always generate fixit notes eric.pouech at orange dot fr
2022-01-30 20:46 ` [Bug c/104289] " pinskia at gcc dot gnu.org
2022-01-31 15:08 ` dmalcolm at gcc dot gnu.org
2022-02-02 10:12 ` eric.pouech at orange dot fr

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).