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 |
```

Reply via email to