public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include)
@ 2022-11-08 22:37 sam at gentoo dot org
  2022-11-09 13:14 ` [Bug c/107583] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: sam at gentoo dot org @ 2022-11-08 22:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107583
           Summary: Missing fixit for struct members (e.g. time_t, missing
                    <time.h> include)
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sam at gentoo dot org
  Target Milestone: ---

Created attachment 53855
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53855&action=edit
a-foo.i

```
$ cat /tmp/foo.c
struct foo {
        time_t mytime; /* missing <time.h> include should trigger fixit */
}

$ gcc /tmp/foo.c
foo.c:2:9: error: unknown type name 'time_t'
    2 |         time_t mytime; /* missing <time.h> include should trigger fixit
*/
      |         ^~~~~~
foo.c:3:1: error: expected identifier or '(' at end of input
    3 | }
      | ^
```

```
# gcc --version
gcc (Gentoo 12.2.1_p20221008 p1) 12.2.1 20221008
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

Expected output is a <time.h> "fixit" like:
```
test.c:3:13: error: unknown type name 'time_t'
    3 | void myfunc(time_t test) {
      |             ^~~~~~
test.c:2:1: note: 'time_t' is defined in header '<time.h>'; did you forget to
'#include <time.h>'?
    1 | #include <stdio.h>
  +++ |+#include <time.h>
    2 |
```

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

* [Bug c/107583] Missing fixit for struct members (e.g. time_t, missing <time.h> include)
  2022-11-08 22:37 [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include) sam at gentoo dot org
@ 2022-11-09 13:14 ` redi at gcc dot gnu.org
  2023-06-15 13:45 ` dmalcolm at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2022-11-09 13:14 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-11-09
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
FWIW it works as expected for C++.

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

* [Bug c/107583] Missing fixit for struct members (e.g. time_t, missing <time.h> include)
  2022-11-08 22:37 [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include) sam at gentoo dot org
  2022-11-09 13:14 ` [Bug c/107583] " redi at gcc dot gnu.org
@ 2023-06-15 13:45 ` dmalcolm at gcc dot gnu.org
  2023-06-15 13:52 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-06-15 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at gcc dot gnu.org

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
get_stdlib_header_for_name in gcc/c-family/known-headers.cc has had:

  {"time_t", {"<time.h>", "<ctime>"} },

since r13-1369-gd489ec082ea214.

Seems to work at file scope, but not within "struct foo":
  https://godbolt.org/z/4EWPxboqP

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

* [Bug c/107583] Missing fixit for struct members (e.g. time_t, missing <time.h> include)
  2022-11-08 22:37 [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include) sam at gentoo dot org
  2022-11-09 13:14 ` [Bug c/107583] " redi at gcc dot gnu.org
  2023-06-15 13:45 ` dmalcolm at gcc dot gnu.org
@ 2023-06-15 13:52 ` dmalcolm at gcc dot gnu.org
  2023-06-16  0:59 ` cvs-commit at gcc dot gnu.org
  2023-06-16  1:03 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-06-15 13:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |dmalcolm at gcc dot gnu.org

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Am working on a fix

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

* [Bug c/107583] Missing fixit for struct members (e.g. time_t, missing <time.h> include)
  2022-11-08 22:37 [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include) sam at gentoo dot org
                   ` (2 preceding siblings ...)
  2023-06-15 13:52 ` dmalcolm at gcc dot gnu.org
@ 2023-06-16  0:59 ` cvs-commit at gcc dot gnu.org
  2023-06-16  1:03 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-16  0:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:57446d1bc9757ee1fb030600d38fa9487231f2a4

commit r14-1876-g57446d1bc9757ee1fb030600d38fa9487231f2a4
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Jun 15 20:56:41 2023 -0400

    c: add name hints to c_parser_declspecs [PR107583]

    PR c/107583 notes that we weren't issuing a hint for

      struct foo {
        time_t mytime; /* missing <time.h> include should trigger fixit */
      };

    in the C frontend.

    The root cause is that one of the "unknown type name" diagnostics
    was missing logic to emit hints, which this patch fixes.

    gcc/c/ChangeLog:
            PR c/107583
            * c-parser.cc (c_parser_declspecs): Add hints to "unknown type
            name" error.

    gcc/testsuite/ChangeLog:
            PR c/107583
            * c-c++-common/spellcheck-pr107583.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

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

* [Bug c/107583] Missing fixit for struct members (e.g. time_t, missing <time.h> include)
  2022-11-08 22:37 [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include) sam at gentoo dot org
                   ` (3 preceding siblings ...)
  2023-06-16  0:59 ` cvs-commit at gcc dot gnu.org
@ 2023-06-16  1:03 ` dmalcolm at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2023-06-16  1:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Should be fixed on trunk for gcc 14 by the above patch.

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

end of thread, other threads:[~2023-06-16  1:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 22:37 [Bug c/107583] New: Missing fixit for struct members (e.g. time_t, missing <time.h> include) sam at gentoo dot org
2022-11-09 13:14 ` [Bug c/107583] " redi at gcc dot gnu.org
2023-06-15 13:45 ` dmalcolm at gcc dot gnu.org
2023-06-15 13:52 ` dmalcolm at gcc dot gnu.org
2023-06-16  0:59 ` cvs-commit at gcc dot gnu.org
2023-06-16  1:03 ` 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).