https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102953
--- Comment #16 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Andrew Cooper from comment #14)
> (In reply to H.J. Lu from comment #13)
> > (In reply to Andrew Cooper from comment #11)
> > >
> > > There should be a diagnostic, but it ought to include cf_check in the type
> > > it prints.
> >
> > Try the v3 patch.
>
> Thanks. Now get:
>
> proto.c:2:37: error: conflicting types with implied 'nocf_check' attribute
> for 'foo'; have 'void(void)'
> 2 | static void __attribute__((unused)) foo(void)
> | ^~~
> proto.c:1:39: note: previous declaration of 'foo' with type 'void(void)'
> 1 | static void __attribute__((cf_check)) foo(void);
> | ^~~
>
> which at least highlights the issue. Any variant like this, but possibly
> even simply reporting 'void __attribute__((nocf_check))(void)' should be
> fine.
The v4 patch changed it to
bar1.c:2:37: error: conflicting types for ‘foo’; have ‘void(void)’ with implied
‘nocf_check’ attribute
2 | static void __attribute__((unused)) foo(void)
| ^~~
bar1.c:1:39: note: previous declaration of ‘foo’ with type ‘void(void)’
1 | static void __attribute__((cf_check)) foo(void);
| ^~~
bar1.c:5:21: warning: initialization of ‘void (*)(void)’ from incompatible
pointer type ‘void (__attribute__((nocf_check)) *)(void)’
[-Wincompatible-pointer-types]
5 | void (*ptr)(void) = foo;
| ^~~